PoshCode Logo PowerShell Code Repository

Audit Script (modification of post by cassibr13 view diff)
diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/795"></script>download | new post

Thanks but that messed it up, I have fixed it now.

  1. #####################################################
  2. #                                                                                                       #
  3. #    Audit script by Alan Renouf - Virtu-Al         #
  4. #    Blog: http://teckinfo.blogspot.com/            #
  5. #                                                                                                       #
  6. #    Usage: Audit.ps1 'pathtolistofservers'         #
  7. #                                                                                                       #
  8. #    The file is optional and needs to be a             #
  9. #        plain text list of computers to be audited     #
  10. #        one on each line.                                                              #
  11. #                                                   #
  12. #####################################################
  13.  
  14. param( [string] $auditlist)
  15.  
  16. if ($auditlist -eq ""){
  17.         Write-Host "No list specified, using $env:computername"
  18.         $targets = $env:computername
  19. }
  20. else
  21. {
  22.         if ((Test-Path $auditlist) -eq $false)
  23.         {
  24.                 Write-Host "Invalid audit path specified: $auditlist"
  25.                 exit
  26.         }
  27.         else
  28.         {
  29.                 Write-Host "Using Audit list: $auditlist"
  30.                 $Targets = Get-Content $auditlist
  31.         }
  32. }
  33.  
  34. $Date = Get-Date
  35. Foreach ($Target in $Targets){
  36.         Write-Output "Collating Detail for $Target"
  37.         $ComputerSystem = Get-WmiObject -computername $Target Win32_ComputerSystem
  38.         switch ($ComputerSystem.DomainRole){
  39.                 0 { $ComputerRole = "Standalone Workstation" }
  40.                 1 { $ComputerRole = "Member Workstation" }
  41.                 2 { $ComputerRole = "Standalone Server" }
  42.                 3 { $ComputerRole = "Member Server" }
  43.                 4 { $ComputerRole = "Domain Controller" }
  44.                 5 { $ComputerRole = "Domain Controller" }
  45.                 default { $ComputerRole = "Information not available" }
  46.         }
  47.        
  48.         $OperatingSystems = Get-WmiObject -computername $Target Win32_OperatingSystem
  49.         $TimeZone = Get-WmiObject -computername $Target Win32_Timezone
  50.         $Keyboards = Get-WmiObject -computername $Target Win32_Keyboard
  51.         $SchedTasks = Get-WmiObject -computername $Target Win32_ScheduledJob
  52.         $BootINI = $OperatingSystems.SystemDrive + "boot.ini"
  53.         $RecoveryOptions = Get-WmiObject -computername $Target Win32_OSRecoveryConfiguration
  54.        
  55.         switch ($ComputerRole){
  56.                 "Member Workstation" { $CompType = "Computer Domain"; break }
  57.                 "Domain Controller" { $CompType = "Computer Domain"; break }
  58.                 "Member Server" { $CompType = "Computer Domain"; break }
  59.                 default { $CompType = "Computer Workgroup"; break }
  60.         }
  61.  
  62.         $LBTime=$OperatingSystems.ConvertToDateTime($OperatingSystems.Lastbootuptime)
  63.         Write-Output "..Hotfix Information"
  64.         $colQuickFixes = Get-WmiObject Win32_QuickFixEngineering
  65.         Write-Output "..Logical Disks"
  66.         $colDisks = Get-WmiObject -ComputerName $Target Win32_LogicalDisk
  67.         Write-Output "..Network Configuration"
  68.         $NICCount = 0
  69.         $colAdapters = Get-WmiObject -ComputerName $Target Win32_NetworkAdapterConfiguration
  70.         Write-Output "..Local Shares"
  71.         $colShares = Get-wmiobject -ComputerName $Target Win32_Share
  72.         Write-Output "..Printers"
  73.         $colInstalledPrinters =  Get-WmiObject -ComputerName $Target Win32_Printer
  74.         Write-Output "..Services"
  75.         $colListOfServices = Get-WmiObject -ComputerName $Target Win32_Service
  76.         Write-Output "..Regional Options"
  77.         $ObjKeyboards = Get-WmiObject -ComputerName $Target Win32_Keyboard
  78.         $keyboardmap = @{
  79.         "00000402" = "BG"
  80.         "00000404" = "CH"
  81.         "00000405" = "CZ"
  82.         "00000406" = "DK"
  83.         "00000407" = "GR"
  84.         "00000408" = "GK"
  85.         "00000409" = "US"
  86.         "0000040A" = "SP"
  87.         "0000040B" = "SU"
  88.         "0000040C" = "FR"
  89.         "0000040E" = "HU"
  90.         "0000040F" = "IS"
  91.         "00000410" = "IT"
  92.         "00000411" = "JP"
  93.         "00000412" = "KO"
  94.         "00000413" = "NL"
  95.         "00000414" = "NO"
  96.         "00000415" = "PL"
  97.         "00000416" = "BR"
  98.         "00000418" = "RO"
  99.         "00000419" = "RU"
  100.         "0000041A" = "YU"
  101.         "0000041B" = "SL"
  102.         "0000041C" = "US"
  103.         "0000041D" = "SV"
  104.         "0000041F" = "TR"
  105.         "00000422" = "US"
  106.         "00000423" = "US"
  107.         "00000424" = "YU"
  108.         "00000425" = "ET"
  109.         "00000426" = "US"
  110.         "00000427" = "US"
  111.         "00000804" = "CH"
  112.         "00000809" = "UK"
  113.         "0000080A" = "LA"
  114.         "0000080C" = "BE"
  115.         "00000813" = "BE"
  116.         "00000816" = "PO"
  117.         "00000C0C" = "CF"
  118.         "00000C1A" = "US"
  119.         "00001009" = "US"
  120.         "0000100C" = "SF"
  121.         "00001809" = "US"
  122.         "00010402" = "US"
  123.         "00010405" = "CZ"
  124.         "00010407" = "GR"
  125.         "00010408" = "GK"
  126.         "00010409" = "DV"
  127.         "0001040A" = "SP"
  128.         "0001040E" = "HU"
  129.         "00010410" = "IT"
  130.         "00010415" = "PL"
  131.         "00010419" = "RU"
  132.         "0001041B" = "SL"
  133.         "0001041F" = "TR"
  134.         "00010426" = "US"
  135.         "00010C0C" = "CF"
  136.         "00010C1A" = "US"
  137.         "00020408" = "GK"
  138.         "00020409" = "US"
  139.         "00030409" = "USL"
  140.         "00040409" = "USR"
  141.         "00050408" = "GK"
  142.         }
  143.         $keyb = $keyboardmap.$($ObjKeyboards.Layout)
  144.         if (!$keyb)
  145.         { $keyb = "Unknown"
  146.         }
  147.         Write-Output "..Event Log Settings"
  148.         $colLogFiles = Get-WmiObject -ComputerName $Target Win32_NTEventLogFile
  149.         Write-Output "..Event Log Errors"
  150.         $WmidtQueryDT = [System.Management.ManagementDateTimeConverter]::ToDmtfDateTime([DateTime]::Now.AddDays(-14))
  151.         $colLoggedEvents = Get-WmiObject -computer $Target -query ("Select * from Win32_NTLogEvent Where Type='Error' and TimeWritten >='" + $WmidtQueryDT + "'")
  152.         Write-Output "..Event Log Warnings"
  153.         $WmidtQueryDT = [System.Management.ManagementDateTimeConverter]::ToDmtfDateTime([DateTime]::Now.AddDays(-14))
  154.         $colLoggedEvents = Get-WmiObject -computer $Target -query ("Select * from Win32_NTLogEvent Where Type='Warning' and TimeWritten >='" + $WmidtQueryDT + "'")
  155.  
  156.         $Filename = ".\" + $Target + "_" + $date.Hour + $date.Minute + "_" + $Date.Day + "-" + $Date.Month + "-" + $Date.Year + ".htm"
  157.  
  158.         $Report = @"
  159.         <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  160.         <html ES_auditInitialized='false'><head><title>Audit</title>
  161.         <META http-equiv=Content-Type content='text/html; charset=windows-1252'>
  162.         <STYLE type=text/css>  
  163.                 DIV .expando {DISPLAY: block; FONT-WEIGHT: normal; FONT-SIZE: 8pt; RIGHT: 10px; COLOR: #ffffff; FONT-FAMILY: Tahoma; POSITION: absolute; TEXT-DECORATION: underline}
  164.                 TABLE {TABLE-LAYOUT: fixed; FONT-SIZE: 100%; WIDTH: 100%}
  165.                 #objshowhide {PADDING-RIGHT: 10px; FONT-WEIGHT: bold; FONT-SIZE: 8pt; Z-INDEX: 2; CURSOR: hand; COLOR: #000000; MARGIN-RIGHT: 0px; FONT-FAMILY: Tahoma; TEXT-ALIGN: right; TEXT-DECORATION: underline; WORD-WRAP: normal}
  166.                 .heading0_expanded {BORDER-RIGHT: #bbbbbb 1px solid; PADDING-RIGHT: 5em; BORDER-TOP: #bbbbbb 1px solid; DISPLAY: block; PADDING-LEFT: 8px; FONT-WEIGHT: bold; FONT-SIZE: 8pt; MARGIN-BOTTOM: -1px; MARGIN-LEFT: 0px; BORDER-LEFT: #bbbbbb 1px solid; WIDTH: 100%; CURSOR: hand; COLOR: #FFFFFF; MARGIN-RIGHT: 0px; PADDING-TOP: 4px; BORDER-BOTTOM: #bbbbbb 1px solid; FONT-FAMILY: Tahoma; POSITION: relative; HEIGHT: 2.25em; BACKGROUND-COLOR: #cc0000}
  167.                 .heading1 {BORDER-RIGHT: #bbbbbb 1px solid; PADDING-RIGHT: 5em; BORDER-TOP: #bbbbbb 1px solid; DISPLAY: block; PADDING-LEFT: 16px; FONT-WEIGHT: bold; FONT-SIZE: 8pt; MARGIN-BOTTOM: -1px; MARGIN-LEFT: 5px; BORDER-LEFT: #bbbbbb 1px solid; WIDTH: 100%; CURSOR: hand; COLOR: #ffffff; MARGIN-RIGHT: 0px; PADDING-TOP: 4px; BORDER-BOTTOM: #bbbbbb 1px solid; FONT-FAMILY: Tahoma; POSITION: relative; HEIGHT: 2.25em; BACKGROUND-COLOR: #7BA7C7}
  168.                 .heading2 {BORDER-RIGHT: #bbbbbb 1px solid; PADDING-RIGHT: 5em; BORDER-TOP: #bbbbbb 1px solid; DISPLAY: block; PADDING-LEFT: 16px; FONT-WEIGHT: bold; FONT-SIZE: 8pt; MARGIN-BOTTOM: -1px; MARGIN-LEFT: 5px; BORDER-LEFT: #bbbbbb 1px solid; WIDTH: 100%; CURSOR: hand; COLOR: #ffffff; MARGIN-RIGHT: 0px; PADDING-TOP: 4px; BORDER-BOTTOM: #bbbbbb 1px solid; FONT-FAMILY: Tahoma; POSITION: relative; HEIGHT: 2.25em; BACKGROUND-COLOR: #A5A5A5}
  169.                 .tableDetail {BORDER-RIGHT: #bbbbbb 1px solid; BORDER-TOP: #bbbbbb 1px solid; DISPLAY: block; PADDING-LEFT: 16px; FONT-SIZE: 8pt;MARGIN-BOTTOM: -1px; PADDING-BOTTOM: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #bbbbbb 1px solid; WIDTH: 100%; COLOR: #000000; MARGIN-RIGHT: 0px; PADDING-TOP: 4px; BORDER-BOTTOM: #bbbbbb 1px solid; FONT-FAMILY: Tahoma; POSITION: relative; BACKGROUND-COLOR: #f9f9f9}
  170.                 .filler {BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BACKGROUND: none transparent scroll repeat 0% 0%; MARGIN-BOTTOM: -1px; FONT: 100%/8px Tahoma; MARGIN-LEFT: 43px; BORDER-LEFT: medium none; COLOR: #ffffff; MARGIN-RIGHT: 0px; PADDING-TOP: 4px; BORDER-BOTTOM: medium none; POSITION: relative}
  171.                 .Solidfiller {BORDER-RIGHT: medium none; BORDER-TOP: medium none; DISPLAY: block; BACKGROUND: none transparent scroll repeat 0% 0%; MARGIN-BOTTOM: -1px; FONT: 100%/8px Tahoma; MARGIN-LEFT: 0px; BORDER-LEFT: medium none; COLOR: #000000; MARGIN-RIGHT: 0px; PADDING-TOP: 4px; BORDER-BOTTOM: medium none; POSITION: relative; BACKGROUND-COLOR: #000000}
  172.                 td {VERTICAL-ALIGN: TOP; FONT-FAMILY: Tahoma}
  173.                 th {VERTICAL-ALIGN: TOP; COLOR: #cc0000; TEXT-ALIGN: left}
  174.         </STYLE>
  175.         <SCRIPT language=vbscript>
  176.                 strShowHide = 1
  177.                 strShow = "show"
  178.                 strHide = "hide"
  179.                 strShowAll = "show all"
  180.                 strHideAll = "hide all"
  181.        
  182.         Function window_onload()
  183.                 If UCase(document.documentElement.getAttribute("ES_auditInitialized")) <> "TRUE" Then
  184.                         Set objBody = document.body.all
  185.                         For Each obji in objBody
  186.                                 If IsSectionHeader(obji) Then
  187.                                         If IsSectionExpandedByDefault(obji) Then
  188.                                                 ShowSection obji
  189.                                         Else
  190.                                                 HideSection obji
  191.                                         End If
  192.                                 End If
  193.                         Next
  194.                         objshowhide.innerText = strShowAll
  195.                         document.documentElement.setAttribute "ES_auditInitialized", "true"
  196.                 End If
  197.         End Function
  198.        
  199.         Function IsSectionExpandedByDefault(objHeader)
  200.                 IsSectionExpandedByDefault = (Right(objHeader.className, Len("_expanded")) = "_expanded")
  201.         End Function
  202.        
  203.         Function document_onclick()
  204.                 Set strsrc = window.event.srcElement
  205.                 While (strsrc.className = "sectionTitle" or strsrc.className = "expando")
  206.                         Set strsrc = strsrc.parentElement
  207.                 Wend
  208.                 If Not IsSectionHeader(strsrc) Then Exit Function
  209.                 ToggleSection strsrc
  210.                 window.event.returnValue = False
  211.         End Function
  212.        
  213.         Sub ToggleSection(objHeader)
  214.                 SetSectionState objHeader, "toggle"
  215.         End Sub
  216.        
  217.         Sub SetSectionState(objHeader, strState)
  218.                 i = objHeader.sourceIndex
  219.                 Set all = objHeader.parentElement.document.all
  220.                 While (all(i).className <> "container")
  221.                         i = i + 1
  222.                 Wend
  223.                 Set objContainer = all(i)
  224.                 If strState = "toggle" Then
  225.                         If objContainer.style.display = "none" Then
  226.                                 SetSectionState objHeader, "show"
  227.                         Else
  228.                                 SetSectionState objHeader, "hide"
  229.                         End If
  230.                 Else
  231.                         Set objExpando = objHeader.children.item(1)
  232.                         If strState = "show" Then
  233.                                 objContainer.style.display = "block"
  234.                                 objExpando.innerText = strHide
  235.        
  236.                         ElseIf strState = "hide" Then
  237.                                 objContainer.style.display = "none"
  238.                                 objExpando.innerText = strShow
  239.                         End If
  240.                 End If
  241.         End Sub
  242.        
  243.         Function objshowhide_onClick()
  244.                 Set objBody = document.body.all
  245.                 Select Case strShowHide
  246.                         Case 0
  247.                                 strShowHide = 1
  248.                                 objshowhide.innerText = strShowAll
  249.                                 For Each obji In objBody
  250.                                         If IsSectionHeader(obji) Then
  251.                                                 HideSection obji
  252.                                         End If
  253.                                 Next
  254.                         Case 1
  255.                                 strShowHide = 0
  256.                                 objshowhide.innerText = strHideAll
  257.                                 For Each obji In objBody
  258.                                         If IsSectionHeader(obji) Then
  259.                                                 ShowSection obji
  260.                                         End If
  261.                                 Next
  262.                 End Select
  263.         End Function
  264.        
  265.         Function IsSectionHeader(obj) : IsSectionHeader = (obj.className = "heading0_expanded") Or (obj.className = "heading1_expanded") Or (obj.className = "heading1") Or (obj.className = "heading2"): End Function
  266.         Sub HideSection(objHeader) : SetSectionState objHeader, "hide" : End Sub
  267.         Sub ShowSection(objHeader) : SetSectionState objHeader, "show": End Sub
  268.         </SCRIPT>
  269.         </HEAD>
  270.         <BODY>
  271.         <p><b><font face="Arial" size="5">$Target Audit<hr size="8" color="#CC0000"></font></b>
  272.         <font face="Arial" size="1"><b><i>Version 1.1 by Alan Renouf (Virtu-Al)</i></b></font><br>
  273.         <font face="Arial" size="1">Report generated on $Date </font></p>
  274.        
  275.         <TABLE cellSpacing=0 cellPadding=0>
  276.                 <TBODY>
  277.                         <TR>
  278.                                 <TD>
  279.                                         <DIV id=objshowhide tabIndex=0><FONT face=Arial></FONT></DIV>
  280.                                 </TD>
  281.                         </TR>
  282.                 </TBODY>
  283.         </TABLE>
  284.         <DIV class=heading0_expanded>
  285.                 <SPAN class=sectionTitle tabIndex=0>$target Details</SPAN>
  286.                 <A class=expando href='#'></A>
  287.         </DIV>
  288.         <DIV class=filler></DIV>
  289.         <DIV class=container>
  290.         <DIV class=heading1>
  291.         <SPAN class=sectionTitle tabIndex=0>General</SPAN>
  292.         <A class=expando href='#'></A>
  293.         </DIV>
  294.         <DIV class=container>
  295.         <DIV class=tableDetail>
  296.         <TABLE>
  297.         <tr>
  298.         <th width='25%'><b>Computer Name</b></font></th>
  299.         <td width='75%'>$($ComputerSystem.Name)</font></td>
  300.         </tr>
  301.         <tr>
  302.         <th width='25%'><b>Computer Role</b></font></th>
  303.         <td width='75%'> $ComputerRole </font></td>
  304.         </tr>
  305.         <tr>
  306.         <th width='25%'><b>$CompType</b></font></th>   
  307.         <td width='75%'>$($ComputerSystem.Domain)</font></td>
  308.         </tr>
  309.         <tr>
  310.         <th width='25%'><b>Operating System</b></font></th>
  311.         <td width='75%'>$($OperatingSystems.Caption)</font></td>
  312.         </tr>
  313.         <tr>
  314.         <th width='25%'><b>Service Pack</b></font></th>
  315.         <td width='75%'>$($OperatingSystems.CSDVersion)</font></td>
  316.         </tr>
  317.         <tr>
  318.                 <th width='25%'><b>System Root</b></font></th>
  319.                 <td width='75%'>$($OperatingSystems.SystemDrive)</font></td>
  320.         </tr>
  321.         <tr>
  322.                 <th width='25%'><b>Manufacturer</b></font></th>
  323.                 <td width='75%'>$($ComputerSystem.Manufacturer)</font></td>
  324.                                         </tr>
  325.         <tr>
  326.                 <th width='25%'><b>Model</b></font></th>
  327.                 <td width='75%'>$($ComputerSystem.Model)</font></td>
  328.                                         </tr>
  329.         <tr>
  330.                 <th width='25%'><b>Number of Processors</b></font></th>
  331.                 <td width='75%'>$($ComputerSystem.NumberOfProcessors)</font></td>
  332.                                         </tr>
  333.         <tr>
  334.                 <th width='25%'><b>Memory</b></font></th>
  335.                 <td width='75%'>$($ComputerSystem.TotalPhysicalMemory)</font></td>
  336.                                         </tr>
  337.         <tr>
  338.                 <th width='25%'><b>Registered User</b></font></th>
  339.                 <td width='75%'>$($ComputerSystem.PrimaryOwnerName)</font></td>
  340.                                         </tr>
  341.                                         <tr>
  342.                 <th width='25%'><b>Registered Organisation</b></font></th>
  343.                 <td width='75%'>$($OperatingSystems.Organization)</font></td>
  344.         </tr>
  345.                                         <tr>
  346.                                         <th width='25%'><b>Last System Boot</b></font></th>
  347.                 <td width='75%'>$LBTime</font></td>
  348.         </tr>
  349.                                 </TABLE>
  350.                         </DIV>
  351.                 </DIV>
  352.                 <DIV class=filler></DIV>
  353.         <DIV class=container>
  354.         <DIV class=heading1>
  355.         <SPAN class=sectionTitle tabIndex=0>HotFixes</SPAN>
  356.         <A class=expando href='#'></A>
  357.         </DIV>
  358.         <DIV class=container>
  359.         <DIV class=tableDetail>
  360.         <TABLE>
  361.         <tr>
  362.         <th width='25%'><b>HotFix Number</b></font></th>
  363.         <th width='75%'><b>Description</b></font></th>
  364.         </tr>
  365. "@
  366.  
  367.         ForEach ($objQuickFix in $colQuickFixes)
  368.         {
  369.                 if ($objQuickFix.HotFixID -ne "File 1")
  370.                 {
  371.                         $Report+= "                             <tr>"
  372.                         $Report+= "                                     <td width='25%'>$($objQuickFix.HotFixID)</font></td>"
  373.                         $Report+= "                                     <td width='75%'>$($objQuickFix.Description)</font></td>"
  374.                         $Report+= "                             </tr>"
  375.                 }
  376.         }
  377. $Report+= @"
  378.         </TABLE>
  379.         </DIV>
  380.         </DIV>
  381.         </DIV>
  382.         <DIV class=filler></DIV>
  383.                 <DIV class=container>
  384.                         <DIV class=heading1>
  385.                                 <SPAN class=sectionTitle tabIndex=0>Logical Disk Configuration</SPAN>
  386.                                 <A class=expando href='#'></A>
  387.                         </DIV>
  388.                         <DIV class=container>
  389.                                 <DIV class=tableDetail>
  390.                                         <TABLE>
  391.                                                 <tr>
  392.                                                         <th width='15%'><b>Drive Letter</b></font></th>
  393.                                                         <th width='20%'><b>Label</b></font></th>
  394.                                                         <th width='20%'><b>File System</b></font></th>
  395.                                                         <th width='15%'><b>Disk Size</b></font></th>
  396.                                                         <th width='15%'><b>Disk Free Space</b></font></th>
  397.                                                         <th width='15%'><b>% Free Space</b></font></th>
  398.                                                 </tr>
  399. "@
  400.  
  401.         Foreach ($objDisk in $colDisks)
  402.         {
  403.                 if ($objDisk.DriveType -eq 3)
  404.                 {
  405.                         $Report+=  "                                    <tr>"
  406.                         $Report+=  "                                            <td width='15%'>$($objDisk.DeviceID)</font></td>"
  407.                         $Report+=  "                                            <td width='20%'>$($objDisk.VolumeName)</font></td>"
  408.                         $Report+=  "                                            <td width='20%'>$($objDisk.FileSystem)</font></td>"
  409.                         $disksize = [math]::round(($objDisk.size / 1048576))
  410.                         $Report+=  "                                            <td width='15%'>$disksize MB</font></td>"
  411.                         $freespace = [math]::round(($objDisk.FreeSpace / 1048576))
  412.                         $Report+=  "                                            <td width='15%'>$Freespace MB</font></td>"
  413.                         $percFreespace=[math]::round(((($objDisk.FreeSpace / 1048576)/($objDisk.Size / 1048676)) * 100),0)
  414.                         $Report+=  "                                            <td width='15%'>$percFreespace%</font></td>"
  415.                         $Report+=  "                                    </tr>"
  416.                 }
  417.         }
  418. $Report+= @"
  419.         </TABLE>
  420.         </DIV>
  421.         </DIV>
  422.         </DIV>
  423.         <DIV class=filler></DIV>
  424.  
  425.        
  426.                 <DIV class=container>
  427.                         <DIV class=heading1>
  428.                                 <SPAN class=sectionTitle tabIndex=0>NIC Configuration</SPAN>
  429.                                 <A class=expando href='#'></A>
  430.                         </DIV>
  431.                         <DIV class=container>
  432.                                 <DIV class=tableDetail>
  433.                                         <TABLE>
  434. "@
  435.         Foreach ($objAdapter in $colAdapters)
  436.         {
  437.                 if ($objAdapter.IPEnabled -eq "True")
  438.                 {
  439.                         $NICCount = $NICCount + 1
  440.                         If ($NICCount -gt 1)
  441.                         {
  442.                                 $Report+=  "                    </TABLE>"
  443.                                 $Report+=  "                            <DIV class=Solidfiller></DIV>"
  444.                                 $Report+=  "                    <TABLE>"
  445.                         }
  446.                 $Report+=  "                                    <tr>"
  447.                 $Report+=  "                                            <th width='25%'><b>Description</b></font></th>"
  448.                 $Report+=  "                                            <td width='75%'>$($objAdapter.Description)</font></td>"
  449.                 $Report+=  "                                    </tr>"
  450.                 $Report+=  "                                    <tr>"
  451.                 $Report+=  "                                            <th width='25%'><b>Physical address</b></font></th>"
  452.                 $Report+=  "                                            <td width='75%'>$($objAdapter.MACaddress)</font></td>"
  453.                 $Report+=  "                                    </tr>"
  454.                 If ($objAdapter.IPAddress -ne $Null)
  455.                 {
  456.                         $Report+=  "                                    <tr>"
  457.                         $Report+=  "                                            <th width='25%'><b>IP Address / Subnet Mask</b></font></th>"
  458.                         $Report+=  "                                            <td width='75%'>$($objAdapter.IPAddress)/$($objAdapter.IPSubnet)</font></td>"
  459.                         $Report+=  "                                    </tr>"
  460.                         $Report+=  "                                    </tr>"
  461.                         $Report+=  "                                    <tr>"
  462.                         $Report+=  "                                            <th width='25%'><b>Default Gateway</b></font></th>"
  463.                         $Report+=  "                                            <td width='75%'>$($objAdapter.DefaultIPGateway)</font></td>"
  464.                         $Report+=  "                                    </tr>"
  465.                
  466.                 }
  467.                 $Report+=  "                                    <tr>"
  468.                 $Report+=  "                                            <th width='25%'><b>DHCP enabled</b></font></th>"
  469.                 If ($objAdapter.DHCPEnabled -eq "True")
  470.                 {
  471.                         $Report+=  "                                            <td width='75%'>Yes</font></td>"
  472.                 }
  473.                 Else
  474.                 {
  475.                         $Report+=  "                                            <td width='75%'>No</font></td>"
  476.                 }
  477.                 $Report+=  "                                    </tr>"
  478.                 $Report+=  "                                    <tr>"
  479.                 $Report+=  "                                                    <th width='25%'><b>DNS Servers</b></font></th>"
  480.                 $Report+=  "                                                    <td width='75%'>"
  481.                 If ($objAdapter.DNSServerSearchOrder -ne $Null)
  482.                 {
  483.                         $Report+=  " $($objAdapter.DNSServerSearchOrder) "
  484.                 }
  485.                 $Report+=  "                                    </tr>"
  486.                 $Report+=  "                                    <tr>"
  487.                 $Report+=  "                                            <th width='25%'><b>Primary WINS Server</b></font></th>"
  488.                 $Report+=  "                                            <td width='75%'>$($objAdapter.WINSPrimaryServer)</font></td>"
  489.                 $Report+=  "                                    </tr>"
  490.                 $Report+=  "                                    <tr>"
  491.                 $Report+=  "                                            <th width='25%'><b>Secondary WINS Server</b></font></th>"
  492.                 $Report+=  "                                            <td width='75%'>$($objAdapter.WINSSecondaryServer)</font></td>"
  493.                 $Report+=  "                                    </tr>"
  494.                 $NICCount = $NICCount + 1
  495.                 }
  496.         }
  497. $Report+= @"
  498.                                         </TABLE>
  499.                                 </DIV>
  500.                         </DIV>
  501.                 </DIV>
  502.                 <DIV class=filler></DIV>
  503. "@     
  504.         if ((get-wmiobject -namespace "root/cimv2" -list) | ? {$_.name -match "Win32_Product"})
  505.         {
  506.                 Write-Output "..Installed Software"
  507.                 $colApps = get-wmiobject -ComputerName $Target Win32_Product | select Name,Version,Vendor,InstallDate
  508.                
  509. $Report+= @"
  510.         <DIV class=container>
  511.                                 <DIV class=heading1>
  512.                                         <SPAN class=sectionTitle tabIndex=0>Software</SPAN>
  513.                                         <A class=expando href='#'></A>
  514.                                 </DIV>
  515.                                 <DIV class=container>
  516.                                         <DIV class=tableDetail>
  517.                                                 <TABLE>
  518.                                                         <tr>
  519.                                                                 <th width='25%'><b>Name</b></font></th>
  520.                                                                 <th width='25%'><b>Version</b></font></th>
  521.                                                                 <th width='25%'><b>Vendor</b></font></th>
  522.                                                                 <th width='25%'><b>Install Date</b></font></th>
  523.                                                         </tr>
  524. "@
  525.                 Foreach ($objApps in $colApps)
  526.                 {
  527.                         $Report+=  "                                    <tr>"
  528.                         $Report+=  "                                            <td width='50%'>$($objApps.Name)</font></td>"
  529.                         $Report+=  "                                            <td width='20%'>$($objApps.Version)</font></td>"
  530.                         $Report+=  "                                            <td width='15%'>$($objApps.Vendor)</font></td>"
  531.                         $Report+=  "                                            <td width='15%'>$($objApps.InstallDate)</font></td>"
  532.                         $Report+=  "                                    </tr>"
  533.                 }
  534.                 $Report+=  "                            </TABLE>"
  535.                 $Report+=  "                    </DIV>"
  536.                 $Report+=  "            </DIV>"
  537.                 $Report+=  "    </DIV>"
  538.                 $Report+=  "    <DIV class=filler></DIV>"              
  539.         }
  540. $Report+= @"
  541.                 <DIV class=container>
  542.                         <DIV class=heading1>
  543.                                 <SPAN class=sectionTitle tabIndex=0>Local Shares</SPAN>
  544.                                 <A class=expando href='#'></A>
  545.                         </DIV>
  546.                         <DIV class=container>
  547.                                 <DIV class=tableDetail>
  548.                                         <TABLE>
  549.                                                 <tr>
  550.                                                         <th width='25%'><b>Share</b></font></th>
  551.                                                         <th width='25%'><b>Path</b></font></th>
  552.                                                         <th width='50%'><b>Comment</b></font></th>
  553.                                                 </tr>
  554. "@
  555. Foreach ($objShare in $colShares)
  556.         {
  557.                 $Report+=  "                                    <tr>"
  558.                 $Report+=  "                                            <td width='25%'>$($objShare.Name)</font></td>"
  559.                 $Report+=  "                                            <td width='25%'>$($objShare.Path)</font></td>"
  560.                 $Report+=  "                                            <td width='50%'>$($objShare.Caption)</font></td>"
  561.                 $Report+=  "                                    </tr>"
  562.         }      
  563. $Report+= @"
  564.                                         </TABLE>
  565.                                 </DIV>
  566.                         </DIV>
  567.                 </DIV>
  568.                 <DIV class=filler></DIV>
  569.        
  570.                 <DIV class=container>
  571.                         <DIV class=heading1>
  572.                                 <SPAN class=sectionTitle tabIndex=0>Printers</SPAN>
  573.                                 <A class=expando href='#'></A>
  574.                         </DIV>
  575.                         <DIV class=container>
  576.                                 <DIV class=tableDetail>
  577.                                         <TABLE>
  578.                                                 <tr>
  579.                                                         <th width='25%'><b>Printer</b></font></th>
  580.                                                         <th width='25%'><b>Location</b></font></th>
  581.                                                         <th width='25%'><b>Default Printer</b></font></th>
  582.                                                         <th width='25%'><b>Portname</b></font></th>
  583.                                                 </tr>
  584. "@
  585.         Foreach ($objPrinter in $colInstalledPrinters)
  586.         {
  587.                 If ($objPrinter.Name -eq "")
  588.                 {
  589.                         $Report+=  "                                    <tr>"
  590.                         $Report+=  "                                            <td width='100%'>No Printers Installed</font></td>"
  591.                 }
  592.                 Else
  593.                 {
  594.                         $Report+=  "                                    <tr>"
  595.                         $Report+=  "                                            <td width='25%'>$($objPrinter.Name)</font></td>"
  596.                         $Report+=  "                                            <td width='25%'>$($objPrinter.Location)</font></td>"
  597.                         if ($objPrinter.Default -eq "True")
  598.                         {
  599.                                 $Report+=  "                                            <td width='25%'>Yes</font></td>"
  600.                         }
  601.                         Else
  602.                         {
  603.                                 $Report+=  "                                            <td width='25%'>No</font></td>"
  604.                         }
  605.                         $Report+=  "                                            <td width='25%'>$($objPrinter.Portname)</font></td>"
  606.                 }
  607.                 $Report+=  "                                    </tr>"
  608.         }
  609. $Report+= @"
  610.                                 </TABLE>
  611.                                 </DIV>
  612.                         </DIV>
  613.                 </DIV>
  614.                 <DIV class=filler></DIV>
  615.                 <DIV class=container>
  616.                         <DIV class=heading1>
  617.                                 <SPAN class=sectionTitle tabIndex=0>Services</SPAN>
  618.                                 <A class=expando href='#'></A>
  619.                         </DIV>
  620.                         <DIV class=container>
  621.                                 <DIV class=tableDetail>
  622.                                         <TABLE>
  623.                                                 <tr>
  624.                                                         <th width='20%'><b>Name</b></font></th>
  625.                                                         <th width='20%'><b>Account</b></font></th>
  626.                                                         <th width='20%'><b>Start Mode</b></font></th>
  627.                                                         <th width='20%'><b>State</b></font></th>
  628.                                                         <th width='20%'><b>Expected State</b></font></th>
  629.                                                 </tr>
  630. "@
  631.  
  632.         Foreach ($objService in $colListOfServices)
  633.         {
  634.                 $Report+=  "                                    <tr>"
  635.                 $Report+=  "                                            <td width='20%'>$($objService.Caption)</font></td>"
  636.                 $Report+=  "                                            <td width='20%'>$($objService.Startname)</font></td>"
  637.                 $Report+=  "                                            <td width='20%'>$($objService.StartMode)</font></td>"
  638.                 If ($objService.StartMode -eq "Auto")
  639.                 {
  640.                         if ($objService.State -eq "Stopped")
  641.                         {
  642.                                 $Report+=  "                                            <td width='20%'><font color='#FF0000'>$($objService.State)</font></td>"
  643.                                 $Report+=  "                                            <td width='25%'><font face='Wingdings'color='#FF0000'>û</font></td>"
  644.                         }
  645.                 }
  646.                 If ($objService.StartMode -eq "Auto")
  647.                 {
  648.                         if ($objService.State -eq "Running")
  649.                         {
  650.                                 $Report+=  "                                            <td width='20%'><font color='#009900'>$($objService.State)</font></td>"
  651.                                 $Report+=  "                                            <td width='20%'><font face='Wingdings'color='#009900'>ü</font></td>"
  652.                         }
  653.                 }
  654.                 If ($objService.StartMode -eq "Disabled")
  655.                 {
  656.                         If ($objService.State -eq "Running")
  657.                         {
  658.                                 $Report+=  "                                            <td width='20%'><font color='#FF0000'>$($objService.State)</font></td>"
  659.                                 $Report+=  "                                            <td width='25%'><font face='Wingdings'color='#FF0000'>û</font></td>"
  660.                         }
  661.                 }
  662.                 If ($objService.StartMode -eq "Disabled")
  663.                 {
  664.                         if ($objService.State -eq "Stopped")
  665.                         {
  666.                                 $Report+=  "                                            <td width='20%'><font color='#009900'>$($objService.State)</font></td>"
  667.                                 $Report+=  "                                            <td width='20%'><font face='Wingdings'color='#009900'>ü</font></td>"
  668.                         }
  669.                 }
  670.                 If ($objService.StartMode -eq "Manual")
  671.                 {
  672.                         $Report+=  "                                            <td width='20%'><font color='#009900'>$($objService.State)</font></td>"
  673.                         $Report+=  "                                            <td width='20%'><font face='Wingdings'color='#009900'>ü</font></td>"
  674.                 }
  675.                 If ($objService.State -eq "Paused")
  676.                 {
  677.                         $Report+=  "                                            <td width='20%'><font color='#FF9933'>$($objService.State)</font></td>"
  678.                         $Report+=  "                                            <td width='20%'><font face='Wingdings'color='#009900'>ü</font></td>"
  679.                 }
  680.                 $Report+=  "                                    </tr>"
  681.         }      
  682. $Report+= @"
  683.                                         </TABLE>
  684.                                 </DIV>
  685.                         </DIV>
  686.                 </DIV>
  687.                 <DIV class=filler></DIV>
  688.                 <DIV class=container>
  689.                         <DIV class=heading1>
  690.                                 <SPAN class=sectionTitle tabIndex=0>Regional Settings</SPAN>
  691.                                 <A class=expando href='#'></A>
  692.                         </DIV>
  693.                         <DIV class=container>
  694.                                 <DIV class=tableDetail>
  695.                                         <TABLE>
  696.                                                 <tr>
  697.                                                         <th width='25%'><b>Time Zone</b></font></th>
  698.                                                         <td width='75%'>$($TimeZone.Description)</font></td>
  699.                                                 </tr>
  700.                                                 <tr>
  701.                                                         <th width='25%'><b>Country Code</b></font></th>
  702.                                                         <td width='75%'>$($OperatingSystems.Countrycode)</font></td>
  703.                                                 </tr>
  704.                                                 <tr>
  705.                                                         <th width='25%'><b>Locale</b></font></th>
  706.                                                         <td width='75%'>$($OperatingSystems.Locale)</font></td>
  707.                                                 </tr>
  708.                                                 <tr>
  709.                                                         <th width='25%'><b>Operating System Language</b></font></th>
  710.                                                         <td width='75%'>$($OperatingSystems.OSLanguage)</font></td>
  711.                                                 </tr>
  712.                                                 <tr>
  713.                                                 <th width='25%'><b>Keyboard Layout</b></font></th>
  714.                                                         <td width='75%'>$keyb</font></td>
  715.                                                 </tr>
  716.                                         </TABLE>
  717.                                 </div>
  718.                         </DIV>
  719.                 </DIV>
  720.                 <DIV class=filler></DIV>
  721.                 <DIV class=container>
  722.                         <DIV class=heading1>
  723.                                 <SPAN class=sectionTitle tabIndex=0>Event Logs</SPAN>
  724.                                 <A class=expando href='#'></A>
  725.                         </DIV>
  726.                         <DIV class=container>
  727.                                 <DIV class=tableDetail>
  728.                 <DIV class=container>
  729.                         <DIV class=heading2>
  730.                                 <SPAN class=sectionTitle tabIndex=0>Event Log Settings</SPAN>
  731.                                 <A class=expando href='#'></A>
  732.                         </DIV>
  733.                         <DIV class=container>
  734.                                 <DIV class=tableDetail>
  735.                                         <TABLE>
  736.                                                 <tr>
  737.                                                 <th width='25%'><b>Log Name</b></font></th>
  738.                                                 <th width='25%'><b>Overwrite Outdated Records</b></font></th>
  739.                                                         <th width='25%'><b>Maximum Size</b></font></th>
  740.                                                         <th width='25%'><b>Current Size</b></font></th>
  741.                                                 </tr>
  742. "@
  743.         ForEach ($objLogFile in $colLogfiles)
  744.         {
  745.                 $Report+=  "                                    <tr>"
  746.                 $Report+=  "                                            <td width='25%'>$($objLogFile.LogFileName)</font></td>"
  747.                 If ($objLogfile.OverWriteOutdated -lt 0)
  748.                 {
  749.                         $Report+=  "                                            <td width='25%'>Never</font></td>"
  750.                 }
  751.                 if ($objLogFile.OverWriteOutdated -eq 0)
  752.                 {
  753.                         $Report+=  "                                            <td width='25%'>As needed</font></td>"
  754.                 }
  755.                 Else
  756.                 {
  757.                         $Report+=  "                                            <td width='25%'>After $($objLogFile.OverWriteOutdated) days</font></td>"
  758.                 }
  759.                 $MaxFileSize = ($objLogfile.MaxFileSize) / 1024
  760.                 $FileSize = ($objLogfile.FileSize) / 1024
  761.                
  762.                 $Report+=  "                                            <td width='25%'>$MaxFileSize KB</font></td>"
  763.                 $Report+=  "                                            <td width='25%'>$FileSize KB</font></td>"
  764.                 $Report+=  "                                    </tr>"
  765.         }
  766. $Report+= @"
  767.                                         </TABLE>
  768.                                 </DIV>
  769.                         </DIV>
  770.                 </DIV>
  771.                 <DIV class=filler></DIV>
  772.                 <DIV class=container>
  773.                         <DIV class=heading2>
  774.                                 <SPAN class=sectionTitle tabIndex=0>ERROR Entries</SPAN>
  775.                                 <A class=expando href='#'></A>
  776.                         </DIV>
  777.                         <DIV class=container>
  778.                                 <DIV class=tableDetail>
  779.                                         <TABLE>
  780.                                                 <tr>
  781.                                                 <th width='10%'><b>Event Code</b></font></th>
  782.                                                 <th width='10%'><b>Source Name</b></font></th>
  783.                                                 <th width='15%'><b>Time</b></font></th>
  784.                                                 <th width='10%'><b>Log</b></font></th>
  785.                                                 <th width='55%'><b>Message</b></font></th>
  786.                                                 </tr>
  787. "@
  788.         ForEach ($objEvent in $colLoggedEvents)
  789.         {
  790.                 $dtmEventDate = $ObjEvent.ConvertToDateTime($objEvent.TimeWritten)
  791.                 $Report+=  "                                    <tr>"
  792.                 $Report+=  "                                            <td width='10%'>$($objEvent.EventCode)</font></td>"
  793.                 $Report+=  "                                            <td width='10%'>$($objEvent.SourceName)</font></td>"
  794.                 $Report+=  "                                            <td width='15%'>$dtmEventDate</font></td>"
  795.                 $Report+=  "                                            <td width='10%'>$($objEvent.LogFile)</font></td>"
  796.                 $Report+=  "                                            <td width='55%'>$($objEvent.Message)</font></td>"
  797.                 $Report+=  "                                    </tr>"
  798.         }
  799. $Report+= @"
  800.                                         </TABLE>
  801.                                 </DIV>
  802.                         </DIV>
  803.                 </DIV>
  804.                 <DIV class=filler></DIV>
  805.                 <DIV class=container>
  806.                         <DIV class=heading2>
  807.                                 <SPAN class=sectionTitle tabIndex=0>WARNING Entries</SPAN>
  808.                                 <A class=expando href='#'></A>
  809.                         </DIV>
  810.                         <DIV class=container>
  811.                                 <DIV class=tableDetail>
  812.                                         <TABLE>
  813.                                                 <tr>
  814.                                                 <th width='10%'><b>Event Code</b></font></th>
  815.                                                 <th width='10%'><b>Source Name</b></font></th>
  816.                                                 <th width='15%'><b>Time</b></font></th>
  817.                                                 <th width='10%'><b>Log</b></font></th>
  818.                                                 <th width='55%'><b>Message</b></font></th>
  819.                                                 </tr>
  820. "@
  821.         ForEach ($objEvent in $colLoggedEvents)
  822.         {
  823.                 $StrWMIDate = $ObjEvent.ConvertToDateTime($objEvent.TimeWritten)
  824.                 $Report+=  "                                    <tr>"
  825.                 $Report+=  "                                            <td width='10%'>$($objEvent.EventCode)</font></td>"
  826.                 $Report+=  "                                            <td width='10%'>$($objEvent.SourceName)</font></td>"
  827.                 $Report+=  "                                            <td width='15%'>$($dtmEventDate)</font></td>"
  828.                 $Report+=  "                                            <td width='10%'>$($objEvent.LogFile)</font></td>"
  829.                 $Report+=  "                                            <td width='55%'>$($objEvent.Message)</font></td>"
  830.                 $Report+=  "                                    </tr>"
  831.         }
  832. $Report+= @"
  833.                                         </TABLE>
  834.                                 </DIV>
  835.                         </DIV>
  836.                 </DIV>
  837.                 <DIV class=filler></DIV>
  838.                                 </DIV>
  839.                         </DIV>
  840.                 </DIV>
  841.        
  842.                 <DIV class=filler></DIV>
  843.         </body>
  844.         </html>
  845. "@
  846. $Report | out-file -encoding ASCII -filepath $Filename
  847. }

Submit a correction or amendment below (
click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:


Remember me