Public/Get-AutotaskEntityUDFObject.ps1
<#
.Synopsis .DESCRIPTION .EXAMPLE Example of how to use this cmdlet .EXAMPLE Another example of how to use this cmdlet .INPUTS Inputs to this cmdlet (if any) .OUTPUTS Output from this cmdlet (if any) .NOTES General notes .COMPONENT The component this cmdlet belongs to .ROLE The role this cmdlet belongs to .FUNCTIONALITY The functionality that best describes this cmdlet #> function Get-AutotaskEntityUDFObject { [CmdletBinding()] Param ( # Autotask Installed Product entity (MPC) [Parameter(Mandatory=$true, ValueFromPipeline=$true, Position=0) ] $entity ) if($entity.count -gt 1){ Write-Error "Cannot extract UDF fields from more than one entity." } $UDF = New-Object -TypeName PSObject $verbosemessage = "Enumerates UserDefinedFields in input entity." Write-Verbose $verbosemessage foreach ($item in $entity.UserDefinedFields.GetEnumerator()){ $UDF | Add-Member -MemberType NoteProperty -Name $item.Name -Value $item.Value } $verbosemessage = "Returns PSObject with UserDefinedFields from input entity as properties." Write-Verbose $verbosemessage return $UDF } |