@ECHO off
$BIOS= Get-WmiObject -computername \"BAHRIATSG2-PC\" -Namespace
root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface
$BIOS.SetBIOSSetting(\'Setup Passwor
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','<utf-16/>TheBIOSPassword','<utf-16/>')}"
I think this is the simplest and clearest way because it don't requires any superfluous switch; just plain PowerShell code:
@ECHO off
PowerShell ^
$BIOS= Get-WmiObject -computername \"BAHRIATSG2-PC\" -Namespace; ^
root/hp/instrumentedBIOS -Class HP_BIOSSettingInterface; ^
$BIOS.SetBIOSSetting('Setup Password','<utf-16/>TheBIOSPassword','<utf-16/>')
pause
Just add a ; ^
at end of each line and escape each quote with backslash.
powershell has its own script file type, extension is .ps1
Save your code to a .ps1 file, and run it from a batch file with:
powershell xxx.ps1