我是PowerShell的新手,我需要编写脚本以特定顺序启动3个或更多Windows服务,并且它们之间有一定的延迟。我知道如何编写脚本来启动所有脚本,但是我不知道如何设置延迟:
Get-Service -ComputerName cumputer_name -Name service_name1 | Stop-Service -Verbose
Get-Service -ComputerName cumputer_name -Name service_name2 | Stop-Service -Verbose
最佳答案
我相信您正在寻找Start-Sleep
。
Get-Service -ComputerName cumputer_name -Name service_name1 | Stop-Service -Verbose
Start-Sleep -Seconds 5
Get-Service -ComputerName cumputer_name -Name service_name2 | Stop-Service -Verbose
关于windows - 一次启动3个Windows服务,它们之间有延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62878342/