简体   繁体   中英

Start services with contain in powershell

I need a Powershell Script which start all my services 'example*' without the services reeded in from a .txt file

(sry, my English sucks I know)

您可以执行以下操作:

Get-Service -Name * -ComputerName PCNameHere | Where {$_.Name -like "example*"} | Restart-Service -Force -Verbose

Something like this maybe:

$restrictedServices = @(Get-Content X:\restricted.txt) -join '|'
Get-Service example* | ?{$_.Name -notmatch $restrictedServices} | Start-Service -PassThru

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM