Return a reference to an Excel Worksheet from a PowerShell Function
问题 For the sake of code readability, I'd like to move my Excel stuff to a function and leave the worksheet object available to write cell values as my program processes stuff. How do I call a function that creates an Excel spreadsheet and return a worksheet reference so I can continue to access the open/active Excel app object I've created? Function Create-Excel-Spreadsheet() { # open excel $excel = New-Object -ComObject excel.application $excel.visible = $True # add a worksheet $workbook =