Skip to content

Commit

Permalink
Set-AzureADMSServicePrincipal (#271)
Browse files Browse the repository at this point in the history
* Added customscript for Set-AzureADMSServicePrincipal
* Set-AzureADMSServicePrincipal
  • Loading branch information
v-akarke authored Jan 10, 2024
1 parent ea2ae08 commit f64dbc8
Showing 1 changed file with 135 additions and 0 deletions.
135 changes: 135 additions & 0 deletions module/AzureADPreview/customizations/Set-AzureADMSServicePrincipal.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
# ------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
# ------------------------------------------------------------------------------
@{
SourceName = "Set-AzureADMSServicePrincipal"
TargetName = $null
Parameters = $null
Outputs = $null
CustomScript = @'
PROCESS {
$params = @{}
$body = @{}
$Web = @{}
$keysChanged = @{ObjectId = "Id"}
if($null -ne $PSBoundParameters["AccountEnabled"])
{
$body["AccountEnabled"] = $PSBoundParameters["AccountEnabled"]
}
if($null -ne $PSBoundParameters["Tags"])
{
$body["Tags"] = $PSBoundParameters["Tags"]
}
if($PSBoundParameters.ContainsKey("Verbose"))
{
$params["Verbose"] = $Null
}
if($null -ne $PSBoundParameters["DisplayName"])
{
$body["DisplayName"] = $PSBoundParameters["DisplayName"]
}
if($null -ne $PSBoundParameters["AppId"])
{
$body["AppId"] = $PSBoundParameters["AppId"]
}
if($PSBoundParameters.ContainsKey("Debug"))
{
$params["Debug"] = $Null
}
if($null -ne $PSBoundParameters["ErrorUrl"])
{
$params["ErrorUrl"] = $PSBoundParameters["ErrorUrl"]
}
if($null -ne $PSBoundParameters["KeyCredentials"])
{
$a = @()
$inpu = $PSBoundParameters["KeyCredentials"]
foreach($value in $inpu)
{
$hash = @{
CustomKeyIdentifier= $value.CustomKeyIdentifier
EndDateTime = $value.EndDate
Key= $value.Value
StartDateTime= $value.StartDate
Type= $value.Type
Usage= $value.Usage
}
$a += $hash
}
$params["KeyCredentials"] = $a
}
if($null -ne $PSBoundParameters["ReplyUrls"])
{
$params["ReplyUrls"] = $PSBoundParameters["ReplyUrls"]
}
if($null -ne $PSBoundParameters["Id"])
{
$params["ServicePrincipalId"] = $PSBoundParameters["Id"]
}
if($null -ne $PSBoundParameters["LogoutUrl"])
{
$params["LogoutUrl"] = $PSBoundParameters["LogoutUrl"]
}
if($null -ne $PSBoundParameters["SamlMetadataUrl"])
{
$params["SamlMetadataUrl"] = $PSBoundParameters["SamlMetadataUrl"]
}
if($null -ne $PSBoundParameters["Homepage"])
{
$params["HomePage"] = $PSBoundParameters["Homepage"]
}
if($null -ne $PSBoundParameters["AppRoleAssignmentRequired"])
{
$body["AppRoleAssignmentRequired"] = $PSBoundParameters["AppRoleAssignmentRequired"]
}
if($null -ne $PSBoundParameters["PasswordCredentials"])
{
$a = @()
$inpu = $PSBoundParameters["PasswordCredentials"]
foreach($value in $inpu)
{
$hash = @{
CustomKeyIdentifier= $value.CustomKeyIdentifier
EndDateTime = $value.EndDate
SecretText= $value.Value
StartDateTime= $value.StartDate
}
$a += $hash
}
$params["PasswordCredentials"] = $a
}
if($null -ne $PSBoundParameters["PublisherName"])
{
$params["PublisherName"] = $PSBoundParameters["PublisherName"]
}
if($null -ne $PSBoundParameters["ServicePrincipalNames"])
{
$body["ServicePrincipalNames"] = $PSBoundParameters["ServicePrincipalNames"]
}
if($null -ne $PSBoundParameters["PreferredTokenSigningKeyThumbprint"])
{
$body["PreferredTokenSigningKeyThumbprint"] = $PSBoundParameters["PreferredTokenSigningKeyThumbprint"]
}
if($null -ne $PSBoundParameters["CustomSecurityAttributes"])
{
$params["CustomSecurityAttributes"] = $PSBoundParameters["CustomSecurityAttributes"]
}
if($body.Count -gt 0)
{
$params["BodyParameter"] = $body
}
Write-Debug("============================ TRANSFORMATIONS ============================")
$params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug
Write-Debug("=========================================================================
")
$response = Update-MgBetaServicePrincipal @params
$response | ForEach-Object {
if($null -ne $_) {
Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id
}
}
$response
}
'@
}

0 comments on commit f64dbc8

Please sign in to comment.