Adding PSCustomObject to Array gives Error, but works fine when debugging the code in Visual Studio Code
问题 When reading data from a CSV file and then trying to add a new custom object to the list I get an error when running the script, but when I try to debug the code I works as intended, and I can't figure out why it does work in debug mode, but not when run normally. $global:scanTime = Get-date $script:logfile_Database = Import-Csv -Path "${logSpace}\${CSV_logfileData}" -Delimiter ";" $currentLogfile = Get-ChildItem -Path "$($logfile.Path)\$($logfile.FileName)" -ErrorAction Stop $logfile_Data =