Private/Get-GlpiToolsConvertValues.ps1
<#
.SYNOPSIS Short description .DESCRIPTION Long description .EXAMPLE PS C:\> <example usage> Explanation of what the example does .INPUTS Inputs (if any) .OUTPUTS Output (if any) .NOTES PSP 05/2019 #> function Get-GlpiToolsConvertValues { [CmdletBinding()] param ( [parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = "ValueToConvert")] [alias('PTC')] [string]$ParameterToConvert, [parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = "ValueToConvert")] [AllowEmptyString()] [AllowEmptyCollection()] [alias('VTC')] [string]$ValueToConvert ) begin { $AppToken = $Script:AppToken $PathToGlpi = $Script:PathToGlpi $SessionToken = $Script:SessionToken $AppToken = Get-GlpiToolsConfig -Verbose:$false | Select-Object -ExpandProperty AppToken $PathToGlpi = Get-GlpiToolsConfig -Verbose:$false | Select-Object -ExpandProperty PathToGlpi $SessionToken = Set-GlpiToolsInitSession -Verbose:$false | Select-Object -ExpandProperty SessionToken $ConvertedArray = [System.Collections.Generic.List[psobject]]::new() } process { switch ($ParameterToConvert) { entities_id { $ConvertedValue = $ValueToConvert | Get-GlpiToolsEntities | Select-Object -ExpandProperty CompleteName } users_id { $ConvertedValue = $ValueToConvert | Get-GlpiToolsUsers | Select-Object realname, firstname | ForEach-Object { "{0} {1}" -f $_.firstname,$_.realname } } Default { $ConvertedValue = $ValueToConvert } } $ConvertedArray.Add( $ConvertedValue ) $ConvertedArray } end { Set-GlpiToolsKillSession -SessionToken $SessionToken -Verbose:$false } } |