Are you trying to find the Windows Security Center Service? The name should be "wscsvc". The name in the error message is missing the letter "c" at the end of the name. Check the contents of the file containing the service names,
String not Passing to Get-Service
I'm trying to find which members of a list of device names in a file. don't have the wscsvc service running on them.
When I use a variable, I get a message saying "Get-Service : Cannot find any service with service name 'wscsv'.". If I replace the variable for the value that the variable contains, it retrieves the service status correctly. What am I missing?
$devices = Get-Content -Path '[File Path]'
foreach($device in $devices)
{
Get-Service -ComputerName $device -Name wscsvc | Export-Csv 'c:\temp\WSCSV_Status.csv'
}
2 answers
Sort by: Most helpful
-
-
Maranya, Damon 326 Reputation points
2023-02-21T15:32:06.8766667+00:00 After some more tinkering this morning. It looks like some of devices on the list are present in AD, but don't have a DNS assignment for Get-Service to reference when trying to track down a device by its Device Name. Meaning that when it tries to find the device running the service, it can't locate it, and there for returns the "Can't find any service with the name 'wscsvc'" error.
So, the script is working as it should. It's my expectations about the number of active devices that seems to be the problem here.