Created
February 1, 2013 16:45
-
-
Save ddhahn/4692501 to your computer and use it in GitHub Desktop.
Looks for a service on a remote computer and logs the server name to a file if it's found
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
$servers = get-content C:\temp\potential_gateways.txt | |
foreach($server in $servers){ | |
Get-Service -ComputerName "$server" -Name "Bentley SELECT Server Gateway" -ErrorVariable serviceerr | |
if ($serviceerr.count -eq 0) { | |
Write-Host "$server appears to be a gateway server" | |
Out-File -InputObject $server -FilePath c:\temp\selectservers.txt -Append -Encoding ASCII | |
} | |
else{ | |
Write-Host "$server is not a gateway server" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment