Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Mount windows share in command line via net use with password encrypted.

$
0
0

Hi All,

  I just try to do with this but not importing the password i think?

Get-Credential | Export-Clixml C:\Users\user\mycredfile1.xml
$Credential = Import-Clixml C:\Users\user\mycredfile1.xml
net use X: "\\server\AHS Data" /user:$($Credential.UserName) $($Credential.GetNetworkCredential().Password)

================================

S C:\WINDOWS\system32> Get-Credential | Export-Clixml C:\Users\user\mycredfile1.xml
$Credential = Import-Clixml C:\Users\user\mycredfile1.xml
net use X: "\\Server\AHS Data" /user:$($Credential.UserName) $($Credential.GetNetworkCredential().Password)
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Method invocation failed because [Deserialized.System.Management.Automation.PSCredential] does not contain a method named 'GetNetworkCredential'.
At line:3 char:72
+ ... ($Credential.UserName) $($Credential.GetNetworkCredential().Password)
+                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (GetNetworkCredential:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound
 
net : System error 85 has occurred.
At line:3 char:1
+ net use X: "\\server\AHS Data" /user:$($Credential.UserName)  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (System error 85 has occurred.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
The local device name is already in use.

PS C:\WINDOWS\system32> 


Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>