<# .PARAMETER editorId to filter by editorId .PARAMETER formId to filter by formId .PARAMETER all to list all records .PARAMETER slotAsArray convert slot field to array .PARAMETER splitBySlot split records by slot .EXAMPLE PS> .\get-armor.ps1 | ?{ $_.FormID -in '00013939' } | .\get-armoraddon.ps1 .EXAMPLE PS> .\get-armoraddon.ps1 -formId 0005DB82 .EXAMPLE PS> .\get-armor.ps1 -editorId EnchArmorImperialLightGauntletsMarksman03|.\get-armoraddon.ps1 .EXAMPLE PS> .\armor-by-keyword.ps1 ArmorHeavy|?{$_.Keywords -contains 'ArmorHelmet'}|.\get-armoraddon.ps1 #> param([string]$editorId, [string]$formId, [switch]$all, [switch]$slotAsArray, [switch]$splitBySlot) # editorId or formId to filter # -all to list all records #usage: ## .\get-armor.ps1 | ?{ $_.FormID -in '00013939' } | .\get-armoraddon.ps1 ## .\get-armoraddon.ps1 -formId 0005DB82 ## .\get-armor.ps1 -editorId EnchArmorImperialLightGauntletsMarksman03|.\get-armoraddon.ps1 ## .\armor-by-keyword.ps1 ArmorHeavy|?{$_.Keywords -contains 'ArmorHelmet'}|.\get-armoraddon.ps1 Set-StrictMode -Version 3.0 $csvDir=(Join-Path $PSScriptRoot ..) $myInput = $input $ids=@() $inObjs=@{} foreach($i in $myInput) { foreach($a in $i.ArmorAddon) { $ids+=$a; if($inObjs.ContainsKey($a)) { $inObjs[$a]=$i } else { $inObjs.Add($a, $i) } } } $csvDir=(Join-Path $PSScriptRoot ..) $csvFile="ArmorExport-ArmorAddon.csv" if($splitBySlot) { $csvFile="ArmorExport-ArmorAddon-Slot.csv" } if($editorId -or $formId) { Get-Content (Join-Path $csvDir $csvFile)|ConvertFrom-Csv -Delimiter ';' ` |where-object { ($editorId -and $_.EditorID -eq $editorId) -or ($formId -and $_.FormID -eq $formId)} ` |foreach-object { ` if($slotAsArray -and !$splitBySlot) { $_.Slot = ($_.Slot -Split ','); } ` $_.AdditionalRaces = ($_.AdditionalRaces -Split ','); ` $_ ` } } elseif($ids.Length -gt 0) { Get-Content (Join-Path $csvDir $csvFile)|ConvertFrom-Csv -Delimiter ';' ` |where-object { $ids -contains $_.EditorID } ` |foreach-object { ` if($slotAsArray -and !$splitBySlot) { $_.Slot = ($_.Slot -Split ','); } ` $_.AdditionalRaces = ($_.AdditionalRaces -Split ','); ` $_ } ` |foreach-object { Add-Member -InputObject $_ -MemberType NoteProperty -Name _ArmoRef ` -Value "$($inObjs[$_.EditorID].EditorID) `"$($inObjs[$_.EditorID].Name)`" [$($inObjs[$_.EditorID].RecordType):$($inObjs[$_.EditorID].FormID)]"; ` $_ } } elseif($all) { Get-Content (Join-Path $csvDir $csvFile)|ConvertFrom-Csv -Delimiter ';' ` |foreach-object { ` if($slotAsArray -and !$splitBySlot) { $_.Slot = ($_.Slot -Split ','); } ` $_.AdditionalRaces = ($_.AdditionalRaces -Split ','); ` $_ } }