Skip to content

Instantly share code, notes, and snippets.

@bcdady
Last active February 24, 2016 20:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcdady/daaaf988636d3f38dc63 to your computer and use it in GitHub Desktop.
Save bcdady/daaaf988636d3f38dc63 to your computer and use it in GitHub Desktop.
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