Embedding o365 credentials into PowerShell

Sometimes it is necessary to schedule scripts with credentials for services such as Office 365 that require authentication.  These passwords can be stored securely rather than in plain text

read-host -assecurestring | convertfrom-securestring | out-file C:\temp\creds.txt
************

As an example for usage

$pass = get-content C:\temp\creds.txt | convertto-securestring
$creds = new-object -typename System.Management.Automation.PSCredential -argumentlist “admin@stevenwatsonuk.onmicrosoft.com”,$pass
Connect-MsolService -credential $creds

however this is not using strong encryption and there are readily available ways of reversing the stored password just stops the plain text access http://stackoverflow.com/questions/7468389/powershell-decode-system-security-securestring-to-readable-password 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s