Private/Get-GreyhoundServerInfo.ps1
function Get-GreyhoundServerInfo { <# .SYNOPSIS Gets information from the GREYHOUND Server .DESCRIPTION Long description .EXAMPLE Example of how to use this cmdlet #> [CmdletBinding(DefaultParameterSetName='Parameter Set 1' )] Param ( [Parameter( Mandatory=$false, ParameterSetName='Parameter Set 1')] [Parameter( Mandatory=$false, ParameterSetName='Parameter Set 2')] [string]$Hostname = 'localhost', [string]$Username = 'system', [string]$Password = (Get-GreyhoundSystemPassword), [Boolean]$UseSsl = $true, [Int32]$Port = '443' ) if ($UseSsl) { $GreyhoundServerUri = 'https://' + $Hostname + ':' + $Port + '/json' } else { $GreyhoundServerUri = 'http://' + $Hostname + ':' + $Port + '/json' } $ContentType = 'application/json' $UserAgent = 'PowerShell' $Body = '{"version":"1.1", "method": "RpcInfo.GetServerInfo", "params": [true]}' $RandomStr = (Get-Random).ToString() $Md5 = New-Object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider $Utf8 = New-Object -TypeName System.Text.UTF8Encoding $ClientID = ([System.BitConverter]::ToString($Md5.ComputeHash($Utf8.GetBytes($RandomStr)))).Replace('-', '') # $Username = 'system' # $Password = Get-GreyhoundSystemPassword $Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f ($ClientID + '-' + $Username) ,$Password))) Write-Host @" "$GreyhoundServerUri" $GreyhoundServerUri '$RandomStr' $RandomStr '$Md5' $Md5 '$Utf8' $Utf8 '$ClientID + $Username' + ($ClientID + '-' + $Username) '$Authorization' + $Authorization "@ ` -ForegroundColor Yellow #try { $GreyhoundResponse = Invoke-RestMethod -Method Post -UserAgent $UserAgent -ContentType $ContentType -Uri $GreyhoundServerUri -Body $Body -Headers @{Authorization=($Authorization)} Write-Host '$GreyhoundResponse' ($GreyhoundResponse) write-host '$GreyhoundResponse.Error' ($GreyhoundResponse.Error) Write-Host '$GreyhoundResponse.Result' ($GreyhoundResponse.Result) if ((!$GreyhoundResponse).Error) { return $GreyhoundResponse.Result } else { return $GreyhoundResponse.Error.message } $GreyhoundResult #} catch { #Write-Host 'Es ist ein Fehler bei der Abfrage des GREYHOUND Servers an' $GreyhoundServerUri 'aufgetreten.' #} } |