Files
ImportExcel/Examples/New-PSItem.ps1
2019-11-21 17:29:58 +00:00

24 lines
575 B
PowerShell

function New-PSItem {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '', Justification='Does not change system state')]
param()
$totalArgs = $args.Count
if($args[-1] -is [array]) {
$script:PSItemHeader=$args[-1]
$totalArgs-=1
}
$h=[ordered]@{}
for ($idx = 0; $idx -lt $totalArgs; $idx+=1) {
if($PSItemHeader) {
$key = $PSItemHeader[$idx]
} else {
$key = "P$($idx+1)"
}
$h.$key=$args[$idx]
}
[PSCustomObject]$h
}