Search code examples
remote-accesspowershell-remoting

Running CMD in Enter-PSSession


im trying to remotely reboot a computer into safemode. I go in with Enter PSSsession but when i try to run the command below it doesn't work. If I run it within Command Prompt it works. someone said this is due to parsing in powershell. So I remote in with ETSN command and try to launch Command prompt but as soon as it opens it closes and goes back to powershell, anyone have an idea of why this happens or knows another way to reboot a Windows PC into safemode?

bcdedit /set {default} safeboot minimal


Solution

  • Curly brackets have a special meaning in PowerShell, so you need to prevent the parser from interpreting them, e.g. by putting the argument in quotes. I would also recommend using the call operator whenever you're calling external commands, even though it's not required in this case.

    & bcdedit /set '{default}' safeboot minimal