Skip to content

Commit

Permalink
Usability Params for Set-EntraUserExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuel-karanja committed Oct 18, 2024
1 parent 8cf8c47 commit dd67223
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 5 deletions.
109 changes: 109 additions & 0 deletions module/Entra/customizations/Set-EntraUserExtension.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# ------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
# ------------------------------------------------------------------------------
@{
SourceName = "Set-AzureADUserExtension"
TargetName = $null
Parameters = $null
Outputs = $null
CustomScript = @'
[CmdletBinding(DefaultParameterSetName = '')]
param (
[Alias('ObjectId')]
[Parameter(ParameterSetName = "SetSingle", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[Parameter(ParameterSetName = "SetMultiple", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $UserId,
[Parameter(ParameterSetName = "SetMultiple", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.Collections.Generic.Dictionary`2[System.String,System.String]] $ExtensionNameValues,
[Parameter(ParameterSetName = "SetSingle", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $ExtensionValue,
[Parameter(ParameterSetName = "SetSingle", Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[System.String] $ExtensionName
)
PROCESS {
$params = @{}
$customHeaders = New-EntraCustomHeaders -Command $MyInvocation.MyCommand
if ($null -ne $PSBoundParameters["UserId"])
{
$params["UserId"] = $PSBoundParameters["UserId"]
}
if ($null -ne $PSBoundParameters["ProgressAction"])
{
$params["ProgressAction"] = $PSBoundParameters["ProgressAction"]
}
if ($null -ne $PSBoundParameters["WarningVariable"])
{
$params["WarningVariable"] = $PSBoundParameters["WarningVariable"]
}
if ($null -ne $PSBoundParameters["ExtensionNameValues"])
{
$params["ExtensionNameValues"] = $PSBoundParameters["ExtensionNameValues"]
}
if ($null -ne $PSBoundParameters["ExtensionValue"])
{
$params["ExtensionValue"] = $PSBoundParameters["ExtensionValue"]
}
if ($null -ne $PSBoundParameters["PipelineVariable"])
{
$params["PipelineVariable"] = $PSBoundParameters["PipelineVariable"]
}
if ($null -ne $PSBoundParameters["ExtensionName"])
{
$params["ExtensionName"] = $PSBoundParameters["ExtensionName"]
}
if ($null -ne $PSBoundParameters["OutBuffer"])
{
$params["OutBuffer"] = $PSBoundParameters["OutBuffer"]
}
if ($null -ne $PSBoundParameters["ErrorVariable"])
{
$params["ErrorVariable"] = $PSBoundParameters["ErrorVariable"]
}
if ($null -ne $PSBoundParameters["ErrorAction"])
{
$params["ErrorAction"] = $PSBoundParameters["ErrorAction"]
}
if ($null -ne $PSBoundParameters["InformationVariable"])
{
$params["InformationVariable"] = $PSBoundParameters["InformationVariable"]
}
if ($null -ne $PSBoundParameters["InformationAction"])
{
$params["InformationAction"] = $PSBoundParameters["InformationAction"]
}
if ($null -ne $PSBoundParameters["WarningAction"])
{
$params["WarningAction"] = $PSBoundParameters["WarningAction"]
}
if ($null -ne $PSBoundParameters["OutVariable"])
{
$params["OutVariable"] = $PSBoundParameters["OutVariable"]
}
if($PSBoundParameters.ContainsKey("Debug"))
{
$params["Debug"] = $PSBoundParameters["Debug"]
}
if($PSBoundParameters.ContainsKey("Verbose"))
{
$params["Verbose"] = $PSBoundParameters["Verbose"]
}
Write-Debug("============================ TRANSFORMATIONS ============================")
$params.Keys | ForEach-Object {"$_ : $($params[$_])" } | Write-Debug
Write-Debug("=========================================================================`n")
$response = Update-MgUserExtension @params -Headers $customHeaders
$response | ForEach-Object {
if($null -ne $_) {
Add-Member -InputObject $_ -MemberType AliasProperty -Name UserId -Value Id
}
}
$response
}
'@
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Sets a user extension.

```powershell
Set-EntraUserExtension
-ObjectId <String>
-UserId <String>
[<CommonParameters>]
```

Expand All @@ -41,7 +41,7 @@ The `Set-EntraUserExtension` cmdlet updates a user extension in Microsoft Entra
```powershell
Connect-Entra -Scopes 'User.ReadWrite.All'
$params = @{
ObjectId = '[email protected]'
UserId = '[email protected]'
ExtensionName = 'extension_e5e29b8a85d941eab8d12162bd004528_extensionAttribute8'
ExtensionValue = 'New Value'
}
Expand All @@ -50,15 +50,15 @@ Set-EntraUserExtension @params

This example shows how to update the value of the extension attribute for a specified user.

- `-ObjectId` parameter specifies the user Id.
- `-UserId` parameter specifies the user Id.
- `-ExtensionName` parameter specifies the name of an extension.
- `-ExtensionValue` parameter specifies the extension name values.

## Parameters

### -ObjectId
### -UserId

Specifies the ID of an object.
Specifies the ID of the user.

```yaml
Type: System.String
Expand Down

0 comments on commit dd67223

Please sign in to comment.