src/Organization/Get-XrmOrganizationClientFeatures.ps1
|
<# .SYNOPSIS Get Organization Client Features. .DESCRIPTION Retrieve all or specified client features from default organization (see : Get-XrmOrganization) .PARAMETER XrmClient Xrm connector initialized to target instance. Use latest one by default. (Dataverse ServiceClient) .PARAMETER Name Client feature name to retrieve. (Default: all client features) .OUTPUTS System.Collections.Hashtable. Client feature values (string) by name, read from the clientfeatureset column. Empty when the organization has none or Name is not defined. .EXAMPLE $clientFeatures = Get-XrmOrganizationClientFeatures -XrmClient $xrmClient; $clientFeatures.GetEnumerator() | Sort-Object -Property Name; .LINK https://github.com/AymericM78/PowerDataOps/blob/main/documentation/commands/Get-XrmOrganizationClientFeatures.md #> function Get-XrmOrganizationClientFeatures { [CmdletBinding()] [OutputType([Hashtable])] param ( [Parameter(Mandatory = $false, ValueFromPipeline)] [Microsoft.PowerPlatform.Dataverse.Client.ServiceClient] $XrmClient = $Global:XrmClient, [Parameter(Mandatory = $false)] [ValidateNotNullOrEmpty()] [String] $Name ) begin { $StopWatch = [System.Diagnostics.Stopwatch]::StartNew(); Trace-XrmFunction -Name $MyInvocation.MyCommand.Name -Stage Start -Parameters ($MyInvocation.MyCommand.Parameters); } process { $organization = $XrmClient | Get-XrmOrganization -Columns "clientfeatureset"; $features = @{}; if ($organization.clientfeatureset) { $featuresXml = [xml] $organization.clientfeatureset; if ($Name) { $feature = $featuresXml.clientfeatures.clientfeature | where-object -Property name -eq $Name; if ($feature) { $features[$feature.name] = $feature.value; } } else { foreach ($feature in $featuresXml.clientfeatures.clientfeature) { $features[$feature.name] = $feature.value; } } } return $features; } end { $StopWatch.Stop(); Trace-XrmFunction -Name $MyInvocation.MyCommand.Name -Stage Stop -StopWatch $StopWatch; } } Export-ModuleMember -Function Get-XrmOrganizationClientFeatures -Alias *; |