0

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

\\192.168.1.1\john_smith

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 \\192.168.1.1\ -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.

0

figured it out

$credential = Get-Credential
$user=$credential.GetNetworkCredential().UserName
New-PSDrive -Name x -PSProvider FileSystem -Root "\\192.168.1.29\$($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.