Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Test-WSMan alternative, with custom PS Object
$Private:WinRMListener = & winrm e winrm/config/listener; foreach ($line in $Private:WinRMLTokens = $WinRMListener -split '\n') { $Private:lineTokens = $line -split '=';if ($lineTokens[0] -like '*Source*') { $Private:source = $($lineTokens[1]).trim().replace('"','').replace(']','') }; if ($lineTokens[0] -like '*Transport*') { $Private:Transport = $($lineTokens[1]).trim() }; if ($lineTokens[0] -like '*Port*') { $Private:Port = $($lineTokens[1]).trim() }; if ($lineTokens[0] -like '*Enabled*') { $Private:Enabled = $($lineTokens[1]).trim() }; if ($lineTokens[0] -like '*ListeningOn*') { $Private:ListeningOn = $(($lineTokens[1] -split ',')[0]).trim() } }; $Private:properties = [ordered]@{ 'Source' = $source; 'Transport' = $Transport; 'Port' = $Port; 'Enabled' = $Enabled; 'ListeningIP' = $ListeningOn }; $Private:WinRMListenerInfo = New-Object -TypeName PSObject -Property $properties; $WinRMListenerInfo
$Private:WinRMVersion = & winrm id; $Private:WinRMVerTokens = $WinRMVersion -split '='; $Private:ProductVerTokens = $WinRMVerTokens[6] -split ' ';$Private:properties = [ordered]@{'ProductVersion'=$WinRMVerTokens[6];'OS'=$ProductVerTokens[2];'SP'=$ProductVerTokens[4];'Stack'=$ProductVerTokens[6]};$Private:WinRMID = New-Object -TypeName PSObject -Property $properties;$WinRMID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment