1

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.

bogga88
  • 21
  • 4

1 Answers1

1

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
bogga88
  • 21
  • 4