Services Running and Stopped

Hi All,

Can any one let me know why the below script is not running and log file  is not generating  

$Servers = get-content E:\AutomationTasks\Computer.txt
foreach($server in $Servers) 
{
Get-Service | Where-Object { ($_.name -like '*W3SVC*') -or ($_.name -like '*Metastorm Deployment Service*') -or ($_.name -like '*Metastorm Process Englikee*') -or ($_.name -like '*BpmDispatcher_A*') -or ($_.name -like '*BpmDispatcher_B*') -or ($_.name -like '*MSCRMAsyncService*') -or ($_.name -like '*PVEDispatcher_A*') -or ($_.name -like '*CrmDispatcher_A*') - ($_.name -like '*CrmDispatcher_B*') }|where {$_.Status -eq "Running"} |ft $server,name, status -AutoSize | out-file E:\MMOS\Logs\Prod-RunningServices.log -append
}
May 18th, 2015 2:02am

Could just be a copy error but you are missing an -or

$Servers = get-content E:\AutomationTasks\Computer.txt
foreach($server in $Servers) 
{
Get-Service | Where-Object { ($_.name -like '*W3SVC*') -or ($_.name -like '*Metastorm Deployment Service*') -or ($_.name -like '*Metastorm Process Englikee*') -or ($_.name -like '*BpmDispatcher_A*') -or ($_.name -like '*BpmDispatcher_B*') -or ($_.name -like '*MSCRMAsyncService*') -or ($_.name -like '*PVEDispatcher_A*') -or ($_.name -like '*CrmDispatcher_A*') -or ($_.name -like '*CrmDispatcher_B*') }|where {$_.Status -eq "Running"} |ft $server,name, status -AutoSize | out-file E:\MMOS\Logs\Prod-RunningServices.log -append
}

Free Windows Admin Tool Kit Click here and download it now
May 18th, 2015 3:22am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics