cd C:\Users\Rupesh Kumar\DocumentsThere is a space between "Rupesh Kumar" which doesn't allow me to change the directory but it is working in CMD.
Set-Location : A positional parameter cannot be found that accepts argument 'Kumar\Desktop'.
At line:1 char:1
+ cd C:\Users\Rupesh Kumar\Desktop
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Set-Location], ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetLocationCommand 1 2 Answers
In cmd cd is an internal command that receives an optional /D option and then treats the whole remaining command line as path, therefore it accepts spaces in the paths even without quotes. Just run cd /? and you'll see
CHDIR command does not treat spaces as delimiters, so it is possible to
CD into a subdirectory name that contains a space without surrounding
the name with quotes. For example: cd \winnt\profiles\username\programs\start menuIn powershell cd is just an alias to Set-Location which accepts various parameters, one of which is the path. You can't have raw spaces in a single argument like (almost) all other shells, therefore you must quote it or escape the spaces like this
cd 'C:\Users\Rupesh Kumar\Documents'
cd "C:\Users\Rupesh Kumar\Documents"
cd C:\Users\Rupesh` Kumar\Documentscmd and powershell are completely different terminals, so why do you expect them to behave the same?
Please add single quotes for the set-location as directed above. As a coder I tend to avoid spaces if I can in everything I write in code. I opt for _ or simply capitalize with no space