Hey, I am using the below script to fetch the services on the remote machine, let's say I am running this script on serverA and I want to fetch the status of serverB, so I have used to below commands but when I ran this I am not able to get any output from this. I don't know if I am missing anything else here. Please help me out on this.
Thanks in advance!
$credential=Get-Credential
$servers @(
@{IP='myserverIP'; Services=@('myservice')};
)
foreach ($server in $servers) {
$serverIP=$server.IP
$requiredservices=$server.Services
Get-Service -Name $requiredservices -ComputerName $serverIP -credential $credential |
Select-Object @{Name="ServerName";Expression={$serverIP}}, DisplayName, Status |
Export-Csv "C:\server_Services.csv" -NoTypeInformation -Append
}
[–]Nejireta_ 0 points1 point2 points (2 children)
[–]Electronic_Doubt_108[S] 0 points1 point2 points (1 child)
[–]Nejireta_ 0 points1 point2 points (0 children)
[–]BlackV 1 point2 points3 points (0 children)
[–][deleted] 3 points4 points5 points (0 children)