Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Script:
# Load the Excel COM object
$excel = New-Object -ComObject Excel.Application
# Add a new workbook
$workbook = $excel.Workbooks.Add()
# Save the workbook to a specified path
$path = "C:\Path\To\Your\NewExcelFile.xlsx"
$workbook.SaveAs($path)
# Close the workbook
$workbook.Close($false)
# Quit the Excel application
$excel.Quit()
# Release the COM objects
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($workbook) | Out-Null
[System.Runtime.InteropServices.Marshal]::ReleaseComObject($excel) | Out-Null
# Collect garbage
[GC]::Collect()
[GC]::WaitForPendingFinalizers()
Write-Output "New Excel file created at: $path"
Como Executar o Script:
.ps1
, por exemplo, CreateNewExcelFile.ps1
..\CreateNewExcelFile.ps1
e pressione Enter.