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}}