Created
September 24, 2020 17:47
-
-
Save ivangeorgiev/7f336267e14565c09af5c724248535e3 to your computer and use it in GitHub Desktop.
Azure Active Directory (AD) With PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Add Application Registration Owner | |
#> | |
function Add-AzAdApplicationUserOwnerXYZ($ApplicationName, $UserName) { | |
$ApplicationId = (Get-AzureADApplication -SearchString $ApplicationName).ObjectId | |
if (!$ApplicationId) { Throw "Unable to find application $ApplicationName" } | |
$UserId = (Get-AzureADUser -ObjectId $UserName).ObjectId | |
if (!$UserId) { Throw "Unable to find user $UserId" } | |
Add-AzureADApplicationOwner -ObjectId $ApplicationId -RefObjectId $UserId | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Add Service Principal Owner | |
#> | |
function Add-AzAdServicePrincipalUserOwnerXYZ($ApplicationName, $UserName) { | |
$ApplicationId = (Get-AzureADApplication -SearchString $ApplicationName).ObjectId | |
if (!$ApplicationId) { Throw "Unable to find application $ApplicationName" } | |
$UserId = (Get-AzureADUser -ObjectId $UserName).ObjectId | |
if (!$UserId) { Throw "Unable to find user $UserId" } | |
Add-AzureADServicePrincipalOwner -ObjectId $ApplicationId -RefObjectId $UserId | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Remove Application Registration Owner | |
#> | |
function Remove-AzAdApplicationUserOwnerXYZ($ApplicationName, $UserName) { | |
$ApplicationId = (Get-AzureADApplication -SearchString $ApplicationName).ObjectId | |
if (!$ApplicationId) { Throw "Unable to find application $ApplicationName" } | |
$UserId = (Get-AzureADUser -ObjectId $UserName).ObjectId | |
if (!$UserId) { Throw "Unable to find user $UserId" } | |
Remove-AzureADApplicationOwner -ObjectId $ApplicationId -OwnerId $UserId | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Remove Service Principal Owner | |
#> | |
function Remove-AzAdServicePrincipalUserOwnerXYZ($ApplicationName, $UserName) { | |
$ApplicationId = (Get-AzureADApplication -SearchString $ApplicationName).ObjectId | |
if (!$ApplicationId) { Throw "Unable to find application $ApplicationName" } | |
$UserId = (Get-AzureADUser -ObjectId $UserName).ObjectId | |
if (!$UserId) { Throw "Unable to find user $UserId" } | |
Remove-AzureADServicePrincipalOwner -ObjectId $ApplicationId -OwnerId $UserId | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment