PS: Replace CMD

less than 1 minute read

Description:

As Microsoft moves forward with Powershell (has it already been out for 10 years?), use the following “tricks” to replace CMD completely with Powershell.

To Resolve:

  1. Obviously, see if there is a Powershell way of doing the same thing (I have a couple posts on this myself..)

Old way to map a drive:

net use g: \\server\share /user:domain\user /persistent:yes

New way:

New-PSDrive -Name G -Root \Server01Scripts -Credential domain\user -Persist -PSProvider FileSystem
  1. If you can’t find a direct equivalent, invoke the command like:
cmd /c "net user administrator /active:no"
  1. Use the Stop-Parsing symbol “–%” so that Powershell won’t parse symbols such as parenthesis and brackets:

Ex: icacls c:\logs\* /grant Administrator:(D,WDAC) will fail in PowerShell. icacls --% c:\logs\* /grant Administrator:(D,WDAC) will work

  1. Lastly for Windows 10 users, make sure to replace CMD with Powershell by going to Settings – Taskbar – Replace CMD with Powershell. This will only give Powershell options with the Win+X menu.