Created
July 13, 2022 22:52
-
-
Save SweetAsNZ/05431ca6d464f3e1aadfe84e582fcd4d to your computer and use it in GitHub Desktop.
Check/Test WinRM On All Domain-Joined Servers
This file contains hidden or 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 Get-WinRMServerFailures | |
{ | |
# Ping a Server and if it responds test WINRM | |
$Log = 'C:\SCRIPTS\WinRM\Servers_WinRMFailed.log' | |
Remove-Item $Log | |
$Servers = (Get-ADComputer -Filter * -Properties Name,OperatingSystem,Enabled | Where {($_.Enabled -eq $true) ` | |
-and ($_.OperatingSystem -like "Windows Server*")} | Sort Name).Name | |
foreach ($Server in $Servers) | |
{ | |
# $Server = 'SERVER1' # Testing | |
# Ping the Server and if it responds | |
if(Test-Connection -ComputerName $Server -Count 1 -Quiet){ | |
# Test WinRM | |
$TestWinRM = Test-NetConnection -ComputerName $Server -CommonTCPPort WINRM #-ErrorAction Stop | |
if($TestWinRM.TCPTestSucceeded -eq $false){ | |
Add-Content -Path $Log -Value $Server | |
} | |
}#END IF BIG | |
}#END FOREACH | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment