PoshCode Logo PowerShell Code Repository

Audit Script by alanrenouf 3 years ago
diff | embed code: <script type="text/javascript" src="http://PoshCode.org/embed/641"></script>download | new post

Ok, i guess i have too much code for the paste bin, please can someone remove this !

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

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