I'm trying to figure out how to combine 2 arrays as explained here by Microsoft.
$Source = 'S:\Test\Out_Test\Departments'
$Array = Get-ChildItem $Source -Recurse
$Array.FullName | Measure-Object # 85
$Array.FullName + $Source | Measure-Object # 86
$Source + $Array.FullName | Measure-Object # 1
The following only has 1 item to iterate through:
$i = 0
foreach ($t in ($Source + $Array.FullName)) {
$i++
"Count is $i"
$t
}
My problem is that if $Source or $Array is empty, it doesn't generate seperate objects anymore and sticks it all together as seen in the previous example. Is there a way to force it into separate objects and not into one concatenated one?
@($Source;$Array.FullName)