Last active
March 2, 2018 20:51
-
-
Save sharepointoscar/8d0db4f9da4962d8723191b7316c0720 to your computer and use it in GitHub Desktop.
Login to Azure via PowerShell non-interactive
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install required module | |
Install AzureRM Module | |
# Load Module | |
Import AzureRM Module | |
# Create a Credential Object | |
$clientID = <CLIENT_ID> | |
$key = <CLIENT_SECRET> | |
$SecurePassword = $key | ConvertTo-SecureString -AsPlainText -Force | |
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $clientID, $SecurePassword | |
# login non-interactive | |
Login-AzureRmAccount -Credential $cred -ServicePrincipal -TenantId | |
# query azure | |
Get-AzureRmVM -ResourceGroupName "spfarmstaging" | Select-Object name,ResourceGroupName | Where {$_.name -ne "SP2012R2AD" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment