I am trying to connect to a network resource through powershell. The network share is in a different domain, so I need to provide credentials. Since New-PSDrive does not support credentials, I was going to use net use , but I am worried about providing my username and password directly in the text in the script. I made ConvertTo-SecureString make a secure string from my password, then use ConvertFrom-SecureString and save the result in a file. Then I pulled it from a file like this, and tried using net :
$password = Get-Content <locationOfStoredPasswordFile> | ConvertTo-SecureString
net use q: "\\server\share" $password /user:domain\username
But net use does not recognize the protected string.
Does anyone have any ideas on how to store credentials, so using a network can use them? Thank!
source
share