Powershell 使用设置服务配置服务

Powershell 使用设置服务配置服务,powershell,command-line-interface,powershell-3.0,Powershell,Command Line Interface,Powershell 3.0,我可以通过Powershell将服务设置为在自己的容器中运行吗?即 Powershell等效于什么sc config type=own您可以更改相应WMI对象的服务类型属性 # get service $s = (Get-WmiObject win32_service -filter "Name='Fax'") # change service type $s.Change($null, $null, 16) # 16 = "Own Process" 您可以在此处找到的其他值() 确保cha

我可以通过Powershell将服务设置为在自己的容器中运行吗?即


Powershell等效于什么
sc config type=own

您可以更改相应WMI对象的服务类型属性

# get service
$s = (Get-WmiObject win32_service -filter "Name='Fax'")

# change service type
$s.Change($null, $null, 16) # 16 = "Own Process"
您可以在此处找到的其他值()


确保change方法的ReturnValue等于0。您可以在上面的链接中找到错误代码的含义。

使用
sc
有什么问题?管道衬里变得困难。一旦识别出占用资源的svchost,我希望将其中的所有服务放在各自的容器中,并通过Powershell远程处理远程重新启动它们,以识别罪魁祸首服务。