PowerShell to SQL- Array function always return element 0 first

2014-11-15

Any Array value if you have like

$searcher.propertiesToLoad.Add("xxxxx")
$myarray.Columns.Add("DistinguishedName")

Always, Always put "| Out-Null" behind to prevent the null element feed Function first and get "False" then return "0" back.
So your Table doesn't need to add one more "Ghost" column

Reference websites:

Returning values from Fuctions in PowerShell... Tricky

Array size differs between return value

Issues to be aware of when transitioning from VBScript to PowerShell

Returning an exit code from a PowerShell script

 

 

Newer Older