Managing Passwords in PowerShell Scripts with PowerShell Administration Scripts
Managing Passwords PowerShell – Learn how to securely manage and encrypt passwords in PowerShell scripts, ensuring data protection and script integrity.
Useful external reference: Microsoft Learn.
Managing Passwords PowerShell Overview
$Credentials = Get-Credential -Credential "domainedwuibail_adm"
$ldWS = New-WebServiceProxy -uri http://serverlandesk.leblogosd.lan/MBSDKService/MsgSDK.asmx?WSDL -Credential $Credentials
Managing Passwords PowerShell Overview
$username = “domainedwuibail_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
Managing Passwords PowerShell Overview
Managing Passwords PowerShell – The encryption and decryption can only be done on the same machine and by the same account
Useful external reference: Microsoft Learn.
- Get the encrypted key
"MyPassword" | Convertto-SecureString -AsPlainText -Force | ConvertFrom-SecureString | Out-file C:tempPassKey.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 "nasdml" -PSProvider "FileSystem" -Credential $creds
#Exemple 2
$Pass = $creds.getnetworkcredential().Password
