Given this file
Set-Location C:\
If I run it
.\foo.ps1
It will change the directory in the script. However once the script is finished the parent console directory has also been changed. Can Set-Location
be called in such a way as to affect only the running script?
try
{
Push-Location
Set-Location c:\
# your code here ...
}
finally
{
Pop-Location
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With