I have created the following Function which will export the values of an array to Excel, but it only exports the first element.
Function Export_Excel ($Array,$Column,$Sheet) {
[System.Threading.Thread]::CurrentThread.CurrentCulture = "en-US"
[System.Threading.Thread]::CurrentThread.CurrentUICulture = "en-US"
$Global:sheet = $Global:wkbk.WorkSheets.Item("$Sheet")
$intRow = 3
$LastRow = $Array.count + 2
$Range = "$Column" + $intRow +":$Column" + "$LastRow"
$RangeSet = $Global:sheet.Range("$Range")
$RangeSet.Value2 = $Array
[gc]::collect()
[gc]::WaitForPendingFinalizers()
[System.Threading.Thread]::CurrentThread.CurrentCulture = $Global:OldCulture
[System.Threading.Thread]::CurrentThread.CurrentUICulture = $Global:OldUICulture
}
My array is generated with $Array+=$ValueForArray.
When I execute
Export_Excel $Array "B" "Sheet1"
it exports for the entire length of the array only the first element in each cell. Can anybody see what I'm doing wrong?

$Array = @()?