Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. Web
  3. more
  4. Inbox
  5. (no subject)
  6. O
  7. Orwig, Adam J CTR AD, 7.2.4 ISF
  8. to me
  9. 4 minutes agoDetails
  10. $ErrorActionPreference = "SilentlyContinue"
  11.  
  12. Function QA-Server {
  13.  
  14.     param([string]$ComputerName)
  15.  
  16.     if(Test-Path "\\$ComputerName\Admin`$"){
  17.         $Global:Output = "\\Server\Software\QA\$ComputerName.html"
  18.         Clear-Content $output -ErrorAction SilentlyContinue
  19.         Write-Host "Creating QA Sheet for $ComputerName`..."
  20.         Start-HTML -ComputerName $ComputerName
  21.         "<h2>Hardware Information:</h2><hr>" | Add-Content $output
  22.         Get-DriveInfo  -ComputerName $ComputerName
  23.         Get-NICInfo -ComputerName $ComputerName
  24.         Get-PersistentRoutes -ComputerName $ComputerName
  25.         Get-ProcessorInfo -ComputerName $ComputerName
  26.         Get-RAMInfo -ComputerName $ComputerName
  27.         "<h2>Software Information:</h2><hr>" | Add-Content $output
  28.         Get-WindowsInfo -ComputerName $ComputerName
  29.         Get-Applications -ComputerName $ComputerName
  30.         End-HTML
  31.     }
  32.  
  33.     else{
  34.         #Write-Host "Could not connect to '$ComputerName'! Please enter a valid server name." -ForegroundColor Red -BackgroundColor Black
  35.         throw "Could not connect to '$ComputerName'! Please enter a valid server name."
  36.  
  37.     }
  38.  
  39. }
  40.  
  41.  
  42. #Start HTML=====================================================================================================================================
  43. Function Start-HTML{
  44.  
  45.     param([string]$ComputerName)
  46.  
  47.     $date = Get-Date -Format "hh:mm MM/dd/yyyy"
  48.  
  49.     "<HTML>
  50.    <HEAD>
  51.    <title>$ComputerName QA Checklist</title>
  52.    <style type='text/css'>
  53.        body{
  54.            font-family:calibri;
  55.            background-color:#dddddd;
  56.            width:800px;
  57.        }
  58.  
  59.        h1 {
  60.            margin-bottom:0px;
  61.        }
  62.  
  63.        p {
  64.            margin-top:0px;
  65.            text-decoration:underline;
  66.        }
  67.  
  68.        h2{
  69.            margin-bottom:0px;
  70.            margin-top:45px;
  71.        }
  72.  
  73.        h3 {
  74.            margin-bottom:0px;
  75.            margin-top:20px;
  76.        }
  77.  
  78.        table{
  79.            border:2px solid #aaaaaa;
  80.            width:99%;
  81.            background-color:#cccccc;
  82.        }
  83.  
  84.        td {
  85.            background-color:white;
  86.            border:1px solid #aaaaaa;
  87.        }
  88.  
  89.        .bold {
  90.            font-weight:bold;
  91.        }
  92.  
  93.    </style>
  94.    </HEAD>
  95.    <BODY>
  96.    <h1>$ComputerName QA Checklist</h1>
  97.    <p>Created by $env:username on $date</p>
  98.    " | Add-Content $Output
  99. }
  100.  
  101.  
  102. #Drive Info=============================================================================================================================
  103. Function Get-DriveInfo {
  104.  
  105.     param([string]$ComputerName)
  106.  
  107.     $wmi = Get-WmiObject -Class Win32_LogicalDisk -ComputerName $ComputerName
  108.  
  109.     "<h3>Drive Information:</h3>
  110.    <table>
  111.    <tr>
  112.        <td class='bold'>Drive Letter:</td>
  113.        <td class='bold'>Drive Name:</td>
  114.        <td class='bold'>Drive Size:</td>
  115.    </tr>
  116.    " | Add-Content $Output
  117.  
  118.         foreach($disk in $wmi){
  119.             $Size = ($disk.Size / 1024 / 1024 / 1024)
  120.             $Size = "{0:N3}" -f $Size
  121.             $Name = $disk.name
  122.             $VolumeName = $disk.VolumeName
  123.             "<tr>
  124.                <td>$Name</td>
  125.                <td>$VolumeName</td>
  126.                <td>$Size GB</td>
  127.            </tr>" | Add-Content $Output
  128.             }
  129.     "</table>" | Add-Content $Output
  130. }
  131.  
  132.  
  133. #Network Adapter Info=====================================================================================================================
  134. Function Get-NICinfo{
  135.  
  136.     param([string]$ComputerName)
  137.  
  138.  
  139.     $wmi = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $ComputerName
  140.  
  141.     "<h3>Network Interface Card Information:</h3>
  142.    <table>
  143.    <tr>
  144.        <td class='bold'>Name:</td>
  145.        <td class='bold'>IP Address:</td>
  146.        <td class='bold'>Subnet:</td>
  147.        <td class='bold'>Default Gateway:</td>
  148.        <td class='bold'>DNS IP Addresses:</td>
  149.        <td class='bold'>MTU</td>
  150.    </tr>
  151.    " | Add-Content $Output
  152.  
  153.     foreach($NIC in $wmi){
  154.         if($NIC.IPaddress){
  155.            $IPAddress = $NIC.IPAddress
  156.            $IPSubnet = $NIC.IPSubnet
  157.            $DefaultIPGateway = $NIC.DefaultIPGateway
  158.            $DNSServerSearchOrder = $NIC.DNSServerSearchOrder
  159.            $MAC = $NIC.MACAddress
  160.            $ID = $NIC.settingID
  161.            $wmi2 = Get-WmiObject -Class Win32_NetworkAdapter -ComputerName $ComputerName -Filter "MACAddress = '$MAC'"
  162.            $Name = $wmi2.NetConnectionID
  163.  
  164.            try{
  165.                 Invoke-Command -ComputerName $ComputerName -ScriptBlock{cmd.exe /c 'netsh interface ipv4 show subinterfaces'} -ErrorAction SilentlyContinue | Tee-Object -FilePath E:\Software\BrandonFallin\temp\temp.txt | Out-Null
  166.  
  167.                 $line = $line.ToString()
  168.                 $MTU = $line.Substring(2,4)
  169.            }
  170.  
  171.            catch{
  172.                 $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $ComputerName)
  173.                 $key = $reg.OpenSubKey("SYSTEM\CurrentControlSet\services\Tcpip\Parameters\Interfaces\$ID")
  174.                 $MTU = $key.GetValue("MTU")
  175.            }
  176.  
  177.  
  178.  
  179.  
  180.            "<tr>
  181.                <td>$Name</td>
  182.                <td>$IPAddress</td>
  183.                <td>$IPSubnet</td>
  184.                <td>$DefaultIPGateway</td>
  185.                <td>$DNSServerSearchOrder</td>
  186.                <td>$MTU</td>
  187.           </tr>" | Add-Content $Output
  188.         }
  189.  
  190.     }
  191.     "</table>" | Add-Content $Output
  192. }
  193.  
  194.  
  195. #Persistent Routes==========================================================================================================================
  196.  
  197. Function Get-PersistentRoutes {
  198.  
  199.     param([string]$ComputerName)
  200.  
  201.     "<h3>Persistent Routes:</h3>
  202.        <table>
  203.        <tr>
  204.            <td class='bold'>Route:</td>
  205.            <td class='bold'>NetMask:</td>
  206.            <td class='bold'>Gateway:</td>
  207.            <td class='bold'>Metric:</td>
  208.        </tr>
  209.    " | Add-Content $Output
  210.  
  211.  
  212.     $reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', "$ComputerName")
  213.     $SubKey = $reg.OpenSubKey('System\\CurrentControlSet\\Services\\Tcpip\\Parameters\\PersistentRoutes')
  214.  
  215.     foreach($Key in $SubKey.GetValueNames()){
  216.     $string = $key -replace ",","</td><td>"
  217.     "<tr><td>$string</td></tr>" | Add-Content $Output
  218.     }
  219.  
  220.     "</table>" | Add-Content $Output
  221.  
  222. }
  223.  
  224. #Processor Info==========================================================================================================================
  225. Function Get-ProcessorInfo {
  226.  
  227.     param([string]$ComputerName)
  228.  
  229.     "<h3>Processor Information:</h3>
  230.    <table>
  231.    <tr>
  232.        <td class='bold'>Processor:</td>
  233.        <td class='bold'>Cores:</td>
  234.        <td class='bold'>Logical Processors:</td>
  235.    </tr>
  236.    " | Add-Content $Output
  237.  
  238.     $wmi = Get-WmiObject -Class Win32_Processor -ComputerName $ComputerName
  239.  
  240.     foreach($processor in $wmi){
  241.  
  242.         $Name = $processor.name
  243.         $NumberOfCores = $processor.NumberOfCores
  244.         $NumberOfLogicalProcessors = $processor.NumberOfLogicalProcessors
  245.  
  246.         "<tr>
  247.            <td>$Name</td>
  248.            <td>$NumberOfCores</td>
  249.            <td>$NumberOfLogicalProcessors</td>
  250.        </tr>" | Add-Content $Output
  251.         }
  252.  
  253.     "</table>" | Add-Content $Output
  254. }
  255.  
  256.  
  257.  
  258. #RAM Info==============================================================================================================================
  259. Function Get-RAMInfo {
  260.  
  261.     param([string]$ComputerName)
  262.  
  263.  
  264.     "<h3>Memory (RAM) Information:</h3>
  265.    <table>" | Add-Content $Output
  266.  
  267.     $wmi = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $ComputerName
  268.     $RAM = [math]::round($wmi.TotalPhysicalMemory / 1024 / 1024 / 1024)
  269.  
  270.  
  271.     "<tr>
  272.        <td class='bold'>RAM:</td>
  273.    </tr>
  274.    <tr>
  275.        <td>$RAM.00 GB</td>
  276.    </tr></table>
  277.    " | Add-Content $Output
  278. }
  279.  
  280. #Windows========================================================================================================================================
  281. Function Get-WindowsInfo{
  282.     param([string]$ComputerName)
  283.  
  284.  
  285.     "<h3>Windows Information:</h3>
  286.    <table>
  287.    <tr>
  288.        <td class='bold'>Item:</td>
  289.        <td class='bold'>Status:</td>
  290.    </tr>
  291.    " | Add-Content $Output
  292.  
  293.  
  294.     #Operating system version------------------------------------------------------------------------------------------------------
  295.     $wmi = Get-WmiObject -Class Win32_OperatingSystem -ComputerName $ComputerName
  296.     $OSVersion = $wmi.Caption
  297.     $BitType = $wmi.OSArchitecture
  298.     $ServicePack = $wmi.ServicePackMajorversion
  299.  
  300.     if($ServicePack -gt 0){
  301.     "<tr><td>Operating System</td><td>$OSVersion Service Pack $ServicePack</td></tr>" | Add-Content $Output
  302.     }
  303.     else{
  304.     "<tr><td>Operating System</td><td>$OSVersion</td></tr>" | Add-Content $Output
  305.     }
  306.     "<tr><td>OS Architecture</td><td>$BitType</td></tr>" | Add-Content $Output
  307.  
  308.  
  309.  
  310.  
  311.  
  312. #Application Info===============================================================================================================================
  313. Function Get-Applications {
  314.  
  315.     param([string]$ComputerName)
  316.  
  317.  
  318.     "<h3>Application Information:</h3>
  319.    <table>
  320.    <tr>
  321.        <td class='bold'>Application:</td>
  322.        <td class='bold'>Status:</td>
  323.    </tr>
  324.    " | Add-Content $Output
  325.  
  326.  
  327.     Function Check-Service {
  328.         param([string]$Service)
  329.  
  330.         $serv = Get-Service -ComputerName $ComputerName -Name $Service -ErrorAction SilentlyContinue
  331.         if($serv.status -ne "Running"){return $false}
  332.         else {return $true}
  333.     }
  334.  
  335.     #Active Client----------------------------------------------------------------------------------------
  336.     $AcSharedStore = Check-Service -Service "ac.sharedstore"
  337.     if(Test-Path "\\$ComputerName\C`$\Program Files\ActivIdentity\ActivClient\acsagent.exe"){
  338.         if($AcSharedStore){"<tr><td>Active Client</td><td>Installed</td></tr>" | Add-Content $Output}
  339.         else{"<tr><td>Active Client</td><td>Not Functioning Properly</td></tr>" | Add-Content $Output}
  340.     }
  341.     else {"<tr><td>Active Client</td><td>Not Installed</td></tr>" | Add-Content $Output}
  342.  
  343.  
  344.     #McAfee----------------------------------------------------------------------------------------------
  345.     $McAfeeAuditManager = Check-Service -Service "McAfeeAuditManager"
  346.     $McAfeeDLPAgentService = Check-Service -Service "McAfeeDLPAgentService"
  347.     $mfefire = Check-Service -Service "mfefire"
  348.     $McAfeeFramework = Check-Service -Service "McAfeeFramework"
  349.     $HipMgmt = Check-Service -Service "HipMgmt"
  350.     $EnterceptAgent = Check-Service -Service "enterceptAgent"
  351.     $McShield = Check-Service -Service "McShield"
  352.     $McTaskManager = Check-Service -Service "McTaskManager"
  353.     $Mfevtp = Check-Service -Service "mfevtp"
  354.     if(Test-Path "\\$ComputerName\C`$\Program Files\McAfee\Host Intrusion Prevention\McAfeeFire.exe"){
  355.         if($McAfeeAuditManager -and $McAfeeDLPAgentService -and $mfefire -and $McAfeeFramework -and $HipMgmt -and $EnterceptAgent -and $McShield -and $McTaskManager -and $Mfevtp){"<tr><td>McAfee</td><td>Installed</td></tr>" | Add-Content $Output}
  356.         else {"<tr><td>McAfee</td><td>Not Functioning Properly</td></tr>" | Add-Content $Output}
  357.     }
  358.     else {"<tr><td>McAfee</td><td>Not Installed</td></tr>" | Add-Content $Output}
  359.  
  360.  
  361.     "</table>" | Add-Content $Output
  362.  
  363. }
  364.  
  365.  
  366.  
  367. #End the HTML Document==========================================================================================================================
  368. Function End-HTML {
  369.     "</BODY></HTML>"  | Add-Content $Output
  370. }
  371.  
  372. QA-Server server123
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement