-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New-EntraAdministrativeUnit improvements - additional params #1351
Open
SteveMutungi254
wants to merge
10
commits into
main
Choose a base branch
from
stevemutungi/New-EntraAdministrativeUnit
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4519c70
Added code logic, tests and docs
SteveMutungi254 a8af234
Fixed MS Graph API path
SteveMutungi254 0b58b80
Experiment - working with Graph generic object
SteveMutungi254 5f1e03a
Experiment - return without a Graph object
SteveMutungi254 d5979a6
Return filtered response
SteveMutungi254 f04d196
Clean-up
SteveMutungi254 b3b01ca
Minor formatting.
SteveMutungi254 4b5450a
Aligning outputs based on code implementation
SteveMutungi254 5802a97
Merge branch 'main' into stevemutungi/New-EntraAdministrativeUnit
SteveMutungi254 804bb67
Merge branch 'main' into stevemutungi/New-EntraAdministrativeUnit
SteveMutungi254 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
185 changes: 75 additions & 110 deletions
185
...le/EntraBeta/Microsoft.Entra.Beta/DirectoryManagement/New-EntraBetaAdministrativeUnit.ps1
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,119 +1,84 @@ | ||
# ------------------------------------------------------------------------------ | ||
# Copyright (c) Microsoft Corporation. All Rights Reserved. | ||
# Licensed under the MIT License. See License in the project root for license information. | ||
# ------------------------------------------------------------------------------ | ||
# ------------------------------------------------------------------------------ | ||
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information. | ||
# ------------------------------------------------------------------------------ | ||
function New-EntraBetaAdministrativeUnit { | ||
[CmdletBinding(DefaultParameterSetName = 'InvokeByDynamicParameters')] | ||
param ( | ||
|
||
[Parameter(ParameterSetName = "InvokeByDynamicParameters")] | ||
[System.String] $Description, | ||
|
||
[Parameter(ParameterSetName = "InvokeByDynamicParameters", Mandatory = $true)] | ||
[System.String] $DisplayName, | ||
|
||
[Parameter(ParameterSetName = "InvokeByDynamicParameters")] | ||
[System.String] $MembershipRule, | ||
|
||
[Parameter(ParameterSetName = "InvokeByDynamicParameters")] | ||
[System.Nullable`1[System.Boolean]] $IsMemberManagementRestricted, | ||
|
||
[Parameter(ParameterSetName = "InvokeByDynamicParameters")] | ||
[System.String] $MembershipRuleProcessingState, | ||
|
||
[Parameter(ParameterSetName = "InvokeByDynamicParameters")] | ||
[System.String] $MembershipType | ||
[Parameter(ParameterSetName = "InvokeByDynamicParameters", HelpMessage = "Description of the administrative unit.")] | ||
[System.String] $Description, | ||
|
||
[Parameter(ParameterSetName = "InvokeByDynamicParameters", Mandatory = $true, HelpMessage = "Display name of the administrative unit.")] | ||
[System.String] $DisplayName, | ||
|
||
[Parameter(ParameterSetName = "InvokeByDynamicParameters", HelpMessage = "Membership rule for the administrative unit.")] | ||
[System.String] $MembershipRule, | ||
|
||
[Parameter(ParameterSetName = "InvokeByDynamicParameters", HelpMessage = "Membership rule processing state for the administrative unit.")] | ||
[System.String] $MembershipRuleProcessingState, | ||
|
||
[Parameter(ParameterSetName = "InvokeByDynamicParameters", HelpMessage = "Membership type for the administrative unit.")] | ||
[System.String] $MembershipType, | ||
|
||
[Parameter(ParameterSetName = "InvokeByDynamicParameters", HelpMessage = "Visibility of the administrative unit.")] | ||
[System.String] $Visibility | ||
) | ||
|
||
PROCESS { | ||
$params = @{} | ||
$customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand | ||
|
||
if ($null -ne $PSBoundParameters["ProgressAction"]) | ||
{ | ||
$params["ProgressAction"] = $PSBoundParameters["ProgressAction"] | ||
} | ||
if($PSBoundParameters.ContainsKey("Debug")) | ||
{ | ||
$params["Debug"] = $PSBoundParameters["Debug"] | ||
} | ||
if ($null -ne $PSBoundParameters["OutBuffer"]) | ||
{ | ||
$params["OutBuffer"] = $PSBoundParameters["OutBuffer"] | ||
} | ||
if ($null -ne $PSBoundParameters["ErrorAction"]) | ||
{ | ||
$params["ErrorAction"] = $PSBoundParameters["ErrorAction"] | ||
} | ||
if ($null -ne $PSBoundParameters["WarningVariable"]) | ||
{ | ||
$params["WarningVariable"] = $PSBoundParameters["WarningVariable"] | ||
} | ||
if ($null -ne $PSBoundParameters["WarningAction"]) | ||
{ | ||
$params["WarningAction"] = $PSBoundParameters["WarningAction"] | ||
} | ||
if ($null -ne $PSBoundParameters["Description"]) | ||
{ | ||
$params["Description"] = $PSBoundParameters["Description"] | ||
} | ||
if ($null -ne $PSBoundParameters["DisplayName"]) | ||
{ | ||
$params["DisplayName"] = $PSBoundParameters["DisplayName"] | ||
} | ||
if ($null -ne $PSBoundParameters["OutVariable"]) | ||
{ | ||
$params["OutVariable"] = $PSBoundParameters["OutVariable"] | ||
} | ||
if ($null -ne $PSBoundParameters["MembershipRule"]) | ||
{ | ||
$params["MembershipRule"] = $PSBoundParameters["MembershipRule"] | ||
} | ||
if ($null -ne $PSBoundParameters["IsMemberManagementRestricted"]) | ||
{ | ||
$params["IsMemberManagementRestricted"] = $PSBoundParameters["IsMemberManagementRestricted"] | ||
} | ||
if($PSBoundParameters.ContainsKey("Verbose")) | ||
{ | ||
$params["Verbose"] = $PSBoundParameters["Verbose"] | ||
} | ||
if ($null -ne $PSBoundParameters["MembershipRuleProcessingState"]) | ||
{ | ||
$params["MembershipRuleProcessingState"] = $PSBoundParameters["MembershipRuleProcessingState"] | ||
} | ||
if ($null -ne $PSBoundParameters["PipelineVariable"]) | ||
{ | ||
$params["PipelineVariable"] = $PSBoundParameters["PipelineVariable"] | ||
} | ||
if ($null -ne $PSBoundParameters["InformationVariable"]) | ||
{ | ||
$params["InformationVariable"] = $PSBoundParameters["InformationVariable"] | ||
} | ||
if ($null -ne $PSBoundParameters["MembershipType"]) | ||
{ | ||
$params["MembershipType"] = $PSBoundParameters["MembershipType"] | ||
} | ||
if ($null -ne $PSBoundParameters["InformationAction"]) | ||
{ | ||
$params["InformationAction"] = $PSBoundParameters["InformationAction"] | ||
} | ||
if ($null -ne $PSBoundParameters["ErrorVariable"]) | ||
{ | ||
$params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"] | ||
} | ||
PROCESS { | ||
$params = @{} | ||
$body = @{} | ||
$customHeaders = New-EntraBetaCustomHeaders -Command $MyInvocation.MyCommand | ||
|
||
Write-Debug("============================ TRANSFORMATIONS ============================") | ||
$params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug | ||
Write-Debug("=========================================================================`n") | ||
|
||
$response = New-MgBetaAdministrativeUnit @params -Headers $customHeaders | ||
$response | ForEach-Object { | ||
if($null -ne $_) { | ||
Add-Member -InputObject $_ -MemberType AliasProperty -Name ObjectId -Value Id | ||
if ($null -ne $PSBoundParameters["Description"]) { | ||
$params["Description"] = $PSBoundParameters["Description"] | ||
$body["Description"] = $PSBoundParameters["Description"] | ||
} | ||
if ($null -ne $PSBoundParameters["DisplayName"]) { | ||
$params["DisplayName"] = $PSBoundParameters["DisplayName"] | ||
$body["DisplayName"] = $PSBoundParameters["DisplayName"] | ||
} | ||
if ($null -ne $PSBoundParameters["MembershipRule"]) { | ||
$params["MembershipRule"] = $PSBoundParameters["MembershipRule"] | ||
$body["MembershipRule"] = $PSBoundParameters["MembershipRule"] | ||
} | ||
if ($null -ne $PSBoundParameters["MembershipRuleProcessingState"]) { | ||
$params["MembershipRuleProcessingState"] = $PSBoundParameters["MembershipRuleProcessingState"] | ||
$body["MembershipRuleProcessingState"] = $PSBoundParameters["MembershipRuleProcessingState"] | ||
} | ||
if ($null -ne $PSBoundParameters["MembershipType"]) { | ||
$params["MembershipType"] = $PSBoundParameters["MembershipType"] | ||
$body["MembershipType"] = $PSBoundParameters["MembershipType"] | ||
} | ||
if ($null -ne $PSBoundParameters["Visibility"]) { | ||
$params["Visibility"] = $PSBoundParameters["Visibility"] | ||
$body["Visibility"] = $PSBoundParameters["Visibility"] | ||
} | ||
|
||
$uri = "/beta/administrativeUnits" | ||
$body = $body | ConvertTo-Json | ||
|
||
Write-Debug "============================ TRANSFORMATIONS ============================" | ||
$params.Keys | ForEach-Object { "$_ : $($params[$_])" } | Write-Debug | ||
Write-Debug "=========================================================================`n" | ||
|
||
$response = Invoke-GraphRequest -Headers $customHeaders -Uri $uri -Method POST -Body $body | ||
$response = $response | ConvertTo-Json | ConvertFrom-Json | ||
|
||
# Workaround for the issue with the response object - missing assembly reference | ||
$filteredResponse = $response | Select-Object -Property Id, DisplayName, Description, IsMemberManagementRestricted, MembershipRule, MembershipRuleProcessingState, MembershipType, Visibility | ||
$filteredResponse | ||
|
||
<# | ||
$auList = @() | ||
foreach ($data in $response) { | ||
$auType = New-Object Microsoft.Graph.Beta.Models.MicrosoftGraphAdministrativeUnit | ||
$data.PSObject.Properties | ForEach-Object { | ||
$propertyName = $_.Name | ||
$propertyValue = $_.Value | ||
$auType | Add-Member -MemberType NoteProperty -Name $propertyName -Value $propertyValue -Force | ||
} | ||
$auList += $auType | ||
} | ||
$auList | ||
#> | ||
} | ||
$response | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this section commented out?