Created
June 14, 2018 20:05
-
-
Save AspenForester/4229cf8d44f76d0ee77888f1cf25a667 to your computer and use it in GitHub Desktop.
Tests for WSMan being enabled on one or more computers, and returns an object containing the computer name and a boolean value.
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
function Test-AllWSMANServer | |
{ | |
[CmdletBinding()] | |
param ( | |
# Computername | |
[Parameter(ValueFromPipeline = $true)] | |
[String[]] | |
$ComputerName | |
) | |
begin | |
{ | |
} | |
process | |
{ | |
foreach ($computer in $ComputerName) | |
{ | |
If (Test-WSMan -ComputerName $computer -ErrorAction SilentlyContinue) | |
{ | |
[pscustomobject]@{ | |
Computername = $computer | |
WSMANEnabled = $true | |
} | |
} | |
else | |
{ | |
Write-Verbose "WSMAN is not enabled on $computer" | |
[pscustomobject]@{ | |
Computername = $computer | |
WSMANEnabled = $false | |
} | |
} | |
} | |
} | |
end | |
{ | |
} | |
} # end Test-AllWSMANServer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment