Is there a way to create a New-PSDrive by using a password that is a NON- SystemSecured string ?
If the password is "FooBoo" I want to use it as it is...
Adding New Windows PowerShell Drives (New-PSDrive) To create a new Windows PowerShell drive, you must supply three parameters: A name for the drive (you can use any valid Windows PowerShell name) The PSProvider (use "FileSystem" for file system locations and "Registry" for registry locations)
Although we can use Net Use in PowerShell, there is a more powerful alternative, the New-PSDrive cmdlet. With the New-PSDrive cmdlet, we cannot only map network drives but also create drive mappings to local folders or registry keys on our computer.
The New-PSDrive cmdlet creates temporary and persistent drives that are mapped to or associated with a location in a data store, such as a network drive, a directory on the local computer, or a registry key, and persistent Windows mapped network drives that are associated with a file system location on a remote ...
just use the old net use commmand
PS>net use z: \\server\share Fooboo /user:domain\user
PS>Get-PSDrive -Name Z
Name Used (GB) Free (GB) Provider Root CurrentLoc
ation
---- --------- --------- -------- ---- ----------
Z 150,36 49,64 FileSystem Z:\
Or convert you plain text password to secure-string :
PS>$pass="FooBoo"|ConvertTo-SecureString -AsPlainText -Force
PS>$Cred = New-Object System.Management.Automation.PsCredential('user@domain',$pass)
PS>New-PSDrive -name j -Root \\server\share -Credential $cred -PSProvider filesystem
Name Used (GB) Free (GB) Provider Root
---- --------- --------- -------- ----
j FileSystem \\server\share
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With