Public/NamingContexts/Set-R1NamingContextLabelProperty.ps1
|
# .ExternalHelp psRadiantOne-help.xml function Set-R1NamingContextLabelProperty { [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] [OutputType([void])] param( [parameter( Mandatory = $true, ValueFromPipelineByPropertyName = $true )] [ValidateNotNullOrEmpty()] [string]$dn, [parameter( Mandatory = $false, ValueFromPipelineByPropertyName = $true )] [ValidateLength(1, 1000)] [string]$rdnPrefix, [parameter( Mandatory = $false, ValueFromPipelineByPropertyName = $true )] [ValidateLength(1, 1000)] [string]$rdnSuffix, [parameter( Mandatory = $false, ValueFromPipelineByPropertyName = $true )] [ValidateNotNullOrEmpty()] [string[]]$objectClasses, [parameter( Mandatory = $false, ValueFromPipelineByPropertyName = $true )] [AllowEmptyString()] [string]$description, [parameter( Mandatory = $false, ValueFromPipelineByPropertyName = $true )] [AllowEmptyCollection()] [object[]]$virtualAttributes ) Begin { Assert-R1Session -RequireToken }#begin Process { $URI = Resolve-R1ServiceUrl -Service Namespace -Path "naming_contexts/$($dn | Get-EscapedString)/label/properties" #Retrieve the current properties and send them back with the supplied values applied over #them, so a property left unspecified keeps its current value. $Existing = Get-R1NamingContextLabelProperty -dn $dn $Template = [ordered]@{ rdnPrefix = $null rdnSuffix = $null objectClasses = @() description = '' virtualAttributes = @() } $Request = Merge-R1Parameter -Template $Template -BoundParameter ($PSBoundParameters | Get-Parameter -ParametersToRemove dn) -Fallback $Existing foreach ($Property in 'objectClasses', 'virtualAttributes') { $Request[$Property] = @($Request[$Property] | Where-Object { $null -ne $_ }) } $Body = $Request | ConvertTo-R1JsonBody -EmptyArrayProperty objectClasses, virtualAttributes if ($PSCmdlet.ShouldProcess($dn, 'Update Label Properties')) { $null = Invoke-R1RestMethod -Uri $URI -Method PUT -Body $Body } }#process End { }#end } |