Exporting credentials in XML

Working as a consultant, from time to time you receive some petitions from your customers in order to facilitate their daily lives.

The other day I receive a petition to save user credentials, and to not prompt for them, is it very easy to do it, lets crack into it:

#Save credentials to file

Get-Credential | Export-Clixml -Path C:\aar\credentials.xml

#Import credentials from file

$credentials = Import-Clixml -Path c:\aar\credentials.xml

Once you have done this, you can include this last line into your scripts pointing to the location where you stored the credentials. Simply as follows: