I want to map a network resource remotely via net use.
This is my PowerShell code:
$user = Read-Host -Prompt "Enter Username"
$pw = Read-Host -Prompt "Enter Password" -AsSecureString
net use X: \\Server\dir1\dir2 /persistent:no /user:$user $pw
It works if I write my credentials instead of the variables.
But I need to read in the credentials.
Is there a way to use variables in the net use command?