├── README.md ├── .vscode └── settings.json ├── .gitignore ├── prtgshell ├── Classes │ ├── Helpers │ │ ├── HelperWeb.Class.ps1 │ │ ├── HelperProcessError.Class.ps1 │ │ └── HelperRegex.Class.ps1 │ └── Main │ │ ├── PrtgGroup.Class.ps1 │ │ ├── PrtgDevice.Class.ps1 │ │ ├── PrtgProbe.Class.ps1 │ │ └── PrtgServer.Class.ps1 ├── Public │ ├── Get-PrtgSensorHistoricData.ps1 │ ├── Get-PrtgCredentialUsage.ps1 │ ├── Get-PrtgObjectParentId.ps1 │ ├── Get-PrtgObjectProperty.ps1 │ ├── Get-PrtgObject.ps1 │ ├── Get-PrtgServer.ps1 │ └── Get-PrtgTableData.ps1 ├── prtgshell.psm1 ├── prtgshell.psd1 └── en-US │ └── prtgshell-help.xml ├── appveyor.yml ├── LICENSE ├── docs ├── Get-PrtgObject.md ├── Get-PrtgCredentialUsage.md ├── Get-PrtgObjectParentId.md ├── Get-PrtgObjectProperty.md ├── Get-PrtgSensorHistoricData.md ├── Get-PrtgTableData.md └── Get-PrtgServer.md ├── deploy.psdeploy.ps1 ├── psake.ps1 └── Tests └── Get-PrtgServer.Tests.ps1 /README.md: -------------------------------------------------------------------------------- 1 | # prtgshell 2 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | // Adds a newline (line break) after a closing brace. 3 | "powershell.codeFormatting.newLineAfterCloseBrace": false, 4 | 5 | // When enabled, will trim trailing whitespace when saving a file. 6 | "files.trimTrailingWhitespace": true, 7 | 8 | // Format a file on save. A formatter must be available, the file must not be auto-saved, and editor must not be shutting down. 9 | "editor.formatOnSave": true, 10 | 11 | // Controls whether the editor should automatically format the line after typing. 12 | "editor.formatOnType": true 13 | } 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | .AppleDouble 3 | .LSOverride 4 | 5 | # Icon must end with two \r 6 | Icon 7 | 8 | 9 | # Thumbnails 10 | ._* 11 | 12 | # Files that might appear in the root of a volume 13 | .DocumentRevisions-V100 14 | .fseventsd 15 | .Spotlight-V100 16 | .TemporaryItems 17 | .Trashes 18 | .VolumeIcon.icns 19 | .com.apple.timemachine.donotpresent 20 | 21 | # Directories potentially created on remote AFP share 22 | .AppleDB 23 | .AppleDesktop 24 | Network Trash Folder 25 | Temporary Items 26 | .apdisk 27 | 28 | # Real config Files 29 | config.json* 30 | 31 | # Log Files 32 | *.log 33 | -------------------------------------------------------------------------------- /prtgshell/Classes/Helpers/HelperWeb.Class.ps1: -------------------------------------------------------------------------------- 1 | class HelperWeb { 2 | static [string] createQueryString ([hashtable]$hashTable) { 3 | $i = 0 4 | $queryString = "?" 5 | # Sorting hashtable to make testing for proper URLs reliable. 6 | foreach ($hash in ($hashTable.GetEnumerator() | Sort-Object -Property Name)) { 7 | $i++ 8 | if ($hash.Name -eq 'returncount') { 9 | $queryString += 'count' + "=" + [System.Uri]::EscapeDataString($hash.Value) 10 | } else { 11 | $queryString += $hash.Name + "=" + [System.Uri]::EscapeDataString($hash.Value) 12 | } 13 | if ($i -lt $HashTable.Count) { 14 | $queryString += "&" 15 | } 16 | } 17 | return $queryString 18 | } 19 | } -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # See http://www.appveyor.com/docs/appveyor-yml for many more options 2 | # Publish to PowerShell Gallery with this key 3 | environment: 4 | NuGetApiKey: 5 | secure: pqFgvQ46X0mWdDt3CZzuOwBe1R2HHBhK0aPYsrNYqQEezJIVhYSq8XX/VJqN/kWJ 6 | 7 | # Skip on updates to the readme. 8 | # We can force this by adding [skip ci] or [ci skip] anywhere in commit message 9 | skip_commits: 10 | message: /updated readme.*|update readme.*s/ 11 | 12 | # Don't use a build system, our test_script does that 13 | build: false 14 | 15 | # Kick off the CI/CD pipeline 16 | test_script: 17 | - ps: . ./build.ps1 18 | 19 | # Notify Slack 20 | notifications: 21 | - provider: Slack 22 | incoming_webhook: 23 | secure: +hsTjowVQ0VzNCAKjdHZ+zHbyxax38iBzTWupua+IG2vrh+BknPHXcUJ6ZJysSbuYPGfkA7vl61WD6dI4mY+7dNHfHvFuvxeKAo4k0nyhE8= 24 | on_build_success: true 25 | on_build_failure: true 26 | on_build_status_changed: true -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Brian Addicks 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /prtgshell/Public/Get-PrtgSensorHistoricData.ps1: -------------------------------------------------------------------------------- 1 | Function Get-PrtgSensorHistoricData { 2 | [CmdletBinding()] 3 | Param ( 4 | [Parameter(Mandatory = $True, Position = 0)] 5 | [int] $SensorId, 6 | 7 | [Parameter(Mandatory = $True, Position = 1)] 8 | [datetime] $RangeStart, 9 | 10 | [Parameter(Mandatory = $True, Position = 2)] 11 | [datetime] $RangeEnd, 12 | 13 | [Parameter(Mandatory = $False, Position = 3)] 14 | [int] $IntervalInSeconds = 3600 15 | ) 16 | 17 | BEGIN { 18 | $PrtgServerObject = $global:PrtgServerObject 19 | $QueryTable = @{} 20 | } 21 | 22 | PROCESS { 23 | $QueryPage = 'historicdata.xml' 24 | $QueryTable.id = $SensorId 25 | $QueryTable.sdate = $RangeStart.ToString("yyyy-MM-dd-HH-mm-ss") 26 | $QueryTable.edate = $RangeEnd.ToString("yyyy-MM-dd-HH-mm-ss") 27 | $QueryTable.avg = $IntervalInSeconds 28 | 29 | $Response = $global:PrtgServerObject.invokeApiQuery($QueryTable, $QueryPage) 30 | $DataPoints = $Response.HistData.Item | Where-Object { $_.'Date Time' -ne 'Averages' } 31 | } 32 | 33 | END { 34 | return $DataPoints 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /docs/Get-PrtgObject.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: prtgshell-help.xml 3 | Module Name: prtgshell 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-PrtgObject 9 | 10 | ## SYNOPSIS 11 | {{Fill in the Synopsis}} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-PrtgObject [-ObjectId] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{Fill in the Description}} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -ObjectId 34 | {{Fill ObjectId Description}} 35 | 36 | ```yaml 37 | Type: Int32[] 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: True (ByPropertyName, ByValue) 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 50 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 51 | 52 | ## INPUTS 53 | 54 | ### System.Int32[] 55 | ## OUTPUTS 56 | 57 | ### System.Object 58 | ## NOTES 59 | 60 | ## RELATED LINKS 61 | -------------------------------------------------------------------------------- /docs/Get-PrtgCredentialUsage.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: prtgshell-help.xml 3 | Module Name: prtgshell 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-PrtgCredentialUsage 9 | 10 | ## SYNOPSIS 11 | {{Fill in the Synopsis}} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-PrtgCredentialUsage [-ObjectId] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{Fill in the Description}} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -ObjectId 34 | {{Fill ObjectId Description}} 35 | 36 | ```yaml 37 | Type: Int32[] 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: True (ByPropertyName, ByValue) 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 50 | 51 | ## INPUTS 52 | 53 | ### System.Int32[] 54 | ## OUTPUTS 55 | 56 | ### System.Object 57 | ## NOTES 58 | 59 | ## RELATED LINKS 60 | -------------------------------------------------------------------------------- /docs/Get-PrtgObjectParentId.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: prtgshell-help.xml 3 | Module Name: prtgshell 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-PrtgObjectParentId 9 | 10 | ## SYNOPSIS 11 | {{Fill in the Synopsis}} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-PrtgObjectParentId [-ObjectId] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{Fill in the Description}} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -ObjectId 34 | {{Fill ObjectId Description}} 35 | 36 | ```yaml 37 | Type: Int32[] 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: True (ByPropertyName, ByValue) 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### CommonParameters 49 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. 50 | For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 51 | 52 | ## INPUTS 53 | 54 | ### System.Int32[] 55 | ## OUTPUTS 56 | 57 | ### System.Object 58 | ## NOTES 59 | 60 | ## RELATED LINKS 61 | -------------------------------------------------------------------------------- /prtgshell/Public/Get-PrtgCredentialUsage.ps1: -------------------------------------------------------------------------------- 1 | function Get-PrtgCredentialUsage { 2 | [CmdletBinding()] 3 | 4 | Param ( 5 | [Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)] 6 | [int[]]$ObjectId 7 | ) 8 | 9 | BEGIN { 10 | $VerbosePrefix = "Get-PrtgCredentialUsage:" 11 | if (!($global:PrtgServerObject.Connected)) { 12 | try { 13 | Throw 14 | } catch { 15 | $PSCmdlet.ThrowTerminatingError([HelperProcessError]::throwCustomError(1000, $global:PrtgServerObject.Hostname)) 16 | } 17 | } 18 | 19 | $ReturnData = @() 20 | } 21 | 22 | PROCESS { 23 | Write-Verbose "$VerbosePrefix Checking Credential Usage for Object: $($ObjectId[0])" 24 | $New = "" | Select-Object -Property ObjectId, ObjectType, WindowsDomain, WindowsUsername, LinuxUsername, EsxUsername, SnmpV3User 25 | $New.ObjectId = $ObjectId[0] 26 | $New.ObjectType = $_.GetType().Name 27 | $New.WindowsDomain = Get-PrtgObjectProperty -Property windowslogindomain -ObjectId $ObjectId 28 | $New.WindowsUsername = Get-PrtgObjectProperty -Property windowsloginusername -ObjectId $ObjectId 29 | $New.LinuxUsername = Get-PrtgObjectProperty -Property linuxloginusername -ObjectId $ObjectId 30 | $New.EsxUsername = Get-PrtgObjectProperty -Property esxuser -ObjectId $ObjectId 31 | $New.SnmpV3User = Get-PrtgObjectProperty -Property snmpuser -ObjectId $ObjectId 32 | 33 | $ReturnData += $New 34 | } 35 | 36 | END { 37 | $ReturnData 38 | } 39 | } -------------------------------------------------------------------------------- /prtgshell/prtgshell.psm1: -------------------------------------------------------------------------------- 1 | # cribbed this from https://www.powershellgallery.com/packages/Idempotion 2 | 3 | $Subs = @( 4 | @{ 5 | Path = 'Classes' 6 | Export = $false 7 | Recurse = $true 8 | Filter = '*.Class.ps1' 9 | Exclude = @( 10 | '*.Tests.ps1' 11 | ) 12 | } , 13 | 14 | @{ 15 | Path = 'Private' 16 | Export = $false 17 | Recurse = $false 18 | Filter = '*-*.ps1' 19 | Exclude = @( 20 | '*.Tests.ps1' 21 | ) 22 | } , 23 | 24 | @{ 25 | Path = 'Public' 26 | Export = $true 27 | Recurse = $false 28 | Filter = '*-*.ps1' 29 | Exclude = @( 30 | '*.Tests.ps1' 31 | ) 32 | } 33 | ) 34 | 35 | 36 | $thisModule = [System.IO.Path]::GetFileNameWithoutExtension($PSCommandPath) 37 | $varName = "__${thisModule}_Export_All" 38 | $exportAll = Get-Variable -Scope Global -Name $varName -ValueOnly -ErrorAction Ignore 39 | 40 | $Subs | ForEach-Object -Process { 41 | $sub = $_ 42 | $thisDir = $PSScriptRoot | Join-Path -ChildPath $sub.Path | Join-Path -ChildPath '*' 43 | $thisDir | 44 | Get-ChildItem -Filter $sub.Filter -Exclude $sub.Exclude -Recurse:$sub.Recurse -ErrorAction Ignore | ForEach-Object -Process { 45 | try { 46 | $Unit = $_.FullName 47 | . $Unit 48 | if ($sub.Export -or $exportAll) { 49 | Export-ModuleMember -Function $_.BaseName -Alias * 50 | } 51 | } catch { 52 | $e = "Could not import '$Unit' with exception: `n`n`n$($_.Exception)" -as $_.Exception.GetType() 53 | throw $e 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /prtgshell/Public/Get-PrtgObjectParentId.ps1: -------------------------------------------------------------------------------- 1 | function Get-PrtgObjectParentId { 2 | [CmdletBinding()] 3 | 4 | Param ( 5 | [Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)] 6 | [int[]]$ObjectId 7 | ) 8 | 9 | BEGIN { 10 | $VerbosePrefix = "Get-PrtgObjectParentId:" 11 | if (!($global:PrtgServerObject.Connected)) { 12 | try { 13 | Throw 14 | } catch { 15 | $PSCmdlet.ThrowTerminatingError([HelperProcessError]::throwCustomError(1000, $global:PrtgServerObject.Hostname)) 16 | } 17 | } 18 | 19 | $QueryPage = 'getobjectstatus.htm' 20 | $ReturnData = @() 21 | } 22 | 23 | PROCESS { 24 | $QueryTable = @{ 25 | "id" = $ObjectId 26 | "name" = 'parentid' 27 | } 28 | Write-Verbose "Looking up Object $ObjectId" 29 | 30 | try { 31 | $Response = $global:PrtgServerObject.invokeApiQuery($QueryTable, $QueryPage) 32 | } catch { 33 | # originally I was catching specific types of exceptions, but apparently they're different between core and non-core, which is stupid 34 | switch -Regex ($_.Exception.Message) { 35 | '401\ \(Unauthorized\)' { 36 | $PSCmdlet.ThrowTerminatingError([HelperProcessError]::throwCustomError(1001, $Server)) 37 | } 38 | default { 39 | $PSCmdlet.ThrowTerminatingError($PSItem) 40 | } 41 | } 42 | } 43 | 44 | $ReturnData += $Response.prtg.result 45 | } 46 | 47 | END { 48 | $ReturnData 49 | } 50 | } -------------------------------------------------------------------------------- /docs/Get-PrtgObjectProperty.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: prtgshell-help.xml 3 | Module Name: prtgshell 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-PrtgObjectProperty 9 | 10 | ## SYNOPSIS 11 | {{Fill in the Synopsis}} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-PrtgObjectProperty [-ObjectId] [-Property] [] 17 | ``` 18 | 19 | ## DESCRIPTION 20 | {{Fill in the Description}} 21 | 22 | ## EXAMPLES 23 | 24 | ### Example 1 25 | ```powershell 26 | PS C:\> {{ Add example code here }} 27 | ``` 28 | 29 | {{ Add example description here }} 30 | 31 | ## PARAMETERS 32 | 33 | ### -ObjectId 34 | {{Fill ObjectId Description}} 35 | 36 | ```yaml 37 | Type: Int32[] 38 | Parameter Sets: (All) 39 | Aliases: 40 | 41 | Required: True 42 | Position: 0 43 | Default value: None 44 | Accept pipeline input: True (ByPropertyName, ByValue) 45 | Accept wildcard characters: False 46 | ``` 47 | 48 | ### -Property 49 | {{Fill Property Description}} 50 | 51 | ```yaml 52 | Type: String 53 | Parameter Sets: (All) 54 | Aliases: 55 | 56 | Required: True 57 | Position: 1 58 | Default value: None 59 | Accept pipeline input: False 60 | Accept wildcard characters: False 61 | ``` 62 | 63 | ### CommonParameters 64 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 65 | 66 | ## INPUTS 67 | 68 | ### System.Int32[] 69 | ## OUTPUTS 70 | 71 | ### System.Object 72 | ## NOTES 73 | 74 | ## RELATED LINKS 75 | -------------------------------------------------------------------------------- /deploy.psdeploy.ps1: -------------------------------------------------------------------------------- 1 | # Generic module deployment. 2 | # This stuff should be moved to psake for a cleaner deployment view 3 | 4 | # ASSUMPTIONS: 5 | 6 | # folder structure of: 7 | # - RepoFolder 8 | # - This PSDeploy file 9 | # - ModuleName 10 | # - ModuleName.psd1 11 | 12 | # Nuget key in $ENV:NugetApiKey 13 | 14 | # Set-BuildEnvironment from BuildHelpers module has populated ENV:BHProjectName 15 | 16 | # Publish to gallery with a few restrictions 17 | if ( 18 | $env:BHPSModulePath -and 19 | $env:BHBuildSystem -ne 'Unknown' -and 20 | $env:BHBranchName -eq "master" -and 21 | $env:BHCommitMessage -match '!deploy' 22 | ) { 23 | Deploy Module { 24 | By PSGalleryModule { 25 | FromSource $ENV:BHPSModulePath 26 | To PSGallery 27 | WithOptions @{ 28 | ApiKey = $ENV:NugetApiKey 29 | } 30 | } 31 | } 32 | } else { 33 | "Skipping deployment: To deploy, ensure that...`n" + 34 | "`t* You are in a known build system (Current: $ENV:BHBuildSystem)`n" + 35 | "`t* You are committing to the master branch (Current: $ENV:BHBranchName) `n" + 36 | "`t* Your commit message includes !deploy (Current: $ENV:BHCommitMessage)" | 37 | Write-Host 38 | } 39 | 40 | # Publish to AppVeyor if we're in AppVeyor 41 | # You can use this to test a build from AppVeyor before pushing to psgallery 42 | # https://psdeploy.readthedocs.io/en/latest/Example-AppVeyorModule-Deployment/ 43 | 44 | if ( 45 | $env:BHPSModulePath -and 46 | $env:BHBuildSystem -eq 'AppVeyor' 47 | ) { 48 | Deploy DeveloperBuild { 49 | By AppVeyorModule { 50 | FromSource $ENV:BHPSModulePath 51 | To AppVeyor 52 | WithOptions @{ 53 | Version = $env:APPVEYOR_BUILD_VERSION 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /prtgshell/Public/Get-PrtgObjectProperty.ps1: -------------------------------------------------------------------------------- 1 | function Get-PrtgObjectProperty { 2 | [CmdletBinding()] 3 | 4 | Param ( 5 | [Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)] 6 | [int[]]$ObjectId, 7 | 8 | [Parameter(Mandatory = $True, Position = 1)] 9 | [string]$Property 10 | ) 11 | 12 | BEGIN { 13 | $VerbosePrefix = "Get-PrtgObjectProperty:" 14 | if (!($global:PrtgServerObject.Connected)) { 15 | try { 16 | Throw 17 | } catch { 18 | $PSCmdlet.ThrowTerminatingError([HelperProcessError]::throwCustomError(1000, $global:PrtgServerObject.Hostname)) 19 | } 20 | } 21 | 22 | $QueryTable = @{} 23 | $QueryTable.name = $Property 24 | 25 | $QueryPage = 'getobjectproperty.htm' 26 | $ReturnData = @() 27 | } 28 | 29 | PROCESS { 30 | $QueryTable.id = $ObjectId 31 | Write-Verbose "Looking up $Property for Object $ObjectId" 32 | 33 | try { 34 | $Response = $global:PrtgServerObject.invokeApiQuery($QueryTable, $QueryPage) 35 | } catch { 36 | # originally I was catching specific types of exceptions, but apparently they're different between core and non-core, which is stupid 37 | switch -Regex ($_.Exception.Message) { 38 | '401\ \(Unauthorized\)' { 39 | $PSCmdlet.ThrowTerminatingError([HelperProcessError]::throwCustomError(1001, $Server)) 40 | } 41 | default { 42 | $PSCmdlet.ThrowTerminatingError($PSItem) 43 | } 44 | } 45 | } 46 | 47 | $ReturnData += $Response.prtg.result 48 | } 49 | 50 | END { 51 | $ReturnData 52 | } 53 | } -------------------------------------------------------------------------------- /prtgshell/Classes/Helpers/HelperProcessError.Class.ps1: -------------------------------------------------------------------------------- 1 | class HelperProcessError { 2 | static [hashtable] newExceptionDefinition ([string]$exceptionType, $exceptionCategory, [string]$message) { 3 | $new = @{} 4 | $new.Exception = New-Object -TypeName $exceptionType -ArgumentList $message 5 | $new.Category = $exceptionCategory 6 | return $new 7 | } 8 | 9 | static [System.Management.Automation.ErrorRecord] throwCustomError ([int]$errorId, [psobject]$object) { 10 | $ErrorLookup = [HelperProcessError]::ExceptionDefinitions.$errorId 11 | return [System.Management.Automation.ErrorRecord]::new( 12 | $ErrorLookup.Exception, 13 | $errorId, 14 | $ErrorLookup.Category, 15 | $object 16 | ) 17 | } 18 | 19 | # List of Exceptions 20 | # The Types and Categories here are generic because I have no idea what subset exist in both core and non-core. 21 | static [hashtable] $ExceptionDefinitions = @{ 22 | 1000 = [HelperProcessError]::newExceptionDefinition('System.ArgumentException', [System.Management.Automation.ErrorCategory]::CloseError, 'No Prtg connection established. Use Get-PrtgServer to connect first.') 23 | 1001 = [HelperProcessError]::newExceptionDefinition('System.ArgumentException', [System.Management.Automation.ErrorCategory]::CloseError, 'Unauthorized, please check your credentials.') 24 | 1002 = [HelperProcessError]::newExceptionDefinition('System.ArgumentException', [System.Management.Automation.ErrorCategory]::CloseError, 'Invalid Column specified for requested Content.') 25 | 1003 = [HelperProcessError]::newExceptionDefinition('System.ArgumentException', [System.Management.Automation.ErrorCategory]::CloseError, 'Cannot find the specified Server. Check the Hostname/Ip and try again.') 26 | 9999 = [HelperProcessError]::newExceptionDefinition('System.ArgumentException', [System.Management.Automation.ErrorCategory]::CloseError, 'Unhandled Exception') # Probably going to mask errors, not sure what else to do at this point. 27 | } 28 | 29 | # Constructor 30 | HelperProcessError () { 31 | } 32 | } -------------------------------------------------------------------------------- /prtgshell/Classes/Main/PrtgGroup.Class.ps1: -------------------------------------------------------------------------------- 1 | class PrtgGroup { 2 | [int]$ObjectId 3 | [System.Xml.XmlElement]$Xml 4 | 5 | [string]$Probe 6 | [string]$Group 7 | [string]$Name 8 | [string]$DownSensor 9 | [int]$DownSensorRaw 10 | [string]$PartialDownSensor 11 | [int]$PartialDownSensorRaw 12 | [string]$DownAcknowledgedSensor 13 | [int]$DownAcknowledgedSensorRaw 14 | [string]$UpSensor 15 | [int]$UpSensorRaw 16 | [string]$WarningSensor 17 | [int]$WarningSensorRaw 18 | [string]$PausedSensor 19 | [int]$PausedSensorRaw 20 | [string]$UnusualSensor 21 | [int]$UnusualSensorRaw 22 | [string]$UndefinedSensor 23 | [int]$UndefinedSensorRaw 24 | 25 | ##################################### Constructors ##################################### 26 | # Constructor with no parameter 27 | PrtgGroup() { 28 | } 29 | 30 | # Contructor that takes return from prtgtabledata 31 | PrtgGroup([System.Xml.XmlElement]$DeviceXml) { 32 | $this.Xml = $DeviceXml 33 | $this.ObjectId = $DeviceXml.objid 34 | $this.Probe = $DeviceXml.probe 35 | $this.Group = $DeviceXml.group 36 | $this.Name = $DeviceXml.name 37 | $this.DownSensor = $DeviceXml.downsens 38 | $this.DownSensorRaw = $DeviceXml.downsens_raw 39 | $this.PartialDownSensor = $DeviceXml.partialdownsens 40 | $this.PartialDownSensorRaw = $DeviceXml.partialdownsens_raw 41 | $this.DownAcknowledgedSensor = $DeviceXml.downacksens 42 | $this.DownAcknowledgedSensorRaw = $DeviceXml.downacksens_raw 43 | $this.UpSensor = $DeviceXml.upsens 44 | $this.UpSensorRaw = $DeviceXml.upsens_raw 45 | $this.WarningSensor = $DeviceXml.warnsens 46 | $this.WarningSensorRaw = $DeviceXml.warnsens_raw 47 | $this.PausedSensor = $DeviceXml.pausedsens 48 | $this.PausedSensorRaw = $DeviceXml.pausedsens_raw 49 | $this.UnusualSensor = $DeviceXml.unusualsens 50 | $this.UnusualSensorRaw = $DeviceXml.unusualsens_raw 51 | $this.UndefinedSensor = $DeviceXml.undefinedsens 52 | $this.UndefinedSensorRaw = $DeviceXml.undefinedsens_raw 53 | } 54 | } -------------------------------------------------------------------------------- /prtgshell/Classes/Main/PrtgDevice.Class.ps1: -------------------------------------------------------------------------------- 1 | class PrtgDevice { 2 | [int]$ObjectId 3 | [string]$Name 4 | [System.Xml.XmlElement]$Xml 5 | 6 | [string]$Probe 7 | [string]$Group 8 | [string]$Device 9 | [string]$Hostname 10 | [string]$DownSensor 11 | [int]$DownSensorRaw 12 | [string]$PartialDownSensor 13 | [int]$PartialDownSensorRaw 14 | [string]$DownAcknowledgedSensor 15 | [int]$DownAcknowledgedSensorRaw 16 | [string]$UpSensor 17 | [int]$UpSensorRaw 18 | [string]$WarningSensor 19 | [int]$WarningSensorRaw 20 | [string]$PausedSensor 21 | [int]$PausedSensorRaw 22 | [string]$UnusualSensor 23 | [int]$UnusualSensorRaw 24 | [string]$UndefinedSensor 25 | [int]$UndefinedSensorRaw 26 | 27 | ##################################### Constructors ##################################### 28 | # Constructor with no parameter 29 | PrtgDevice() { 30 | } 31 | 32 | # Contructor that takes return from prtgtabledata 33 | PrtgDevice([System.Xml.XmlElement]$DeviceXml) { 34 | $this.Xml = $DeviceXml 35 | $this.ObjectId = $DeviceXml.objid 36 | $this.Probe = $DeviceXml.probe 37 | $this.Group = $DeviceXml.group 38 | $this.Device = $DeviceXml.device 39 | $this.Hostname = $DeviceXml.host 40 | $this.DownSensor = $DeviceXml.downsens 41 | $this.DownSensorRaw = $DeviceXml.downsens_raw 42 | $this.PartialDownSensor = $DeviceXml.partialdownsens 43 | $this.PartialDownSensorRaw = $DeviceXml.partialdownsens_raw 44 | $this.DownAcknowledgedSensor = $DeviceXml.downacksens 45 | $this.DownAcknowledgedSensorRaw = $DeviceXml.downacksens_raw 46 | $this.UpSensor = $DeviceXml.upsens 47 | $this.UpSensorRaw = $DeviceXml.upsens_raw 48 | $this.WarningSensor = $DeviceXml.warnsens 49 | $this.WarningSensorRaw = $DeviceXml.warnsens_raw 50 | $this.PausedSensor = $DeviceXml.pausedsens 51 | $this.PausedSensorRaw = $DeviceXml.pausedsens_raw 52 | $this.UnusualSensor = $DeviceXml.unusualsens 53 | $this.UnusualSensorRaw = $DeviceXml.unusualsens_raw 54 | $this.UndefinedSensor = $DeviceXml.undefinedsens 55 | $this.UndefinedSensorRaw = $DeviceXml.undefinedsens_raw 56 | } 57 | } -------------------------------------------------------------------------------- /prtgshell/Public/Get-PrtgObject.ps1: -------------------------------------------------------------------------------- 1 | function Get-PrtgObject { 2 | [CmdletBinding()] 3 | 4 | Param ( 5 | [Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)] 6 | [int[]]$ObjectId 7 | ) 8 | 9 | BEGIN { 10 | $VerbosePrefix = "Get-PrtgObject:" 11 | if (!($global:PrtgServerObject.Connected)) { 12 | try { 13 | Throw 14 | } catch { 15 | $PSCmdlet.ThrowTerminatingError([HelperProcessError]::throwCustomError(1000, $global:PrtgServerObject.Hostname)) 16 | } 17 | } 18 | 19 | $QueryPage = 'table.xml' 20 | $ReturnData = @() 21 | } 22 | 23 | PROCESS { 24 | $QueryTable = @{ 25 | "content" = "sensortree" 26 | "id" = $ObjectId 27 | "columns" = 'objid,probe,group,device,host,downsens,partialdownsens,downacksens,upsens,warnsens,pausedsens,unusualsens,undefinedsens' 28 | } 29 | Write-Verbose "Looking up Object $ObjectId" 30 | 31 | try { 32 | $Response = $global:PrtgServerObject.invokeApiQuery($QueryTable, $QueryPage) 33 | } catch { 34 | # originally I was catching specific types of exceptions, but apparently they're different between core and non-core, which is stupid 35 | switch -Regex ($_.Exception.Message) { 36 | '401\ \(Unauthorized\)' { 37 | $PSCmdlet.ThrowTerminatingError([HelperProcessError]::throwCustomError(1001, $Server)) 38 | } 39 | default { 40 | $PSCmdlet.ThrowTerminatingError($PSItem) 41 | } 42 | } 43 | } 44 | 45 | $Nodes = $Response.prtg.sensortree.nodes 46 | $global:Nodes = $Nodes 47 | 48 | if ($Nodes.device) { 49 | $Object = [PrtgDevice]::new() 50 | $Object.Name = $Nodes.device.name 51 | $Object.ObjectId = $Nodes.device.id[0] 52 | $Object.Hostname = $Nodes.device.host 53 | 54 | $ReturnData += $Object 55 | } else { 56 | Throw "Only works on devices right now" 57 | } 58 | } 59 | 60 | END { 61 | $ReturnData 62 | } 63 | } -------------------------------------------------------------------------------- /docs/Get-PrtgSensorHistoricData.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: prtgshell-help.xml 3 | Module Name: prtgshell 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-PrtgSensorHistoricData 9 | 10 | ## SYNOPSIS 11 | {{Fill in the Synopsis}} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-PrtgSensorHistoricData [-SensorId] [-RangeStart] [-RangeEnd] 17 | [[-IntervalInSeconds] ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | {{Fill in the Description}} 22 | 23 | ## EXAMPLES 24 | 25 | ### Example 1 26 | ```powershell 27 | PS C:\> {{ Add example code here }} 28 | ``` 29 | 30 | {{ Add example description here }} 31 | 32 | ## PARAMETERS 33 | 34 | ### -IntervalInSeconds 35 | {{Fill IntervalInSeconds Description}} 36 | 37 | ```yaml 38 | Type: Int32 39 | Parameter Sets: (All) 40 | Aliases: 41 | 42 | Required: False 43 | Position: 3 44 | Default value: None 45 | Accept pipeline input: False 46 | Accept wildcard characters: False 47 | ``` 48 | 49 | ### -RangeEnd 50 | {{Fill RangeEnd Description}} 51 | 52 | ```yaml 53 | Type: DateTime 54 | Parameter Sets: (All) 55 | Aliases: 56 | 57 | Required: True 58 | Position: 2 59 | Default value: None 60 | Accept pipeline input: False 61 | Accept wildcard characters: False 62 | ``` 63 | 64 | ### -RangeStart 65 | {{Fill RangeStart Description}} 66 | 67 | ```yaml 68 | Type: DateTime 69 | Parameter Sets: (All) 70 | Aliases: 71 | 72 | Required: True 73 | Position: 1 74 | Default value: None 75 | Accept pipeline input: False 76 | Accept wildcard characters: False 77 | ``` 78 | 79 | ### -SensorId 80 | {{Fill SensorId Description}} 81 | 82 | ```yaml 83 | Type: Int32 84 | Parameter Sets: (All) 85 | Aliases: 86 | 87 | Required: True 88 | Position: 0 89 | Default value: None 90 | Accept pipeline input: False 91 | Accept wildcard characters: False 92 | ``` 93 | 94 | ### CommonParameters 95 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 96 | 97 | ## INPUTS 98 | 99 | ### None 100 | ## OUTPUTS 101 | 102 | ### System.Object 103 | ## NOTES 104 | 105 | ## RELATED LINKS 106 | -------------------------------------------------------------------------------- /psake.ps1: -------------------------------------------------------------------------------- 1 | # PSake makes variables declared here available in other scriptblocks 2 | # Init some things 3 | Properties { 4 | # Find the build folder based on build system 5 | $ProjectRoot = $ENV:BHProjectPath 6 | if (-not $ProjectRoot) { 7 | $ProjectRoot = $PSScriptRoot 8 | } 9 | 10 | $Timestamp = Get-date -uformat "%Y%m%d-%H%M%S" 11 | $PSVersion = $PSVersionTable.PSVersion.Major 12 | $TestFile = "TestResults_PS$PSVersion`_$TimeStamp.xml" 13 | $lines = '----------------------------------------------------------------------' 14 | 15 | $Verbose = @{} 16 | if ($ENV:BHCommitMessage -match "!verbose") { 17 | $Verbose = @{Verbose = $True} 18 | } 19 | } 20 | 21 | Task Default -Depends Deploy 22 | 23 | Task Init { 24 | $lines 25 | Set-Location $ProjectRoot 26 | "Build System Details:" 27 | Get-Item ENV:BH* 28 | "`n" 29 | } 30 | 31 | Task Test -Depends Init { 32 | $lines 33 | "`n`tSTATUS: Testing with PowerShell $PSVersion" 34 | 35 | # Gather test results. Store them in a variable and file 36 | $TestResults = Invoke-Pester -Path $ProjectRoot\Tests -PassThru -OutputFormat NUnitXml -OutputFile "$ProjectRoot\$TestFile" 37 | 38 | # In Appveyor? Upload our tests! #Abstract this into a function? 39 | If ($ENV:BHBuildSystem -eq 'AppVeyor') { 40 | (New-Object 'System.Net.WebClient').UploadFile( 41 | "https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", 42 | "$ProjectRoot\$TestFile" ) 43 | } 44 | 45 | Remove-Item "$ProjectRoot\$TestFile" -Force -ErrorAction SilentlyContinue 46 | 47 | # Failed tests? 48 | # Need to tell psake or it will proceed to the deployment. Danger! 49 | if ($TestResults.FailedCount -gt 0) { 50 | Write-Error "Failed '$($TestResults.FailedCount)' tests, build failed" 51 | } 52 | "`n" 53 | } 54 | 55 | Task Build -Depends Test { 56 | $lines 57 | 58 | If ($ENV:BHBuildSystem -eq 'AppVeyor') { 59 | # Load the module, read the exported functions, update the psd1 FunctionsToExport 60 | Set-ModuleFunctions 61 | } 62 | 63 | If ($ENV:BHBuildSystem -ne 'AppVeyor') { 64 | # Bump the module version 65 | Update-Metadata -Path $env:BHPSModuleManifest 66 | } 67 | } 68 | 69 | Task Deploy -Depends Build { 70 | $lines 71 | 72 | $Params = @{ 73 | Path = $ProjectRoot 74 | Force = $true 75 | Recurse = $false # We keep psdeploy artifacts, avoid deploying those : ) 76 | } 77 | Invoke-PSDeploy @Verbose @Params 78 | } 79 | -------------------------------------------------------------------------------- /docs/Get-PrtgTableData.md: -------------------------------------------------------------------------------- 1 | --- 2 | external help file: prtgshell-help.xml 3 | Module Name: prtgshell 4 | online version: 5 | schema: 2.0.0 6 | --- 7 | 8 | # Get-PrtgTableData 9 | 10 | ## SYNOPSIS 11 | {{Fill in the Synopsis}} 12 | 13 | ## SYNTAX 14 | 15 | ``` 16 | Get-PrtgTableData [-Content] [[-ObjectId] ] [-Column ] [-Count ] 17 | [-StartNumber ] [] 18 | ``` 19 | 20 | ## DESCRIPTION 21 | {{Fill in the Description}} 22 | 23 | ## EXAMPLES 24 | 25 | ### Example 1 26 | ```powershell 27 | PS C:\> {{ Add example code here }} 28 | ``` 29 | 30 | {{ Add example description here }} 31 | 32 | ## PARAMETERS 33 | 34 | ### -Column 35 | {{Fill Column Description}} 36 | 37 | ```yaml 38 | Type: String[] 39 | Parameter Sets: (All) 40 | Aliases: 41 | 42 | Required: False 43 | Position: Named 44 | Default value: None 45 | Accept pipeline input: False 46 | Accept wildcard characters: False 47 | ``` 48 | 49 | ### -Content 50 | {{Fill Content Description}} 51 | 52 | ```yaml 53 | Type: String 54 | Parameter Sets: (All) 55 | Aliases: 56 | Accepted values: probes, devices, groups, sensors, todos, messages, values, channels, history 57 | 58 | Required: True 59 | Position: 0 60 | Default value: None 61 | Accept pipeline input: False 62 | Accept wildcard characters: False 63 | ``` 64 | 65 | ### -Count 66 | {{Fill Count Description}} 67 | 68 | ```yaml 69 | Type: Int32 70 | Parameter Sets: (All) 71 | Aliases: 72 | 73 | Required: False 74 | Position: Named 75 | Default value: None 76 | Accept pipeline input: False 77 | Accept wildcard characters: False 78 | ``` 79 | 80 | ### -ObjectId 81 | {{Fill ObjectId Description}} 82 | 83 | ```yaml 84 | Type: Int32 85 | Parameter Sets: (All) 86 | Aliases: 87 | 88 | Required: False 89 | Position: 1 90 | Default value: None 91 | Accept pipeline input: False 92 | Accept wildcard characters: False 93 | ``` 94 | 95 | ### -StartNumber 96 | {{Fill StartNumber Description}} 97 | 98 | ```yaml 99 | Type: Int32 100 | Parameter Sets: (All) 101 | Aliases: 102 | 103 | Required: False 104 | Position: Named 105 | Default value: None 106 | Accept pipeline input: False 107 | Accept wildcard characters: False 108 | ``` 109 | 110 | ### CommonParameters 111 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 112 | 113 | ## INPUTS 114 | 115 | ### None 116 | ## OUTPUTS 117 | 118 | ### System.Object 119 | ## NOTES 120 | 121 | ## RELATED LINKS 122 | -------------------------------------------------------------------------------- /prtgshell/Classes/Helpers/HelperRegex.Class.ps1: -------------------------------------------------------------------------------- 1 | class HelperRegex { 2 | static [string]$Ipv4 = '\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b' 3 | static [string]$Ipv4Range = '\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)-((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b' 4 | static [string]$Fqdn = '(?=^.{1,254}$)(^(?:(?!\d|-)[a-zA-Z0-9\-]{1,63}(? [-UserName] [-PassHash] [[-Port] ] [-HttpOnly] 18 | [-SkipCertificateCheck] [-Quiet] [] 19 | ``` 20 | 21 | ### Credential 22 | ``` 23 | Get-PrtgServer [-Server] [-Credential] [[-Port] ] [-HttpOnly] 24 | [-SkipCertificateCheck] [-Quiet] [] 25 | ``` 26 | 27 | ## DESCRIPTION 28 | Performs initial connection to Prtg Server. Runs a getstatus query to get some info about the sever and test connectivity. Additionally, if Credential is provided, the user's PassHash is retrieved. 29 | 30 | ## EXAMPLES 31 | 32 | ### Example 1 33 | ```powershell 34 | PS C:\> Get-PrtgServer -Server 'prtg.example.com' -UserName JohnDoe -PassHash 1234567890 35 | Port : 443 36 | Protocol : https 37 | Hostname : prtg.example.com 38 | UserName : JohnDoe 39 | PassHash : 1234567890 40 | UrlHistory : {https://prtg.example.com:443/api/getstatus.xml?passhash=1234567890&username=JohnDoe} 41 | LastError : 42 | LastResult : #document 43 | NewAlarms : 0 44 | Alarms : 21 45 | AckAlarms : 7 46 | NewToDos : 0 47 | Clock : 12/14/2018 1:40:41 PM 48 | ClockasDateTime : 12/14/18 1:40:41 PM 49 | ActivationStatusMessage : (Tag activationstatusalert unknown) 50 | BackgroundTasks : 0 51 | CorrelationTasks : 0 52 | AutoDiscoTasks : 0 53 | Version : 18.2.41.1652+ 54 | PrtgUpdateAvailable : True 55 | IsAdminUser : True 56 | IsCluster : False 57 | ReadOnlyUser : False 58 | ReadOnlyAllowAcknowledge : False 59 | ``` 60 | 61 | Initiates connection to Prtg Server with the provided Username and PassHash. 62 | 63 | ### Example 2 64 | ```powershell 65 | PS C:\> Get-PrtgServer -Server 'prtg.example.com' -Credential (Get-Credential) -SkipCertificateCheck 66 | Port : 443 67 | Protocol : https 68 | Hostname : prtg.example.com 69 | UserName : JohnDoe 70 | PassHash : 1234567890 71 | UrlHistory : {https://prtg.example.com:443/api/getpasshash.htm?password=PASSWORDREDACTED&username=JohnDoe, 72 | https://prtg.example.com:443/api/getstatus.xml?passhash=1234567890&username=JohnDoe} 73 | LastError : 74 | LastResult : #document 75 | NewAlarms : 0 76 | Alarms : 21 77 | AckAlarms : 7 78 | NewToDos : 0 79 | Clock : 12/14/2018 1:40:41 PM 80 | ClockasDateTime : 12/14/18 1:40:41 PM 81 | ActivationStatusMessage : (Tag activationstatusalert unknown) 82 | BackgroundTasks : 0 83 | CorrelationTasks : 0 84 | AutoDiscoTasks : 0 85 | Version : 18.2.41.1652+ 86 | PrtgUpdateAvailable : True 87 | IsAdminUser : True 88 | IsCluster : False 89 | ReadOnlyUser : False 90 | ReadOnlyAllowAcknowledge : False 91 | ``` 92 | 93 | Initiates connection to Prtg Server with the provided Credential skipping validation of the provided SSL certificate. 94 | 95 | ### Example 3 96 | ```powershell 97 | PS C:\> Get-PrtgServer -Server 'prtg.example.com' -Credential (Get-Credential) -HttpOnly -Quiet -Port 8080 98 | ``` 99 | 100 | Initiates connection to Prtg Server with the provided Credential using plaintext HTTP on port 8080. No result is returned to the output stream due to the -Quiet switch. 101 | 102 | ## PARAMETERS 103 | 104 | ### -Credential 105 | PSCredential object with a valid username/password. 106 | 107 | ```yaml 108 | Type: PSCredential 109 | Parameter Sets: Credential 110 | Aliases: 111 | 112 | Required: True 113 | Position: 1 114 | Default value: None 115 | Accept pipeline input: False 116 | Accept wildcard characters: False 117 | ``` 118 | 119 | ### -HttpOnly 120 | Specifies to use plaintext HTTP instead of SSL. 121 | 122 | ```yaml 123 | Type: SwitchParameter 124 | Parameter Sets: (All) 125 | Aliases: http 126 | 127 | Required: False 128 | Position: Named 129 | Default value: None 130 | Accept pipeline input: False 131 | Accept wildcard characters: False 132 | ``` 133 | 134 | ### -PassHash 135 | Specified the PassHash of the provided Username. 136 | 137 | ```yaml 138 | Type: String 139 | Parameter Sets: PassHash 140 | Aliases: 141 | 142 | Required: True 143 | Position: 2 144 | Default value: None 145 | Accept pipeline input: False 146 | Accept wildcard characters: False 147 | ``` 148 | 149 | ### -Port 150 | Specifies a non-default port. 151 | 152 | ```yaml 153 | Type: Int32 154 | Parameter Sets: (All) 155 | Aliases: 156 | 157 | Required: False 158 | Position: 2 159 | Default value: None 160 | Accept pipeline input: False 161 | Accept wildcard characters: False 162 | ``` 163 | 164 | ### -Quiet 165 | Does not return any result to the output stream. 166 | 167 | ```yaml 168 | Type: SwitchParameter 169 | Parameter Sets: (All) 170 | Aliases: q 171 | 172 | Required: False 173 | Position: Named 174 | Default value: None 175 | Accept pipeline input: False 176 | Accept wildcard characters: False 177 | ``` 178 | 179 | ### -Server 180 | IP or Hostname of the Prtg server. 181 | 182 | ```yaml 183 | Type: String 184 | Parameter Sets: (All) 185 | Aliases: 186 | 187 | Required: True 188 | Position: 0 189 | Default value: None 190 | Accept pipeline input: False 191 | Accept wildcard characters: False 192 | ``` 193 | 194 | ### -SkipCertificateCheck 195 | Disabled validation of Prtg server's SSL certificate. 196 | 197 | ```yaml 198 | Type: SwitchParameter 199 | Parameter Sets: (All) 200 | Aliases: 201 | 202 | Required: False 203 | Position: Named 204 | Default value: None 205 | Accept pipeline input: False 206 | Accept wildcard characters: False 207 | ``` 208 | 209 | ### -UserName 210 | Specifies the desired Username to connect with. 211 | 212 | ```yaml 213 | Type: String 214 | Parameter Sets: PassHash 215 | Aliases: 216 | 217 | Required: True 218 | Position: 1 219 | Default value: None 220 | Accept pipeline input: False 221 | Accept wildcard characters: False 222 | ``` 223 | 224 | ### CommonParameters 225 | This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). 226 | 227 | ## INPUTS 228 | 229 | ### None 230 | ## OUTPUTS 231 | 232 | ### PrtgServer 233 | ## NOTES 234 | 235 | ## RELATED LINKS 236 | 237 | [https://github.com/LockstepGroup/prtgshell](https://github.com/LockstepGroup/prtgshell) 238 | 239 | [https://www.powershellgallery.com/packages/prtgshell](https://www.powershellgallery.com/packages/prtgshell) -------------------------------------------------------------------------------- /prtgshell/Public/Get-PrtgTableData.ps1: -------------------------------------------------------------------------------- 1 | function Get-PrtgTableData { 2 | [CmdletBinding()] 3 | 4 | Param ( 5 | [Parameter(Mandatory = $True, Position = 0)] 6 | [ValidateSet('probes', "devices", "groups", "sensors", "todos", "messages", "values", "channels", "history")] 7 | [string]$Content, 8 | 9 | [Parameter(Mandatory = $false, Position = 1)] 10 | [int]$ObjectId = 0, 11 | 12 | [Parameter(Mandatory = $False)] 13 | [string[]]$Column, 14 | 15 | <# [Parameter(Mandatory = $False)] 16 | [string[]]$FilterTag, #> 17 | 18 | [Parameter(Mandatory = $False)] 19 | [int]$Count = 500, 20 | 21 | [Parameter(Mandatory = $False)] 22 | [int]$StartNumber 23 | ) 24 | 25 | BEGIN { 26 | $VerbosePrefix = "Get-PrtgTableData:" 27 | if (!($global:PrtgServerObject.Connected)) { 28 | try { 29 | Throw 30 | } catch { 31 | $PSCmdlet.ThrowTerminatingError([HelperProcessError]::throwCustomError(1000, $global:PrtgServerObject.Hostname)) 32 | } 33 | } 34 | 35 | $QueryTable = @{} 36 | $Batching = $false 37 | 38 | $global:PrtgServerObject.ReturnCount = $Count 39 | $global:PrtgServerObject.CurrentStartPosition = $StartNumber 40 | 41 | <# if ($Content -eq "sensors" -and $FilterTags) { 42 | $FilterString = "" 43 | 44 | foreach ($tag in $FilterTags) { 45 | $FilterString += "&filter_tags=" + $tag 46 | } 47 | } #> 48 | 49 | $ValidColumns = @{} 50 | $ValidColumns.probes = @("objid", "type", "name", "tags", "active", "probe", "notifiesx", "intervalx", "access", "dependency", "probegroupdevice", "status", "message", "priority", "upsens", "downsens", "downacksens", "partialdownsens", "warnsens", "pausedsens", "unusualsens", "undefinedsens", "totalsens", "favorite", "schedule", "comments", "condition", "basetype", "baselink", "parentid", "fold", "groupnum", "devicenum") 51 | $ValidColumns.devices = @("objid", "probe", "group", "device", "host", "downsens", "partialdownsens", "downacksens", "upsens", "warnsens", "pausedsens", "unusualsens", "undefinedsens") 52 | $ValidColumns.groups = @("objid", "probe", "group", "name", "downsens", "partialdownsens", "downacksens", "upsens", "warnsens", "pausedsens", "unusualsens", "undefinedsens") 53 | $ValidColumns.sensors = @("parentid", "objid", "probe", "group", "device", "sensor", "status", "message", "lastvalue", "lastvalue_raw", "priority", "favorite") 54 | $ValidColumns.todos = @("objid", "datetime", "name", "status", "priority", "message") 55 | $ValidColumns.messages = @("objid", "datetime", "parent", "type", "name", "status", "message") 56 | $ValidColumns.values = @("datetime", "value_", "coverage") 57 | $ValidColumns.channels = @("name", "lastvalue", "lastvalue_raw") 58 | $ValidColumns.history = @("dateonly", "timeonly", "user", "message") 59 | 60 | $ValidColumnsForContent = $ValidColumns.$Content 61 | 62 | if ($Column) { 63 | foreach ($col in $Column) { 64 | if ($ValidColumnsForContent -notcontains $col) { 65 | try { 66 | throw 67 | } catch { 68 | $PSCmdlet.ThrowTerminatingError([HelperProcessError]::throwCustomError(1002, $col)) 69 | } 70 | } 71 | } 72 | $SelectedColumns = $Column 73 | } else { 74 | $SelectedColumns = $ValidColumnsForContent 75 | } 76 | 77 | $SelectedColumnsString = $SelectedColumns -join "," 78 | 79 | $HTMLColumns = @("downsens", "partialdownsens", "downacksens", "upsens", "warnsens", "pausedsens", "unusualsens", "undefinedsens", "message", "favorite") 80 | $QueryPage = 'table.xml' 81 | $ReturnData = @() 82 | } 83 | 84 | PROCESS { 85 | $QueryTable.content = $Content 86 | $QueryTable.columns = $SelectedColumnsString 87 | $QueryTable.id = $ObjectId 88 | 89 | if ($Batching) { 90 | 91 | } else { 92 | try { 93 | $Response = $global:PrtgServerObject.invokeApiQuery($QueryTable, $QueryPage, $Content) 94 | } catch { 95 | # originally I was catching specific types of exceptions, but apparently they're different between core and non-core, which is stupid 96 | switch -Regex ($_.Exception.Message) { 97 | '401\ \(Unauthorized\)' { 98 | $PSCmdlet.ThrowTerminatingError([HelperProcessError]::throwCustomError(1001, $Server)) 99 | } 100 | default { 101 | Throw $_ 102 | #$PSCmdlet.ThrowTerminatingError($PSItem) 103 | } 104 | } 105 | } 106 | 107 | foreach ($obj in $Response) { 108 | switch ($Content) { 109 | 'devices' { 110 | $ReturnData += [PrtgDevice]::new($obj) 111 | continue 112 | } 113 | 'groups' { 114 | $ReturnData += [PrtgGroup]::new($obj) 115 | continue 116 | } 117 | 'probes' { 118 | if ($obj.type -ne 'Probe') { 119 | continue 120 | } 121 | $ReturnData += [PrtgProbe]::new($obj) 122 | continue 123 | } 124 | default { 125 | $ReturnData = $Response 126 | } 127 | } 128 | } 129 | } 130 | 131 | $ReturnData 132 | 133 | 134 | <# $url = HelperURLBuilder "table.xml" ( 135 | "&content=$Content", 136 | "&columns=$SelectedColumnsString", 137 | "&id=$ObjectId", 138 | $FilterString, 139 | $CountString 140 | ) #> 141 | 142 | #$Global:LastUrl = $Url 143 | 144 | <# if ($Raw) { 145 | $QueryObject = HelperHTTPQuery $url 146 | return $QueryObject.Data 147 | } #> 148 | <# 149 | $QueryObject = HelperHTTPQuery $url -AsXML 150 | $Data = $QueryObject.Data 151 | 152 | $ReturnData = @() 153 | 154 | foreach ($item in $Data.$Content.item) { 155 | $ThisRow = "" | Select-Object $SelectedColumns 156 | foreach ($Prop in $SelectedColumns) { 157 | if ($Content -eq "channels" -and $Prop -eq "lastvalue_raw") { 158 | # fix a bizarre formatting bug 159 | $ThisRow.$Prop = HelperFormatHandler $item.$Prop 160 | } elseif ($HTMLColumns -contains $Prop) { 161 | # strip HTML, leave bare text 162 | $ThisRow.$Prop = $item.$Prop -replace "<[^>]*?>|<[^>]*>", "" 163 | } else { 164 | $ThisRow.$Prop = $item.$Prop 165 | } 166 | } 167 | $ReturnData += $ThisRow 168 | } 169 | 170 | if ($ReturnData.name -eq "Item" -or (!($ReturnData.ToString()))) { 171 | $DeterminedObjectType = Get-PrtgObjectType $ObjectId 172 | 173 | $ValidQueriesTable = @{ 174 | group = @("devices", "groups", "sensors", "todos", "messages", "values", "history") 175 | probenode = @("devices", "groups", "sensors", "todos", "messages", "values", "history") 176 | device = @("sensors", "todos", "messages", "values", "history") 177 | sensor = @("messages", "values", "channels", "history") 178 | report = @("Currently unsupported") 179 | map = @("Currently unsupported") 180 | storedreport = @("Currently unsupported") 181 | } 182 | 183 | Write-Host "No $Content; Object $ObjectId is type $DeterminedObjectType" 184 | Write-Host (" Valid query types: " + ($ValidQueriesTable.$DeterminedObjectType -join ", ")) 185 | } else { 186 | return $ReturnData 187 | } #> 188 | } 189 | } -------------------------------------------------------------------------------- /prtgshell/Classes/Main/PrtgServer.Class.ps1: -------------------------------------------------------------------------------- 1 | class PrtgServer { 2 | [string]$Hostname 3 | 4 | [ValidateRange(1, 65535)] 5 | [int]$Port = 443 6 | 7 | [ValidateSet('http', 'https')] 8 | [string]$Protocol = "https" 9 | 10 | [string]$UserName 11 | [string]$PassHash 12 | 13 | # Track usage 14 | [int]$ReturnCount = 500 15 | [int]$CurrentStartPosition = 0 16 | hidden [bool]$Connected 17 | [array]$UrlHistory 18 | [array]$RawQueryResultHistory 19 | [array]$QueryHistory 20 | $LastError 21 | $LastResult 22 | 23 | # Status Properties 24 | [int]$NewAlarms 25 | [int]$Alarms 26 | [int]$AckAlarms 27 | [int]$NewToDos 28 | [string]$Clock 29 | [datetime]$ClockasDateTime 30 | [string]$ActivationStatusMessage 31 | [int]$BackgroundTasks 32 | [int]$CorrelationTasks 33 | [int]$AutoDiscoTasks 34 | [string]$Version 35 | [bool]$PRTGUpdateAvailable 36 | [bool]$IsAdminUser 37 | [bool]$IsCluster 38 | [bool]$ReadOnlyUser 39 | [bool]$ReadOnlyAllowAcknowledge 40 | 41 | # Generate Api URL 42 | [String] getApiUrl([hashtable]$queryHashtable, [string]$queryPage) { 43 | $formattedQueryString = [HelperWeb]::createQueryString($queryHashtable) 44 | if ($this.Hostname) { 45 | $url = $this.Protocol + "://" + $this.Hostname + ':' + $this.Port + "/api/" + $queryPage + $formattedQueryString 46 | return $url 47 | } else { 48 | return $null 49 | } 50 | } 51 | 52 | 53 | # Test Connection 54 | [bool] testConnection() { 55 | $result = $this.invokeApiQuery(@{}, 'getstatus.xml') 56 | $this.Connected = $true 57 | $this.NewAlarms = $result.status.NewAlarms 58 | $this.Alarms = $result.status.Alarms 59 | $this.AckAlarms = $result.status.AckAlarms 60 | $this.NewToDos = $result.status.NewToDos 61 | $this.Clock = $result.status.Clock 62 | $this.ClockasDateTime = $result.status.Clock 63 | $this.ActivationStatusMessage = $result.status.ActivationStatusMessage 64 | $this.BackgroundTasks = $result.status.BackgroundTasks 65 | $this.CorrelationTasks = $result.status.CorrelationTasks 66 | $this.AutoDiscoTasks = $result.status.AutoDiscoTasks 67 | $this.Version = $result.status.Version 68 | $this.PRTGUpdateAvailable = $result.status.PRTGUpdateAvailable 69 | $this.IsAdminUser = $result.status.IsAdminUser 70 | $this.IsCluster = $result.status.IsCluster 71 | $this.ReadOnlyUser = $result.status.ReadOnlyUser 72 | $this.ReadOnlyAllowAcknowledge = $result.status.ReadOnlyAllowAcknowledge 73 | return $true 74 | } 75 | 76 | #region ApiQueryFunctions 77 | ################################################################################################### 78 | #region GetPassHashQuery 79 | # example: https://prtg.example.com/api/getpasshash.htm?username=JohnDoe&password=TopSecret 80 | [xml] invokeGetPassHashQuery([PSCredential]$credential) { 81 | $queryString = @{} 82 | $queryPage = "getpasshash.htm" 83 | $queryString.username = $credential.UserName 84 | $queryString.password = $Credential.getnetworkcredential().password 85 | $result = $this.invokeApiQuery($queryString, $queryPage) 86 | $this.UserName = $credential.UserName 87 | $this.PassHash = $result.objects.object.'#text' 88 | return $result 89 | } 90 | #endregion GetPassHashQuery 91 | 92 | #region invokeApiQueryBatches 93 | [array] invokeApiQuery([hashtable]$queryHashtable, [string]$queryPage, [string]$itemNode = $null) { 94 | Write-Verbose "Calling invokeapiquery with itemNode: $itemNode" 95 | Write-Verbose "ReturnCount: $($this.ReturnCount)" 96 | Write-Verbose "CurrentStartPosition: $($this.CurrentStartPosition)" 97 | $ContinueLoop = $true 98 | $allResults = @() 99 | $checkResults = @{} 100 | $queryHashtable.returncount = $this.ReturnCount 101 | $result = $this.invokeApiQuery($queryHashtable, $queryPage) 102 | $result = $result.$itemNode.item 103 | $allResults += $result 104 | foreach ($r in $result) { 105 | $thisId = $r.objid 106 | $checkResults.$thisId = $r 107 | } 108 | do { 109 | $this.CurrentStartPosition = $this.CurrentStartPosition + $this.ReturnCount 110 | $queryHashtable.start = $this.CurrentStartPosition 111 | Write-Verbose "CurrentStartPosition: $($this.CurrentStartPosition)" 112 | Write-Verbose "allResults Count: $($allResults.Count)" 113 | $result = $this.invokeApiQuery($queryHashtable, $queryPage) 114 | $result = $result.$itemNode.item 115 | foreach ($r in $result) { 116 | $thisId = $r.objid 117 | if ($checkResults.$thisId) { 118 | $ContinueLoop = $false 119 | } else { 120 | $checkResults.$thisId = $r 121 | $allResults += $r 122 | } 123 | } 124 | } while ($ContinueLoop) 125 | $this.CurrentStartPosition = 0 126 | $this.LastResult = $allResults 127 | return $allResults 128 | } 129 | #endregion invokeApiQueryBatches 130 | 131 | #region invokeApiQuery 132 | [xml] invokeApiQuery([hashtable]$queryHashtable, [string]$queryPage) { 133 | # If the query is not a GetPassHash query we need to append the PassHash and UserName to the query string 134 | if ($queryPage -ne "getpasshash.htm") { 135 | $queryHashtable.username = $this.UserName 136 | $queryHashtable.passhash = $this.PassHash 137 | } 138 | 139 | $url = $this.getApiUrl($queryHashtable, $queryPage) 140 | 141 | #region trackHistory 142 | # Populate Query/Url History 143 | # Redact password if it's a keygen query 144 | if ($queryPage -ne "getpasshash.htm") { 145 | $this.UrlHistory += $url 146 | } else { 147 | $EncodedPassword = [System.Uri]::EscapeDataString($queryHashtable.password) 148 | $queryHashtable.password = 'PASSWORDREDACTED' 149 | $this.UrlHistory += $url.Replace($EncodedPassword, "PASSWORDREDACTED") 150 | } 151 | 152 | # add query object to QueryHistory 153 | $this.QueryHistory += $queryHashtable 154 | #endregion trackHistory 155 | 156 | 157 | 158 | # try query 159 | try { 160 | $QueryParams = @{} 161 | $QueryParams.Uri = $url 162 | $QueryParams.UseBasicParsing = $true 163 | 164 | switch ($global:PSVersionTable.PSEdition) { 165 | 'Core' { 166 | $QueryParams.SkipCertificateCheck = $true 167 | continue 168 | } 169 | default { 170 | [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 171 | try { 172 | add-type @" 173 | using System.Net; 174 | using System.Security.Cryptography.X509Certificates; 175 | public class TrustAllCertsPolicy : ICertificatePolicy { 176 | public bool CheckValidationResult( 177 | ServicePoint srvPoint, X509Certificate certificate, 178 | WebRequest request, int certificateProblem) { 179 | return true; 180 | } 181 | } 182 | "@ 183 | } catch { 184 | 185 | } 186 | [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy 187 | continue 188 | } 189 | } 190 | 191 | $rawResult = Invoke-WebRequest @QueryParams -Verbose:$false # doing this mostly to prevent plaintext password from being displayed by accident. 192 | } catch { 193 | Throw $_ 194 | } 195 | 196 | $this.RawQueryResultHistory += $rawResult 197 | 198 | if ($queryPage -eq "getpasshash.htm") { 199 | $result = @{'passhash' = $rawResult.Content} 200 | $result = [xml]($result.passhash | ConvertTo-Xml) 201 | } else { 202 | $result = [xml]($rawResult.Content) 203 | } 204 | 205 | $this.LastResult = $result 206 | 207 | return $result 208 | 209 | <# 210 | 211 | $result = [xml]($rawResult.Content) 212 | 213 | 214 | $proccessedResult = $this.processQueryResult($result) 215 | 216 | return $proccessedResult #> 217 | } 218 | #endregion invokeApiQuery 219 | ################################################################################################### 220 | #endregion ApiQueryFunctions 221 | 222 | #region Initiators 223 | ################################################################################################### 224 | # Blank Initiator 225 | PrtgServer() { 226 | } 227 | 228 | # Initiator with PassHash 229 | PrtgServer([string]$Hostname, [string]$UserName, [string]$PassHash, [string]$Protocol = "https", [int]$Port = 443) { 230 | $this.Hostname = $Hostname 231 | $this.UserName = $UserName 232 | $this.PassHash = $PassHash 233 | $this.Protocol = $Protocol 234 | $this.Port = $Port 235 | } 236 | 237 | # Initiator with Credential 238 | PrtgServer([string]$Hostname, [PSCredential]$Credential, [string]$Protocol = "https", [int]$Port = 443) { 239 | $this.Hostname = $Hostname 240 | $this.Protocol = $Protocol 241 | $this.Port = $Port 242 | $this.invokeGetPassHashQuery($Credential) 243 | } 244 | #endregion Initiators 245 | } -------------------------------------------------------------------------------- /Tests/Get-PrtgServer.Tests.ps1: -------------------------------------------------------------------------------- 1 | if (-not $ENV:BHProjectPath) { 2 | Set-BuildEnvironment -Path $PSScriptRoot\.. 3 | } 4 | Remove-Module $ENV:BHProjectName -ErrorAction SilentlyContinue 5 | Import-Module (Join-Path $ENV:BHProjectPath $ENV:BHProjectName) -Force 6 | 7 | 8 | InModuleScope $ENV:BHProjectName { 9 | $PSVersion = $PSVersionTable.PSVersion.Major 10 | $ProjectRoot = $ENV:BHProjectPath 11 | 12 | $Verbose = @{} 13 | if ($ENV:BHBranchName -notlike "master" -or $env:BHCommitMessage -match "!verbose") { 14 | $Verbose.add("Verbose", $True) 15 | } 16 | 17 | Describe "Get-PrtgServer" { 18 | $PrtgServer = '1.1.1.1' 19 | $PrtgUsername = 'JohnDoe' 20 | $PrtgPassHash = '1234567890' 21 | $PrtgStatus = @' 22 | 23 | 24 | 0 25 | 0 26 | 21 27 | 7 28 | 29 | 12/12/2018 4:33:04 PM 30 | (Tag activationstatusalert unknown) 31 | 0 32 | 0 33 | 0 34 | 18.2.41.1652+ 35 | yes 36 | true 37 | 38 | 39 | 40 | 41 | 42 | '@ 43 | # make a cred to use for tests 44 | $StoredCred = '{"AesKey":[162,160,87,5,70,136,113,133,145,96,37,116,29,27,8,136,13,71,189,50,118,137,87,63,43,56,182,68,48,45,164,185],"Password":"76492d1116743f0423413b16050a5345MgB8AGYAMABiAHcAUgBtADgASgBYAHEASABOAEgAVQBQAHUAdgArAFYAcgBLAEEAPQA9AHwANQBiADAANABiADgAMgA5AGQANQAxAGEAZQBhAGYANgBlAGIAMwA2AGUAOAAyADkAMQBlADIAOAA0ADEAZABmADIANQBkAGIAMAA0ADQAMwBkAGYAZQBjADAAYgBmADgANgA0AGMAOQA5ADAAOQBhAGUAYQA2ADMAMgA2ADQAOAA="}' 45 | $StoredCred = $StoredCred | ConvertFrom-Json 46 | $PrtgPassword = ConvertTo-SecureString $StoredCred.Password -Key $StoredCred.AesKey 47 | $PrtgCred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $PrtgUsername, $PrtgPassword 48 | 49 | $PrtgStatusResult = @{'Content' = $PrtgStatus} 50 | 51 | Context "PassHash Provided" { 52 | Mock Invoke-WebRequest { return $PrtgStatusResult } -ParameterFilter { $Uri -match 'getstatus.xml' } 53 | Get-PrtgServer -Server $PrtgServer -UserName $PrtgUsername -PassHash $PrtgPassHash -Quiet 54 | It "PrtgServerObject should have correct Version" { 55 | $PrtgServerObject.Version | Should -Be '18.2.41.1652+' 56 | } 57 | It "PrtgServerObject should have correct Port" { 58 | $PrtgServerObject.Port | Should -BeExactly 443 59 | } 60 | It "PrtgServerObject should have correct Protocol" { 61 | $PrtgServerObject.Protocol | Should -Be 'https' 62 | } 63 | It "PrtgServerObject should have correct Hostname" { 64 | $PrtgServerObject.Hostname | Should -Be '1.1.1.1' 65 | } 66 | It "PrtgServerObject should have correct UserName" { 67 | $PrtgServerObject.UserName | Should -Be 'JohnDoe' 68 | } 69 | It "PrtgServerObject should have correct PassHash" { 70 | $PrtgServerObject.PassHash | Should -Be '1234567890' 71 | } 72 | It "PrtgServerObject should have correct UrlHistory" { 73 | $PrtgServerObject.UrlHistory[0] | Should -Be 'https://1.1.1.1:443/api/getstatus.xml?passhash=1234567890&username=JohnDoe' 74 | } 75 | It "PrtgServerObject should have correct RawQueryResultHistory" { 76 | $PrtgServerObject.RawQueryResultHistory.Count | Should -Be 1 77 | } 78 | It "PrtgServerObject should have correct QueryHistory" { 79 | $PrtgServerObject.QueryHistory.Count | Should -Be 1 80 | } 81 | It "PrtgServerObject should have correct LastError" { 82 | $PrtgServerObject.LastError | Should -BeNullOrEmpty 83 | } 84 | It "PrtgServerObject should have correct LastResult" { 85 | $PrtgServerObject.LastResult | Should -Not -Be $null 86 | } 87 | It "PrtgServerObject should have correct NewAlarms" { 88 | $PrtgServerObject.NewAlarms | Should -Be 0 89 | } 90 | It "PrtgServerObject should have correct Alarms" { 91 | $PrtgServerObject.Alarms | Should -Be 21 92 | } 93 | It "PrtgServerObject should have correct AckAlarms" { 94 | $PrtgServerObject.AckAlarms | Should -Be 7 95 | } 96 | It "PrtgServerObject should have correct NewToDos" { 97 | $PrtgServerObject.NewToDos | Should -Be 0 98 | } 99 | It "PrtgServerObject should have correct Clock" { 100 | $PrtgServerObject.Clock | Should -Be '12/12/2018 4:33:04 PM' 101 | } 102 | It "PrtgServerObject should have correct ClockasDateTime" { 103 | $PrtgServerObject.ClockasDateTime | Should -Be (Get-Date '2018-12-12T16:33:04.0000000') 104 | } 105 | It "PrtgServerObject should have correct ActivationStatusMessage" { 106 | $PrtgServerObject.ActivationStatusMessage | Should -Be '(Tag activationstatusalert unknown)' 107 | } 108 | It "PrtgServerObject should have correct BackgroundTasks" { 109 | $PrtgServerObject.BackgroundTasks | Should -Be 0 110 | } 111 | It "PrtgServerObject should have correct CorrelationTasks" { 112 | $PrtgServerObject.CorrelationTasks | Should -Be 0 113 | } 114 | It "PrtgServerObject should have correct AutoDiscoTasks" { 115 | $PrtgServerObject.AutoDiscoTasks | Should -Be 0 116 | } 117 | It "PrtgServerObject should have correct PRTGUpdateAvailable" { 118 | $PrtgServerObject.PRTGUpdateAvailable | Should -BeTrue 119 | } 120 | It "PrtgServerObject should have correct IsAdminUser" { 121 | $PrtgServerObject.IsAdminUser | Should -BeTrue 122 | } 123 | It "PrtgServerObject should have correct IsCluster" { 124 | $PrtgServerObject.IsCluster | Should -BeFalse 125 | } 126 | It "PrtgServerObject should have correct ReadOnlyUser" { 127 | $PrtgServerObject.ReadOnlyUser | Should -BeFalse 128 | } 129 | It "PrtgServerObject should have correct ReadOnlyAllowAcknowledge" { 130 | $PrtgServerObject.ReadOnlyAllowAcknowledge | Should -BeFalse 131 | } 132 | } 133 | 134 | $PrtgPassHashResult = @{'Content' = $PrtgPassHash} 135 | 136 | Context "Credential Provided" { 137 | Mock Invoke-WebRequest { return $PrtgPassHashResult } -ParameterFilter { $Uri -match 'getpasshash.htm' } 138 | Mock Invoke-WebRequest { return $PrtgStatusResult } -ParameterFilter { $Uri -match 'getstatus.xml' } 139 | 140 | Get-PrtgServer -Server $PrtgServer -Credential $PrtgCred -Quiet 141 | It "PrtgServerObject should have correct Version" { 142 | $PrtgServerObject.Version | Should -Be '18.2.41.1652+' 143 | } 144 | It "PrtgServerObject should have correct Port" { 145 | $PrtgServerObject.Port | Should -BeExactly 443 146 | } 147 | It "PrtgServerObject should have correct Protocol" { 148 | $PrtgServerObject.Protocol | Should -Be 'https' 149 | } 150 | It "PrtgServerObject should have correct Hostname" { 151 | $PrtgServerObject.Hostname | Should -Be '1.1.1.1' 152 | } 153 | It "PrtgServerObject should have correct UserName" { 154 | $PrtgServerObject.UserName | Should -Be 'JohnDoe' 155 | } 156 | It "PrtgServerObject should have correct PassHash" { 157 | $PrtgServerObject.PassHash | Should -Be '1234567890' 158 | } 159 | It "PrtgServerObject should have correct UrlHistory" { 160 | $PrtgServerObject.UrlHistory[0] | Should -Be 'https://1.1.1.1:443/api/getpasshash.htm?password=PASSWORDREDACTED&username=JohnDoe' 161 | } 162 | It "PrtgServerObject should have correct RawQueryResultHistory" { 163 | $PrtgServerObject.RawQueryResultHistory.Count | Should -Be 2 164 | } 165 | It "PrtgServerObject should have correct QueryHistory" { 166 | $PrtgServerObject.QueryHistory.Count | Should -Be 2 167 | } 168 | It "PrtgServerObject should have correct LastError" { 169 | $PrtgServerObject.LastError | Should -BeNullOrEmpty 170 | } 171 | It "PrtgServerObject should have correct LastResult" { 172 | $PrtgServerObject.LastResult | Should -Not -Be $null 173 | } 174 | It "PrtgServerObject should have correct NewAlarms" { 175 | $PrtgServerObject.NewAlarms | Should -Be 0 176 | } 177 | It "PrtgServerObject should have correct Alarms" { 178 | $PrtgServerObject.Alarms | Should -Be 21 179 | } 180 | It "PrtgServerObject should have correct AckAlarms" { 181 | $PrtgServerObject.AckAlarms | Should -Be 7 182 | } 183 | It "PrtgServerObject should have correct NewToDos" { 184 | $PrtgServerObject.NewToDos | Should -Be 0 185 | } 186 | It "PrtgServerObject should have correct Clock" { 187 | $PrtgServerObject.Clock | Should -Be '12/12/2018 4:33:04 PM' 188 | } 189 | It "PrtgServerObject should have correct ClockasDateTime" { 190 | $PrtgServerObject.ClockasDateTime | Should -Be (Get-Date '2018-12-12T16:33:04.0000000') 191 | } 192 | It "PrtgServerObject should have correct ActivationStatusMessage" { 193 | $PrtgServerObject.ActivationStatusMessage | Should -Be '(Tag activationstatusalert unknown)' 194 | } 195 | It "PrtgServerObject should have correct BackgroundTasks" { 196 | $PrtgServerObject.BackgroundTasks | Should -Be 0 197 | } 198 | It "PrtgServerObject should have correct CorrelationTasks" { 199 | $PrtgServerObject.CorrelationTasks | Should -Be 0 200 | } 201 | It "PrtgServerObject should have correct AutoDiscoTasks" { 202 | $PrtgServerObject.AutoDiscoTasks | Should -Be 0 203 | } 204 | It "PrtgServerObject should have correct PRTGUpdateAvailable" { 205 | $PrtgServerObject.PRTGUpdateAvailable | Should -BeTrue 206 | } 207 | It "PrtgServerObject should have correct IsAdminUser" { 208 | $PrtgServerObject.IsAdminUser | Should -BeTrue 209 | } 210 | It "PrtgServerObject should have correct IsCluster" { 211 | $PrtgServerObject.IsCluster | Should -BeFalse 212 | } 213 | It "PrtgServerObject should have correct ReadOnlyUser" { 214 | $PrtgServerObject.ReadOnlyUser | Should -BeFalse 215 | } 216 | It "PrtgServerObject should have correct ReadOnlyAllowAcknowledge" { 217 | $PrtgServerObject.ReadOnlyAllowAcknowledge | Should -BeFalse 218 | } 219 | } 220 | 221 | Context "Test Custom Port/Protocol" { 222 | Mock Invoke-WebRequest { return $PrtgStatusResult } -ParameterFilter { $Uri -match 'getstatus.xml' } 223 | Get-PrtgServer -Server $PrtgServer -UserName $PrtgUsername -PassHash $PrtgPassHash -Quiet -HttpOnly -Port 444 224 | It "PrtgServerObject should have correct Port" { 225 | $PrtgServerObject.Port | Should -BeExactly 444 226 | } 227 | It "PrtgServerObject should have correct Protocol" { 228 | $PrtgServerObject.Protocol | Should -Be 'http' 229 | } 230 | } 231 | Context "Bad Credentials" { 232 | # Would like to check for correct error id (1000,Get-PrtgServer), but not sure how to that with Mock 233 | Mock Invoke-WebRequest { Throw '401 (Unauthorized)' } -ParameterFilter { $Uri -match 'getstatus.xml' } 234 | It "Should throw error with bad PassHash" { 235 | { Get-PrtgServer -Server $PrtgServer -UserName $PrtgUsername -PassHash $PrtgPassHash -Quiet } | Should -Throw -ErrorId '1001,Get-PrtgServer' 236 | } 237 | Mock Invoke-WebRequest { Throw '401 (Unauthorized)' } -ParameterFilter { $Uri -match 'getpasshash.htm' } 238 | It "Should throw error with bad Credential" { 239 | { Get-PrtgServer -Server $PrtgServer -Credential $PrtgCred -Quiet } | Should -Throw -ErrorId '1001,Get-PrtgServer' 240 | } 241 | } 242 | } 243 | } -------------------------------------------------------------------------------- /prtgshell/en-US/prtgshell-help.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Get-PrtgCredentialUsage 6 | Get 7 | PrtgCredentialUsage 8 | 9 | {{Fill in the Synopsis}} 10 | 11 | 12 | 13 | {{Fill in the Description}} 14 | 15 | 16 | 17 | Get-PrtgCredentialUsage 18 | 19 | ObjectId 20 | 21 | {{Fill ObjectId Description}} 22 | 23 | Int32[] 24 | 25 | Int32[] 26 | 27 | 28 | None 29 | 30 | 31 | 32 | 33 | 34 | ObjectId 35 | 36 | {{Fill ObjectId Description}} 37 | 38 | Int32[] 39 | 40 | Int32[] 41 | 42 | 43 | None 44 | 45 | 46 | 47 | 48 | 49 | System.Int32[] 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | System.Object 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | -------------------------- Example 1 -------------------------- 74 | PS C:\> {{ Add example code here }} 75 | 76 | {{ Add example description here }} 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | Get-PrtgObject 85 | Get 86 | PrtgObject 87 | 88 | {{Fill in the Synopsis}} 89 | 90 | 91 | 92 | {{Fill in the Description}} 93 | 94 | 95 | 96 | Get-PrtgObject 97 | 98 | ObjectId 99 | 100 | {{Fill ObjectId Description}} 101 | 102 | Int32[] 103 | 104 | Int32[] 105 | 106 | 107 | None 108 | 109 | 110 | 111 | 112 | 113 | ObjectId 114 | 115 | {{Fill ObjectId Description}} 116 | 117 | Int32[] 118 | 119 | Int32[] 120 | 121 | 122 | None 123 | 124 | 125 | 126 | 127 | 128 | System.Int32[] 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | System.Object 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | -------------------------- Example 1 -------------------------- 153 | PS C:\> {{ Add example code here }} 154 | 155 | {{ Add example description here }} 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | Get-PrtgObjectParentId 164 | Get 165 | PrtgObjectParentId 166 | 167 | {{Fill in the Synopsis}} 168 | 169 | 170 | 171 | {{Fill in the Description}} 172 | 173 | 174 | 175 | Get-PrtgObjectParentId 176 | 177 | ObjectId 178 | 179 | {{Fill ObjectId Description}} 180 | 181 | Int32[] 182 | 183 | Int32[] 184 | 185 | 186 | None 187 | 188 | 189 | 190 | 191 | 192 | ObjectId 193 | 194 | {{Fill ObjectId Description}} 195 | 196 | Int32[] 197 | 198 | Int32[] 199 | 200 | 201 | None 202 | 203 | 204 | 205 | 206 | 207 | System.Int32[] 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | System.Object 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | -------------------------- Example 1 -------------------------- 232 | PS C:\> {{ Add example code here }} 233 | 234 | {{ Add example description here }} 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | Get-PrtgObjectProperty 243 | Get 244 | PrtgObjectProperty 245 | 246 | {{Fill in the Synopsis}} 247 | 248 | 249 | 250 | {{Fill in the Description}} 251 | 252 | 253 | 254 | Get-PrtgObjectProperty 255 | 256 | ObjectId 257 | 258 | {{Fill ObjectId Description}} 259 | 260 | Int32[] 261 | 262 | Int32[] 263 | 264 | 265 | None 266 | 267 | 268 | Property 269 | 270 | {{Fill Property Description}} 271 | 272 | String 273 | 274 | String 275 | 276 | 277 | None 278 | 279 | 280 | 281 | 282 | 283 | ObjectId 284 | 285 | {{Fill ObjectId Description}} 286 | 287 | Int32[] 288 | 289 | Int32[] 290 | 291 | 292 | None 293 | 294 | 295 | Property 296 | 297 | {{Fill Property Description}} 298 | 299 | String 300 | 301 | String 302 | 303 | 304 | None 305 | 306 | 307 | 308 | 309 | 310 | System.Int32[] 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | System.Object 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | -------------------------- Example 1 -------------------------- 335 | PS C:\> {{ Add example code here }} 336 | 337 | {{ Add example description here }} 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | Get-PrtgSensorHistoricData 346 | Get 347 | PrtgSensorHistoricData 348 | 349 | {{Fill in the Synopsis}} 350 | 351 | 352 | 353 | {{Fill in the Description}} 354 | 355 | 356 | 357 | Get-PrtgSensorHistoricData 358 | 359 | SensorId 360 | 361 | {{Fill SensorId Description}} 362 | 363 | Int32 364 | 365 | Int32 366 | 367 | 368 | None 369 | 370 | 371 | RangeStart 372 | 373 | {{Fill RangeStart Description}} 374 | 375 | DateTime 376 | 377 | DateTime 378 | 379 | 380 | None 381 | 382 | 383 | RangeEnd 384 | 385 | {{Fill RangeEnd Description}} 386 | 387 | DateTime 388 | 389 | DateTime 390 | 391 | 392 | None 393 | 394 | 395 | IntervalInSeconds 396 | 397 | {{Fill IntervalInSeconds Description}} 398 | 399 | Int32 400 | 401 | Int32 402 | 403 | 404 | None 405 | 406 | 407 | 408 | 409 | 410 | IntervalInSeconds 411 | 412 | {{Fill IntervalInSeconds Description}} 413 | 414 | Int32 415 | 416 | Int32 417 | 418 | 419 | None 420 | 421 | 422 | RangeEnd 423 | 424 | {{Fill RangeEnd Description}} 425 | 426 | DateTime 427 | 428 | DateTime 429 | 430 | 431 | None 432 | 433 | 434 | RangeStart 435 | 436 | {{Fill RangeStart Description}} 437 | 438 | DateTime 439 | 440 | DateTime 441 | 442 | 443 | None 444 | 445 | 446 | SensorId 447 | 448 | {{Fill SensorId Description}} 449 | 450 | Int32 451 | 452 | Int32 453 | 454 | 455 | None 456 | 457 | 458 | 459 | 460 | 461 | None 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | System.Object 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | -------------------------- Example 1 -------------------------- 486 | PS C:\> {{ Add example code here }} 487 | 488 | {{ Add example description here }} 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | Get-PrtgServer 497 | Get 498 | PrtgServer 499 | 500 | Performs initial connection to Prtg Server. 501 | 502 | 503 | 504 | Performs initial connection to Prtg Server. Runs a getstatus query to get some info about the sever and test connectivity. Additionally, if Credential is provided, the user's PassHash is retrieved. 505 | 506 | 507 | 508 | Get-PrtgServer 509 | 510 | Server 511 | 512 | IP or Hostname of the Prtg server. 513 | 514 | String 515 | 516 | String 517 | 518 | 519 | None 520 | 521 | 522 | Credential 523 | 524 | PSCredential object with a valid username/password. 525 | 526 | PSCredential 527 | 528 | PSCredential 529 | 530 | 531 | None 532 | 533 | 534 | Port 535 | 536 | Specifies a non-default port. 537 | 538 | Int32 539 | 540 | Int32 541 | 542 | 543 | None 544 | 545 | 546 | HttpOnly 547 | 548 | Specifies to use plaintext HTTP instead of SSL. 549 | 550 | 551 | SwitchParameter 552 | 553 | 554 | False 555 | 556 | 557 | Quiet 558 | 559 | Does not return any result to the output stream. 560 | 561 | 562 | SwitchParameter 563 | 564 | 565 | False 566 | 567 | 568 | SkipCertificateCheck 569 | 570 | Disabled validation of Prtg server's SSL certificate. 571 | 572 | 573 | SwitchParameter 574 | 575 | 576 | False 577 | 578 | 579 | 580 | Get-PrtgServer 581 | 582 | Server 583 | 584 | IP or Hostname of the Prtg server. 585 | 586 | String 587 | 588 | String 589 | 590 | 591 | None 592 | 593 | 594 | UserName 595 | 596 | Specifies the desired Username to connect with. 597 | 598 | String 599 | 600 | String 601 | 602 | 603 | None 604 | 605 | 606 | PassHash 607 | 608 | Specified the PassHash of the provided Username. 609 | 610 | String 611 | 612 | String 613 | 614 | 615 | None 616 | 617 | 618 | Port 619 | 620 | Specifies a non-default port. 621 | 622 | Int32 623 | 624 | Int32 625 | 626 | 627 | None 628 | 629 | 630 | HttpOnly 631 | 632 | Specifies to use plaintext HTTP instead of SSL. 633 | 634 | 635 | SwitchParameter 636 | 637 | 638 | False 639 | 640 | 641 | Quiet 642 | 643 | Does not return any result to the output stream. 644 | 645 | 646 | SwitchParameter 647 | 648 | 649 | False 650 | 651 | 652 | SkipCertificateCheck 653 | 654 | Disabled validation of Prtg server's SSL certificate. 655 | 656 | 657 | SwitchParameter 658 | 659 | 660 | False 661 | 662 | 663 | 664 | 665 | 666 | Credential 667 | 668 | PSCredential object with a valid username/password. 669 | 670 | PSCredential 671 | 672 | PSCredential 673 | 674 | 675 | None 676 | 677 | 678 | HttpOnly 679 | 680 | Specifies to use plaintext HTTP instead of SSL. 681 | 682 | SwitchParameter 683 | 684 | SwitchParameter 685 | 686 | 687 | False 688 | 689 | 690 | PassHash 691 | 692 | Specified the PassHash of the provided Username. 693 | 694 | String 695 | 696 | String 697 | 698 | 699 | None 700 | 701 | 702 | Port 703 | 704 | Specifies a non-default port. 705 | 706 | Int32 707 | 708 | Int32 709 | 710 | 711 | None 712 | 713 | 714 | Quiet 715 | 716 | Does not return any result to the output stream. 717 | 718 | SwitchParameter 719 | 720 | SwitchParameter 721 | 722 | 723 | False 724 | 725 | 726 | Server 727 | 728 | IP or Hostname of the Prtg server. 729 | 730 | String 731 | 732 | String 733 | 734 | 735 | None 736 | 737 | 738 | SkipCertificateCheck 739 | 740 | Disabled validation of Prtg server's SSL certificate. 741 | 742 | SwitchParameter 743 | 744 | SwitchParameter 745 | 746 | 747 | False 748 | 749 | 750 | UserName 751 | 752 | Specifies the desired Username to connect with. 753 | 754 | String 755 | 756 | String 757 | 758 | 759 | None 760 | 761 | 762 | 763 | 764 | 765 | None 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | PrtgServer 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 789 | -------------------------- Example 1 -------------------------- 790 | PS C:\> Get-PrtgServer -Server 'prtg.example.com' -UserName JohnDoe -PassHash 1234567890 791 | Port : 443 792 | Protocol : https 793 | Hostname : prtg.example.com 794 | UserName : JohnDoe 795 | PassHash : 1234567890 796 | UrlHistory : {https://prtg.example.com:443/api/getstatus.xml?passhash=1234567890&username=JohnDoe} 797 | LastError : 798 | LastResult : #document 799 | NewAlarms : 0 800 | Alarms : 21 801 | AckAlarms : 7 802 | NewToDos : 0 803 | Clock : 12/14/2018 1:40:41 PM 804 | ClockasDateTime : 12/14/18 1:40:41 PM 805 | ActivationStatusMessage : (Tag activationstatusalert unknown) 806 | BackgroundTasks : 0 807 | CorrelationTasks : 0 808 | AutoDiscoTasks : 0 809 | Version : 18.2.41.1652+ 810 | PrtgUpdateAvailable : True 811 | IsAdminUser : True 812 | IsCluster : False 813 | ReadOnlyUser : False 814 | ReadOnlyAllowAcknowledge : False 815 | 816 | Initiates connection to Prtg Server with the provided Username and PassHash. 817 | 818 | 819 | 820 | -------------------------- Example 2 -------------------------- 821 | PS C:\> Get-PrtgServer -Server 'prtg.example.com' -Credential (Get-Credential) -SkipCertificateCheck 822 | Port : 443 823 | Protocol : https 824 | Hostname : prtg.example.com 825 | UserName : JohnDoe 826 | PassHash : 1234567890 827 | UrlHistory : {https://prtg.example.com:443/api/getpasshash.htm?password=PASSWORDREDACTED&username=JohnDoe, 828 | https://prtg.example.com:443/api/getstatus.xml?passhash=1234567890&username=JohnDoe} 829 | LastError : 830 | LastResult : #document 831 | NewAlarms : 0 832 | Alarms : 21 833 | AckAlarms : 7 834 | NewToDos : 0 835 | Clock : 12/14/2018 1:40:41 PM 836 | ClockasDateTime : 12/14/18 1:40:41 PM 837 | ActivationStatusMessage : (Tag activationstatusalert unknown) 838 | BackgroundTasks : 0 839 | CorrelationTasks : 0 840 | AutoDiscoTasks : 0 841 | Version : 18.2.41.1652+ 842 | PrtgUpdateAvailable : True 843 | IsAdminUser : True 844 | IsCluster : False 845 | ReadOnlyUser : False 846 | ReadOnlyAllowAcknowledge : False 847 | 848 | Initiates connection to Prtg Server with the provided Credential skipping validation of the provided SSL certificate. 849 | 850 | 851 | 852 | -------------------------- Example 3 -------------------------- 853 | PS C:\> Get-PrtgServer -Server 'prtg.example.com' -Credential (Get-Credential) -HttpOnly -Quiet -Port 8080 854 | 855 | Initiates connection to Prtg Server with the provided Credential using plaintext HTTP on port 8080. No result is returned to the output stream due to the -Quiet switch. 856 | 857 | 858 | 859 | 860 | 861 | https://github.com/LockstepGroup/prtgshell 862 | https://github.com/LockstepGroup/prtgshell 863 | 864 | 865 | https://www.powershellgallery.com/packages/prtgshell 866 | https://www.powershellgallery.com/packages/prtgshell 867 | 868 | 869 | 870 | 871 | 872 | Get-PrtgTableData 873 | Get 874 | PrtgTableData 875 | 876 | {{Fill in the Synopsis}} 877 | 878 | 879 | 880 | {{Fill in the Description}} 881 | 882 | 883 | 884 | Get-PrtgTableData 885 | 886 | Content 887 | 888 | {{Fill Content Description}} 889 | 890 | 891 | probes 892 | devices 893 | groups 894 | sensors 895 | todos 896 | messages 897 | values 898 | channels 899 | history 900 | 901 | String 902 | 903 | String 904 | 905 | 906 | None 907 | 908 | 909 | ObjectId 910 | 911 | {{Fill ObjectId Description}} 912 | 913 | Int32 914 | 915 | Int32 916 | 917 | 918 | None 919 | 920 | 921 | Column 922 | 923 | {{Fill Column Description}} 924 | 925 | String[] 926 | 927 | String[] 928 | 929 | 930 | None 931 | 932 | 933 | Count 934 | 935 | {{Fill Count Description}} 936 | 937 | Int32 938 | 939 | Int32 940 | 941 | 942 | None 943 | 944 | 945 | StartNumber 946 | 947 | {{Fill StartNumber Description}} 948 | 949 | Int32 950 | 951 | Int32 952 | 953 | 954 | None 955 | 956 | 957 | 958 | 959 | 960 | Column 961 | 962 | {{Fill Column Description}} 963 | 964 | String[] 965 | 966 | String[] 967 | 968 | 969 | None 970 | 971 | 972 | Content 973 | 974 | {{Fill Content Description}} 975 | 976 | String 977 | 978 | String 979 | 980 | 981 | None 982 | 983 | 984 | Count 985 | 986 | {{Fill Count Description}} 987 | 988 | Int32 989 | 990 | Int32 991 | 992 | 993 | None 994 | 995 | 996 | ObjectId 997 | 998 | {{Fill ObjectId Description}} 999 | 1000 | Int32 1001 | 1002 | Int32 1003 | 1004 | 1005 | None 1006 | 1007 | 1008 | StartNumber 1009 | 1010 | {{Fill StartNumber Description}} 1011 | 1012 | Int32 1013 | 1014 | Int32 1015 | 1016 | 1017 | None 1018 | 1019 | 1020 | 1021 | 1022 | 1023 | None 1024 | 1025 | 1026 | 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | System.Object 1034 | 1035 | 1036 | 1037 | 1038 | 1039 | 1040 | 1041 | 1042 | 1043 | 1044 | 1045 | 1046 | 1047 | -------------------------- Example 1 -------------------------- 1048 | PS C:\> {{ Add example code here }} 1049 | 1050 | {{ Add example description here }} 1051 | 1052 | 1053 | 1054 | 1055 | 1056 | --------------------------------------------------------------------------------