Reputation: 897
How would I go about doing what I mentioned in the subject line. Here are screenshots of what I mean:
I was expecting the directory below to have changed to "C:\Program Files" after running the "Test.ps1" script?
Updated script after adding Write-Host $pwd
Upvotes: 0
Views: 27482
Reputation: 3342
There is no global 'current' directory, it is a property of the particular process you are working in. The 'current' directory for winword.exe
may be very different to the 'current' directory of powershell.exe
. And indeed, two different powershell processes can have different ideas of the 'current' directory.
So it would be foolish to expect that changing the 'current' directory in one powershell process would affect any other processes.
Upvotes: 1
Reputation: 816
Set-Location -Path "C:\Folder\SubFolder"
The above will change the directory to the given location as long as you have access to navigate to the location provided.
Upvotes: 3