Skip to content

Instantly share code, notes, and snippets.

@AspenForester
Created June 14, 2018 20:05
Show Gist options
  • Save AspenForester/4229cf8d44f76d0ee77888f1cf25a667 to your computer and use it in GitHub Desktop.
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.
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