Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Param (
- [string]$msolDisplayName = "SVC-Nework-Gateway-Updater",
- [string]$msolFirstName = "Network-Gateway",
- [string]$msolLastName = "Updater-Account",
- [string]$msolUpn = "svc_network-updater@yourDomain.onmicrosoft.com",
- [string]$msolPassword = "MyPassword#12345",
- [string]$msolUsageLocation = "US",
- [string]$azureSubscriptionName = "mySubscription",
- [string]$azureResourceGroupName = "Networking",
- [string]$azureLocalGatewayName = "LocalGateway"
- )
- #region Login to O365 and Create User
- $cred = Get-Credential -Message "Enter Admin Credentials for O365..."
- Connect-MsolService -Credential $cred
- $user = New-MsolUser -DisplayName $msolDisplayName `
- -FirstName $msolFirstName `
- -LastName $msolLastName `
- -UserPrincipalName $msolUpn `
- -UsageLocation $msolUsageLocation `
- -ForceChangePassword:$false `
- -PasswordNeverExpires:$true `
- -Password $msolPassword
- #endregion
- #region Login to Azure and Add User to Local Network Gateway RBAC
- Login-AzureRmAccount -SubscriptionName $azureSubscriptionName
- $ID = Get-AzureRmResourceGroup $azureResourceGroupName | Get-AzureRmLocalNetworkGateway -Name $azureLocalGatewayName | select Id
- New-AzureRmRoleAssignment -Scope $ID.Id -ObjectId $user.ObjectId -RoleDefinitionName "Contributor"
- <# Remove User from EVERYWHERE!
- Get-AzureRmRoleAssignment | Where-Object {$_.ObjectId -eq $userID} | Remove-AzureRmRoleAssignment
- #>
- #endregion
Add Comment
Please, Sign In to add comment