How to run powershell command in batch file

后端 未结 3 1945
轮回少年
轮回少年 2021-01-25 16:50
@ECHO off

$BIOS= Get-WmiObject -computername \"BAHRIATSG2-PC\" -Namespace 
root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface

$BIOS.SetBIOSSetting(\'Setup Passwor         


        
3条回答
  •  终归单人心
    2021-01-25 17:16

    Enclose your PowerShell code in,

    powershell -Command "& {}"
    

    Remember to separate all statements with ; and to enclose your " with a quoted string, i.e by using ""

    powershell -Command "& {$BIOS= Get-WmiObject -computername ""BAHRIATSG2-PC\"" -Namespace root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface; $BIOS.SetBIOSSetting('Setup Password','TheBIOSPassword','')}"
    

提交回复
热议问题