Advertisement
Guest User

AMT Vulnerability script part 2 updated

a guest
Dec 26th, 2017
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $Path = "C:\TempPath\intelamt\results"
  2.  
  3. If (Test-path("$Path\Summary.csv")) {
  4. }
  5. Else {
  6.     New-Item -ItemType "file" -Path "$Path\Summary.csv"
  7. }
  8.  
  9. $Computers = (get-childitem $Path -dir).fullname
  10.  
  11. ForEach ($Computer in $Computers) {
  12.     $Files = (get-childitem $Computer)
  13.     ForEach ($File in $Files) {
  14.         If ($File.name -like "*.xml") {
  15.             $Vulnerable = Select-String -Path $File -SimpleMatch "<System_Risk>"
  16.         }
  17.         If ($File.name -eq "log.txt") {
  18.                 $Matches = @("talk to LMS","Error when talking to LMS","Failed to unprovision","Failed to get General AMT Settings","AMT reports Unauthorized")            
  19.                 ForEach ($Match in $Matches) {                 
  20.                     $Unprovisioned = (Select-String -Path $File -SimpleMatch $Match)                   
  21.                     If ($Unprovisioned){
  22.                         break
  23.                     }
  24.                 }              
  25.         }
  26.         If ($File.name -eq "scdisabled.txt") {     
  27.             $LMSDisabled = Select-String -Path $File -SimpleMatch "[SC] ChangeServiceConfig SUCCESS"
  28.             $LMSInstalled = Select-String -Path $File -SimpleMatch "The specified service does not exist as an installed service"                  
  29.         }  
  30.     }
  31.    
  32.     If ($Vulnerable) { 
  33.         $IsVulnerable = $Vulnerable.line -replace'[,]',''  
  34.     }
  35.     If ($Unprovisioned) {  
  36.         $IsUnprovisioned = "Failed to unprovision" 
  37.     }
  38.     Else {
  39.         $IsUnprovisioned = "unprovisioned"
  40.     }
  41.     If ($LMSDisabled) {
  42.         $IsLMSDisabled = "LMS service is disabled"
  43.     }
  44.     Else { 
  45.         $IsLMSDisabled = "Failed to disable LMS service"   
  46.     }
  47.     If ($LMSInstalled) {   
  48.         $IsLMSInstalled = "LMS service not installed"  
  49.     }
  50.     Else {
  51.         $IsLMSInstalled = "LMS service is installed"
  52.     }
  53.     $HostName =(Get-Item $Computer).Name
  54.     $PCSummary = "$HostName,$IsVulnerable,$IsUnprovisioned,$IsLMSDisabled,$IsLMSInstalled"
  55.     Add-Content "$Path\Summary.csv" $PCSummary
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement