简体   繁体   中英

Powershell - Net Use credentials not working

i want to automate net use through powershell to bind a lot of share drives.

first i fetch the credentials via Get-Credentials , then i want to use the credentials later.

$cred = Get-Credentials -Message "Enter credentials"
net use K: \\192.168.100.50\E$ /user:$cred.username $cred.password

This throws the error Network password wrong (translated from german)

When i enter it like that: net use K: \\\\192.168.100.50\\E$ /user:Admin Adminpassword

It works? When i replace $cred.password with the plaintext password and only use the username variable it still says Network password wrong

What is conflicting here?

Use powershell to do this, because Get-Credentials store your data as securestring, net use can't work with it.

 $cred = Get-Credentials -Message "Enter credentials"
 New-PSDrive -Name K -PSProvider FileSystem -Root "ComputerName\FilePath" -Persist -Credential $cred

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM