Skip to content

Instantly share code, notes, and snippets.

@shawnweisfeld
Created May 24, 2016 23:22
Show Gist options
  • Save shawnweisfeld/4d3d70d9d9e04642a81f96195824842c to your computer and use it in GitHub Desktop.
Save shawnweisfeld/4d3d70d9d9e04642a81f96195824842c to your computer and use it in GitHub Desktop.
$Password = '<<my password>>'
Login-AzureRmAccount
$azureAdApplication = New-AzureRmADApplication -DisplayName "MyPoshApp" -HomePage "https://www.contoso.org" -IdentifierUris "https://www.contoso.org/example" -Password $Password
$azureAdApplication
DisplayName : MyPoshApp
Type : Application
ApplicationId : <<ApplicationID>>
ApplicationObjectId : <<Application Object ID>>
AvailableToOtherTenants : False
AppPermissions : {}
IdentifierUris : {https://www.contoso.org/example}
ReplyUrls : {}
New-AzureRmADServicePrincipal -ApplicationId $azureAdApplication.ApplicationId
New-AzureRmRoleAssignment -RoleDefinitionName Owner -ServicePrincipalName $azureAdApplication.ApplicationId.Guid
RoleAssignmentId : /subscriptions/<<GUID>>/providers/Microsoft.Authorization/roleAssignments/<<GUID>>
Scope : /subscriptions/<<GUID>>
DisplayName : MyPoshApp
SignInName :
RoleDefinitionName : Owner
RoleDefinitionId : <<GUID>>
ObjectId : <<GUID>>
ObjectType : ServicePrincipal
Get-AzureRmSubscription
SubscriptionName : Visual Studio Enterprise
SubscriptionId : <<GUID>>
TenantId : <<TenantID GUID>>
State : Enabled
$secretvalue = ConvertTo-SecureString $Password -AsPlainText -Force
$SecureStringAsPlainText = $secretvalue | ConvertFrom-SecureString
$SecureStringAsPlainText | Out-File c:\temp\pwd.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment