We have a network share over vpn to a windows server in a different city. each person has a username to access the folder (and only that specific folder) his/her folder is same as username. user os is win 10

usr: john_smith; pw: 1234


I'm trying to make a script that will ask for user credentials to map the drive and then based on the credentials to know that after the ip his folder is same as usernamer, automatically adding the folder name to path.

New-PSDrive -Name P -PSProvider FileSystem -Root \\\ -Credential domain\user

New-PSDrive dose not help me because, again, user has access rights only to his/her folder, any other root folder is unavailable.


figured it out

$credential = Get-Credential
New-PSDrive -Name x -PSProvider FileSystem -Root "\\\$($user)" -Credential $credential -persist

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.