Skip to content

Instantly share code, notes, and snippets.

@ddhahn
Created February 1, 2013 16:45
Show Gist options
  • Save ddhahn/4692501 to your computer and use it in GitHub Desktop.
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
$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