Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

want to display computername, serviceName and status

$
0
0

I want to get lanmanserver status for all servers with "*equ*"  in the name, the get-adcomputer returns proper server values (before the pipe) once i put in foreach i get the following error with the script i use below, 

______________________________________________

get-adcomputer -filter  'name -like "*equ*"' | foreach {Get-service -ServiceName lanmanserver -ComputerName $_ } | select Name, Machinename, Status

_______________________________________________

Get-service : Cannot find any service with service name 'lanmanserver'.
At line:1 char:57
+ get-adcomputer -filter  'name -like "*equ*"' | foreach {Get-service -ServiceName ...
+                                                         ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (lanmanserver:String) [Get-Service], ServiceCommandException
    + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand

Get-service : Cannot find any service with service name 'lanmanserver'.
At line:1 char:57
+ get-adcomputer -filter  'name -like "*equ*"' | foreach {Get-service -ServiceName ...
+                                                         ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (lanmanserver:String) [Get-Service], ServiceCommandException
    + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand

Get-service : Cannot find any service with service name 'lanmanserver'.
At line:1 char:57
+ get-adcomputer -filter  'name -like "*equ*"' | foreach {Get-service -ServiceName ...
+                                                         ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (lanmanserver:String) [Get-Service], ServiceCommandException
    + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand


get-adcomputer -filter 'name -like "*equ*"' | foreach {get-service -servicename spooler | select *, @{n="ComputerName"; e={$_.ComputerName}}


Viewing all articles
Browse latest Browse all 6937

Trending Articles