Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # AzUserLogin
- # ===========
- #
- # Prompt for user credentials
- # Login to Azure
- # Gather output response
- #Prompt for Username
- $AzUser = Read-Host "Azure username: "
- #Prompt for pasword
- $AZsecurePass = Read-Host "Azure password: " -AsSecureString;
- $AzPass = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($AZsecurePass));
- #Login AZ User and gather output as $AzUserObj
- $AzUserObj = az login -u $AzUser -p $AzPass;
- #Convert standard $AZResourceGroupObj to JSN format to expose individual values
- #These values can be used in subsequent automated tasks
- $AZUserJSN = ConvertFrom-Json -InputObject ([string]$AZUserObj)
- write-host $AZUserJSN.id
- write-host $AZUserJSN.cloudName
- write-host $AZUserJSN.isDefault
- write-host $AZUserJSN.name
- write-host $AZUserJSN.state
- write-host $AZUserJSN.tenantId
- write-host $AZUserJSN.user.name
- write-host $AZUserJSN.user.type
Add Comment
Please, Sign In to add comment