Guest User

Untitled

a guest
Feb 5th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. # AzUserLogin
  2. # ===========
  3. #
  4. # Prompt for user credentials
  5. # Login to Azure
  6. # Gather output response
  7.  
  8. #Prompt for Username
  9. $AzUser = Read-Host "Azure username: "
  10.  
  11. #Prompt for pasword
  12. $AZsecurePass = Read-Host "Azure password: " -AsSecureString;
  13. $AzPass = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($AZsecurePass));
  14.  
  15. #Login AZ User and gather output as $AzUserObj
  16. $AzUserObj = az login -u $AzUser -p $AzPass;
  17.  
  18. #Convert standard $AZResourceGroupObj to JSN format to expose individual values
  19. #These values can be used in subsequent automated tasks
  20. $AZUserJSN = ConvertFrom-Json -InputObject ([string]$AZUserObj)
  21. write-host $AZUserJSN.id
  22. write-host $AZUserJSN.cloudName
  23. write-host $AZUserJSN.isDefault
  24. write-host $AZUserJSN.name
  25. write-host $AZUserJSN.state
  26. write-host $AZUserJSN.tenantId
  27. write-host $AZUserJSN.user.name
  28. write-host $AZUserJSN.user.type
Add Comment
Please, Sign In to add comment