-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
285 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Function ConvertFrom-OmnidbDetail { | ||
<# | ||
.SYNOPSIS | ||
Returns an array from "omnidb [options] -detail" output | ||
.DESCRIPTION | ||
Accepts the output of "omnidb [options] -detail" in pipline and returns a PowerShell array | ||
.EXAMPLE | ||
omnidb -session 2019/02/07-7 -detail | ConvertFrom-OmnidbDetail | ||
.LINK | ||
https://github.com/jorioux/PowerDP | ||
#> | ||
|
||
Param( | ||
[Parameter(ValueFromPipeline = $true)] | ||
[string[]]$Lines, | ||
[switch]$FullObjectName | ||
) | ||
BEGIN { | ||
$ArrayOutput = @() | ||
$Item = New-Object PSObject | ||
} | ||
PROCESS { | ||
|
||
$Lines | %{ | ||
#An empty line means its a new item | ||
if([string]::IsNullOrWhiteSpace($_)){ | ||
#Add Item to Array only if its not empty | ||
if(($Item|Get-Member -Type NoteProperty).count -gt 0){ | ||
$ArrayOutput += $Item | ||
$Item = New-Object PSObject | ||
} | ||
} | ||
if($_ -match "^\s*((?:[\w\[\]]\s?)+)\s+:\s(.*)"){ | ||
$Name = $Matches[1].trimend() | ||
$Value = $Matches[2] | ||
|
||
if($Name -eq "Object name" -and !$FullObjectName){ | ||
$Value = [regex]::Match($Value, '^(.+):.*').groups[1].value | ||
} | ||
|
||
#Convert values to correct type | ||
if($Name -match "^.*(Time|Started|Finished).*$"){ | ||
$Value = $Value | ||
} elseif($Name -match "^.*(Number).*$"){ | ||
$Value = ConvertTo-Int($Value) | ||
} elseif($Value -match "^(\d+)\sKB"){ | ||
$Name = $Name + " (GB)" | ||
$Value = ConvertTo-Int($Matches[1]/1024/1024) | ||
} elseif($Name -match "^(.*)\s\[KB.*"){ | ||
$Name = $Matches[1] + " (GB)" | ||
$Value = ConvertTo-Int($Value/1024/1024) | ||
} | ||
$Item | Add-Member -type NoteProperty -Name $Name -Value $Value | ||
|
||
} | ||
} | ||
} | ||
END { | ||
$ArrayOutput += $Item | ||
return $ArrayOutput | Select-Object * | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Function ConvertTo-Int { | ||
<# | ||
.SYNOPSIS | ||
Converts a string value to a Int or Double | ||
#> | ||
[CmdletBinding()] | ||
Param( | ||
[Parameter(ValueFromPipeline = $true)] | ||
[ValidateNotNullOrEmpty()] | ||
$IntVal | ||
) | ||
try{ | ||
if($IntVal.GetType().FullName -match '^.*Int.*$') { | ||
return [int]$IntVal | ||
} elseif($IntVal.GetType().FullName -match '^.*(Double|Float).*$') { | ||
return [math]::Round([double]$IntVal,2) | ||
} elseif($IntVal -match '^.*(\,|\.).*$') { | ||
return [math]::Round([double]($IntVal.replace(',','.')),2) | ||
} else { | ||
return [int]($IntVal) | ||
} | ||
} catch { | ||
return $IntVal | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Function Get-Omnidb { | ||
<# | ||
.SYNOPSIS | ||
Returns an array with session detail | ||
.DESCRIPTION | ||
Fetches the session detail and returns a PowerShell array | ||
.EXAMPLE | ||
Get-Omnidb -Session 2019/02/07-7 | ||
.LINK | ||
https://github.com/jorioux/PowerDP | ||
#> | ||
|
||
[CmdletBinding()] | ||
Param( | ||
[Parameter(Mandatory=$true, ValueFromPipeline = $true)] | ||
[ValidateNotNullOrEmpty()] | ||
[string]$Session, | ||
[switch]$Media, | ||
[switch]$Listcopies | ||
) | ||
|
||
if($Media){ | ||
$Cmd = "omnidb -session $Session -media -detail" | ||
} elseif($Listcopies){ | ||
$Output = (Get-Omnidb -Session $Session) | ||
if($Output -eq $null){ | ||
return $Output | ||
} else { | ||
$CopyID = $Output.'Copy ID' | ||
} | ||
$CopyID = $CopyID.split(' ')[0] | ||
$Cmd = "omnidb -copyid $CopyID -listcopies -detail" | ||
} else { | ||
$Cmd = "omnidb -session $Session -detail" | ||
} | ||
|
||
$Output = (Invoke-Expression -Command $Cmd) | ||
if($Output.count -le 2){ | ||
return $Output | ||
} else { | ||
return $Output | ConvertFrom-OmnidbDetail | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
Function Get-Omnirpt { | ||
<# | ||
.SYNOPSIS | ||
omnirpt -report session_objects | ||
.DESCRIPTION | ||
Converts the session_objects report to a PowerShell array | ||
.EXAMPLE | ||
Get-Omnirpt 2018/03/30-01 | ||
.LINK | ||
https://github.com/jorioux/PowerDP | ||
#> | ||
|
||
[CmdletBinding()] | ||
Param( | ||
[Parameter(ValueFromPipeline = $true)] | ||
[string]$Report, | ||
[string]$Session, | ||
[string]$Timeframe, | ||
[int]$Days | ||
) | ||
|
||
$ValidReports = @( | ||
'list_sessions', | ||
'used_media', | ||
'host_statistics', | ||
'obj_nobackup', | ||
'obj_copies', | ||
'obj_lastbackup', | ||
'obj_avesize', | ||
'media_list', | ||
'single_session', | ||
'session_objects', | ||
'session_hosts', | ||
'session_devices', | ||
'session_media', | ||
'session_objcopies' | ||
) | ||
|
||
if(!$ValidReports.Contains($Report)){ | ||
write-host "Not a valid report. Valid reports are :`n" | ||
$ValidReports | %{write-host "`t$_"} | ||
return "" | ||
} | ||
|
||
$Cmd = "omnirpt -report $Report " | ||
|
||
if(![string]::IsNullOrEmpty($Session)){ | ||
$Cmd += " -session $Session " | ||
} | ||
|
||
if($Days -ge 1){ | ||
$Timeframe = [string]($Days*24) | ||
$Timeframe = $Timeframe + " " + $Timeframe | ||
$Cmd += " -timeframe $Timeframe " | ||
} elseif(![string]::IsNullOrEmpty($Timeframe)){ | ||
$Cmd += " -timeframe $Timeframe " | ||
} | ||
|
||
$Cmd += ' -tab' | ||
|
||
$Array = Invoke-Expression -Command $Cmd | ConvertFrom-Omnirpt | ||
|
||
return $Array | Select-Object * | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.