PS: Replace CMD
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:
-
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:
1
net use g: \\ServerComputerName\share /user:domain\user /persistent:yes
- New way:
1
New-PSDrive -Name G -Root \\Server01\Scripts -Credential domain\user -Persist -PSProvider FileSystem
-
If you can’t find a direct equivalent, invoke the command like:
1
cmd /c "net user administrator /active:no"
-
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 -
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.
Comments