public/Get-WorkdayWorkerNationalId.ps1
function Get-WorkdayWorkerNationalId { <# .SYNOPSIS Returns a Worker's National Id information. .DESCRIPTION Returns a Worker's National Id information as custom Powershell objects. .PARAMETER WorkerId The Worker's Id at Workday. .PARAMETER WorkerType The type of ID that the WorkerId represents. Valid values are 'WID', 'Contingent_Worker_ID' and 'Employee_ID'. .PARAMETER Human_ResourcesUri Human_Resources Endpoint Uri for the request. If not provided, the value stored with Set-WorkdayEndpoint -Endpoint Human_Resources is used. .PARAMETER Username Username used to authenticate with Workday. If empty, the value stored using Set-WorkdayCredential will be used. .PARAMETER Password Password used to authenticate with Workday. If empty, the value stored using Set-WorkdayCredential will be used. .EXAMPLE Get-WorkdayWorkerNationalId -WorkerId 123 Type Id Descriptor ---- -- ---------- USA-SSN 000000000 000-00-0000 (USA-SSN) #> [CmdletBinding(DefaultParametersetName='Search')] [OutputType([PSCustomObject])] param ( [Parameter(Mandatory = $true, Position=0, ParameterSetName='Search')] [ValidatePattern ('^[a-fA-F0-9\-]{1,32}$')] [string]$WorkerId, [Parameter(ParameterSetName="Search")] [ValidateSet('WID', 'Contingent_Worker_ID', 'Employee_ID')] [string]$WorkerType = 'Employee_ID', [Parameter(ParameterSetName="Search")] [string]$Human_ResourcesUri, [Parameter(ParameterSetName="Search")] [string]$Username, [Parameter(ParameterSetName="Search")] [string]$Password, [Parameter(ParameterSetName="NoSearch")] [xml]$WorkerXml, [Alias("Force")] [switch]$IncludeInactive ) if ([string]::IsNullOrWhiteSpace($Human_ResourcesUri)) { $Human_ResourcesUri = $WorkdayConfiguration.Endpoints['Human_Resources'] } if ($PsCmdlet.ParameterSetName -eq 'Search') { $response = Get-WorkdayWorker -WorkerId $WorkerId -WorkerType $WorkerType -IncludePersonal -Human_ResourcesUri $Human_ResourcesUri -Username:$Username -Password:$Password -IncludeInactive:$IncludeInactive -ErrorAction Stop $WorkerXml = $response.Xml } if ($WorkerXml -eq $null) { Write-Warning 'Unable to get National Id information, Worker not found.' return } $numberTemplate = [pscustomobject][ordered]@{ Type = $null Id = $null Descriptor = $null WID = $null } $WorkerXml.GetElementsByTagName('wd:National_ID') | ForEach-Object { $o = $numberTemplate.PsObject.Copy() $typeXml = $_.National_ID_Data.ID_Type_Reference.ID | Where-Object {$_.type -eq 'National_ID_Type_Code'} $o.Type = $typeXml.'#text' $o.Id = $_.National_ID_Data.ID $o.Descriptor = $_.National_ID_Reference.Descriptor $o.WID = $_.National_ID_Reference.ID | Where-Object {$_.type -eq 'WID'} | Select-Object -ExpandProperty '#text' Write-Output $o } } |