Skip to content

Instantly share code, notes, and snippets.

@bergmeister
Last active June 19, 2020 15:05
Show Gist options
  • Save bergmeister/825c59b25670046ac586bb8bb0d062dd to your computer and use it in GitHub Desktop.
Save bergmeister/825c59b25670046ac586bb8bb0d062dd to your computer and use it in GitHub Desktop.
Remove AAS IP Firewall exception and remove currently executing service principal from AAS admin list
[CmdletBinding()]
Param(
[Parameter(Mandatory)]
[string] $ResourceGroupName
)
# Remove currently executing service principal from AAS admin list
$azAnalysisServicesServer = Get-AzAnalysisServicesServer -ResourceGroupName $ResourceGroupName
$azContext = Get-Azcontext
$spApplicationId = ($azContext).Account.Id
$azAnalysisServicesServer.AsAdministrators.Remove("app:$spApplicationId@$($azContext.Tenant.Id)")
Set-AzAnalysisServicesServer -Administrator ([string]::Join(',', $azAnalysisServicesServer.AsAdministrators)) -Name $azAnalysisServicesServer.Name
# Remove temporarily addded firewall exception (if it exists)
$azAnalysisServicesServer.FirewallConfig.FirewallRules = $azAnalysisServicesServer.FirewallConfig.FirewallRules | Where-Object { -not $_.FirewallRuleName.StartsWith('az-devops-hosted-agent') }
Set-AzAnalysisServicesServer -FirewallConfig $azAnalysisServicesServer.FirewallConfig -Name $azAnalysisServicesServer.Name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment