Requesting a password.

$Credentials = Get-Credential -Credential "domaine\dwuibail_adm"
$ldWS    = New-WebServiceProxy -uri http://serverlandesk.leblogosd.lan/MBSDKService/MsgSDK.asmx?WSDL -Credential $Credentials

Passwords in plain text.

$username = “domaine\dwuibail_adm”
$password = “Motdepasse”
$Credentials = New-Object System.Management.Automation.PSCredential $Username,$Password
$ldWS    = New-WebServiceProxy -uri http://serverlandesk.leblogosd.lan/MBSDKService/MsgSDK.asmx?WSDL -Credential $Credentials

Encrypting passwords

The encryption and decryption can only be done on the same machine and by the same account

  • Get the encrypted key
"MyPassword" | Convertto-SecureString -AsPlainText -Force | ConvertFrom-SecureString | Out-file C:\temp\PassKey.txt
  • Using the encrypted key
$user = "moncompte"
$password = ConvertTo-SecureString -String "01000000d08c9ddf01151111111111111111111111111 ..... 111111111111111"
$creds    = New-Object -TypeName System.Management.Automation.PsCredential -ArgumentList ($user, $password)

#Exemple 1
New-PSDrive -Name "P" -Root "\\nas\dml" -PSProvider "FileSystem" -Credential $creds

#Exemple 2
$Pass  = $creds.getnetworkcredential().Password

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.