Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mano8/1260da0c4c3a7be2bb2238541c83018c to your computer and use it in GitHub Desktop.
Save mano8/1260da0c4c3a7be2bb2238541c83018c to your computer and use it in GitHub Desktop.

Revisions

  1. @bdanse bdanse created this gist Nov 4, 2018.
    11 changes: 11 additions & 0 deletions CreateAutomationPSCredential.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    #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'