Link to home
Start Free TrialLog in
Avatar of Parity123
Parity123Flag for United States of America

asked on

Powershell: Check if WinRM is listening

Hello experts,

Please assist.
I am looking for a script to loop through 700 domain controllers and check if the winrm is listening. The output should be

 computer name,  result

The result will be YES if it is listening or NO.

Please help me complete this.
$output = @()
$computers = gc computers.txt
foreach ($computer in $computers) {

    $output += test-wsman $computer
}
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

$output = @()
$computers = gc computers.txt
foreach ($computer in $computers) {
  Try {
    $r = Test-WSMan -ComputerName $computer -ErrorAction Stop
    $output += $computer + ' Success'
  }
  Catch {
    $output += $computer + ' Failed'
  }
} 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Parity123

ASKER

Thanks