# Get Excel ready
$Excel = New-Object -comobject Excel.Application
$Excel.visible = $True
$Workbook = $Excel.Workbooks.Add()
$Info = $Workbook.Worksheets.Item(1)
# Create our column headers
$Info.Cells.Item(1,1) = "Computer Name"
$Info.Cells.Item(1,2) = "SDK Components Security Updates"
$Info.Cells.Item(1,3) = "SQL Server Security Updates"
$Info.Cells.Item(1,4) = "Windows Security Updates"
$Info.Cells.Item(1,5) = "BizTalk Server Security Updates"
$Info.Cells.Item(1,6) = "Exchange Security Updates"
$Info.Cells.Item(1,7) = "Office Security Updates"
# Add a little formatting
$Style = $Info.UsedRange
$Style.Interior.ColorIndex = 19
$Style.Font.ColorIndex = 11
$Style.Font.Bold = $True
$intRow = 2
# iterate over each .mbsa file
foreach ($file in $file)
{
[XML]$ScanResult = Get-Content "C:\SecurityScans"
$Scanned = $ScanResult.SecScan.Check | select Name, Advice
$Server = $ScanResult.SecScan.Machine
foreach($Scan in $Scanned)
{
# if Advice doesn't start with a numeric value then set it equal to 0
if( $Scan.Advice -match '^(?<Cnt>[0-9]*)'){$Advice=$matches.cnt} else{$Advice=0}
$Style.Cells.Item($intRow, 1) = $Server
switch ($Scan.Name)
{
"SDK Components Security Updates" {$Style.Cells.Item($intRow, 2) = $Advice;break}
"SQL Server Security Updates" {$Style.Cells.Item($intRow, 3) = $Advice;break}
"Windows Security Updates" {$Style.Cells.Item($intRow, 4) = $Advice;break}
"BizTalk Server Security Updates" {$Style.Cells.Item($intRow, 5) = $Advice;break}
"Exchange Security Updates" {$Style.Cells.Item($intRow, 6) = $Advice;break}
"Office Security Updates" {$Style.Cells.Item($intRow, 7) = $Advice;break}
}
}
$intRow = $intRow + 1
}
ASKER
$files = Get-ChildItem -path 'C:\users\admin\SecurityScans'
# Get Excel ready
$Excel = New-Object -comobject Excel.Application
$Excel.visible = $True
$Workbook = $Excel.Workbooks.Add()
$Info = $Workbook.Worksheets.Item(1)
# Create our column headers
$Info.Cells.Item(1,1) = "Computer Name"
$Info.Cells.Item(1,2) = "SDK Components Security Updates"
$Info.Cells.Item(1,3) = "SQL Server Security Updates"
$Info.Cells.Item(1,4) = "Windows Security Updates"
$Info.Cells.Item(1,5) = "BizTalk Server Security Updates"
$Info.Cells.Item(1,6) = "Exchange Security Updates"
$Info.Cells.Item(1,7) = "Office Security Updates"
# Add a little formatting
$Style = $Info.UsedRange
$Style.Interior.ColorIndex = 19
$Style.Font.ColorIndex = 11
$Style.Font.Bold = $True
$intRow = 2
# iterate over each .mbsa file
foreach ($file in $files)
{
[XML]$ScanResult = Get-Content $Files
$Scanned = $ScanResult.SecScan.Check | select Name, Advice
$Server = $ScanResult.SecScan.Machine
foreach($Scan in $Scanned)
{
# if Advice doesn't start with a numeric value then set it equal to 0
if( $Scan.Advice -match '^(?<Cnt>[0-9]*)'){$Advice=$matches.cnt} else{$Advice=0}
$Style.Cells.Item($intRow, 1) = $Server
switch ($Scan.Name)
{
"SDK Components Security Updates" {$Style.Cells.Item($intRow, 2) = $Advice;break}
"SQL Server Security Updates" {$Style.Cells.Item($intRow, 3) = $Advice;break}
"Windows Security Updates" {$Style.Cells.Item($intRow, 4) = $Advice;break}
"BizTalk Server Security Updates" {$Style.Cells.Item($intRow, 5) = $Advice;break}
"Exchange Security Updates" {$Style.Cells.Item($intRow, 6) = $Advice;break}
"Office Security Updates" {$Style.Cells.Item($intRow, 7) = $Advice;break}
}
}
$intRow = $intRow + 1
}
ASKER
ASKER
Most development for the Microsoft platform is done utilizing the technologies supported by the.NET framework. Other development is done using Visual Basic for Applications (VBA) for programs like Access, Excel, Word and Outlook, with PowerShell for scripting, or with SQL for large databases.
TRUSTED BY
Open in new window
However, there is another typo in the foreach line (25) - you are using the same var as foreach var and files array. I reckon that line should be:Open in new window