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>