# Open Excel document
$ExcelDocument = New-Object -comobject Excel.Application
# Name the Excel document using seconds for testing at this point
$ExcelPath = "C:\ServerAudit_"+([datetime]::Now).tostring("yyyyMMddhhmmss")+".xlsx"
#Show the Excel Documents?
$ExcelDocument.visible = $True
#Display those pesky alerts?
$ExcelDocument.DisplayAlerts = $False
#Create a new Excel Document (aka WorkBook)
$Workbook = $ExcelDocument.Workbooks.Add()
#Create worksheet tabs for each server, since Excel starts with three, add tabs if we have more than three servers.
If ($b.count -le 3) {for ($j=1; $j -le ($b.count-3); $j++) {$Sheet = $Workbook.WorkSheets.add()}}
# Determine Number of Servers
$limit = $b.Count
# Write the Excel sheet tab names
For ($j=1; $j -le $limit; $j++)
{
Write-Host "Creating worksheet tab for ";$ServerList[$j]
$CurrentSheet = $Workbook.WorkSheets.Item($j)
$CurrentSheet.name = $ServerList[$j]
$CurrentSheet.application.activewindow.splitcolumn = 0
#Where we want to split the screen for scrolling in Excel
$CurrentSheet.application.activewindow.splitrow = 16
$CurrentSheet.application.activewindow.freezepanes = $true
}
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE