Skip to content

Instantly share code, notes, and snippets.

@bdanse
Created November 4, 2018 12:37
Show Gist options
  • Save bdanse/c2b8c3c509de78434e16f443189b19f8 to your computer and use it in GitHub Desktop.
Save bdanse/c2b8c3c509de78434e16f443189b19f8 to your computer and use it in GitHub Desktop.
Example for creating Automation PSCredential
#Create a secure string for the password
$SecureStringPassword = ConvertTo-SecureString "SuperSecretPassw0rd" -AsPlainText -Force
#Create a PSCredential object
$PSCredential = New-Object System.Management.Automation.PSCredential('domain\myusername', $SecureStringPassword)
#Write PSCredential object to an Azure Automation account
New-AzureRmAutomationCredential -Name 'MyCredentialAssetName' -Value $PSCredential
#Retrieve PSCredential object from within a runbook of DSC compilation job
Get-AutomationPSCredential -Name 'MyCredentialAssetName'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment