【问题标题】:Powershell script replace sc configPowershell 脚本替换 sc 配置
【发布时间】:2019-11-29 12:27:33
【问题描述】:

美好的一天,

我寻找与

相同的命令

sc config BITS type= own 在 Powershell 中。 我认为与 set-service -name BITS -computername server1234 -idon´t know

我的问题是我的 INVOKE-COMMAND 不起作用。 但是所有脚本都只工作这一行不起作用。

Invoke-Command -ComputerName $serverneedhelp -ScriptBlock {Start-Process cmd -ArgumentList "/c 'sc config bits type= own'"}

如果有人可以帮助我,那就太好了。 谢谢你

问候 一月

【问题讨论】:

  • 您是否尝试过直接调用sc.exe 而不是通过cmd

标签: powershell sc


【解决方案1】:

直接运行?

Invoke-Command $serverneedhelp { sc config bits type= own }

另一种选择是使用 wmi:Configure service with Set-Service

【讨论】:

    【解决方案2】:

    在我的脚本中使用它

    Invoke-Command -ComputerName $serverneedhelp -ScriptBlock {Start-Process cmd  -ArgumentList "/c sc config bits type= own"}
    

    但是我搜索了一个没有 cmd 的 Powershell 版本

    【讨论】:

      【解决方案3】:

      我知道这是旧线程,但也许有人会从中受益。 对我有用的是:

      Invoke-Command -ComputerName $serverneedhelp -ScriptBlock {& SC.exe config "bits" type= own}
      

      【讨论】:

        猜你喜欢
        • 2021-06-09
        • 2016-10-06
        • 2016-08-21
        • 2019-03-14
        • 2012-10-02
        • 2021-09-29
        • 2018-07-11
        • 2013-12-07
        • 1970-01-01
        相关资源
        最近更新 更多