Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a new PSDrive by using a password that is not SystemSecuredString?

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...

like image 279
pencilCake Avatar asked Dec 11 '12 10:12

pencilCake


People also ask

How do I create a new-PSDrive in PowerShell?

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)

Can I use Net use in PowerShell?

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.

What is a PSDrive?

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 ...


1 Answers

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
like image 113
Loïc MICHEL Avatar answered Oct 19 '22 21:10

Loïc MICHEL