Use ConvertTo-PSFHashtable for splatting in Get-D365Environment (#870)#911
Conversation
|
@pavankadabala-png Thanks for cleaning this up, looks good. Since it is probably the same pattern in all the files, I would prefer if we could do it all in one pr, even if this touches multiple files. |
|
Makes sense — done. I've expanded the PR to apply the same
In each case the resulting splat hashtable is identical to what the manual removals produced — the keys that were stripped are exactly the caller-only parameters that aren't parameters of the reference command. |
|
@pavankadabala-png Thanks. Found one more, the |
What this does
Applies the first of the PSFramework quick-wins from #870 (suggested by @FriedrichWeinmann): replaces the manual
Get-DeepClone $PSBoundParameters+.Remove(...)splatting pattern inGet-D365EnvironmentwithConvertTo-PSFHashtable -ReferenceCommand.Why it's equivalent
ConvertTo-PSFHashtable -ReferenceCommand Get-ServiceListkeeps only the keys that are parameters ofGet-ServiceList. ForGet-D365Environmentthat is exactlyAll, Aos, Batch, DMF, FinancialReporter— the same set the manual code produced by removingComputerName,OutputServiceDetailsOnlyandOnlyStartTypeAutomatic. As a bonus it also drops any other non-matching parameter automatically, so the filtering stays correct if parameters change later.ConvertTo-PSFHashtableand its-ReferenceCommandparameter are available in the module's minimum required PSFramework version (1.9.308), so no dependency bump is needed.Scope
Kept to a single file per the contributing guidelines. The same pattern applies to the sibling
*-D365Environmentcmdlets and a couple of internal SQL helpers (Get-SqlCommandcallers) — happy to follow up with those in separate PRs.Refs #870