(I don't speak English. Hope you understand.)

Hi, I have a powershell script(.ps1) and it needs to work with the current path(e.g. "C:\Users\user\Desktop"). I don't know how to set it into a variable. I know the variable $PWD, but it is:

Path ---- C:\Users\user\Desktop 

and I need it without 'Path ----'.

Thank you for the answers, Andrew

1

1 Answer

Here are some ways to do that. basically you just need to expand the path property.

PS C:\WINDOWS\system32> $PWD Path ---- C:\WINDOWS\system32 PS C:\WINDOWS\system32> $PWD.Path C:\WINDOWS\system32 PS C:\WINDOWS\system32> $PWD | select -Expand Path C:\WINDOWS\system32 PS C:\WINDOWS\system32> (get-location).path C:\WINDOWS\system32 
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy