วันพฤหัสบดีที่ 6 กรกฎาคม พ.ศ. 2560

Scripts Power Shell :Loop For Check Install KB

Scripts Power Shell :Loop For Check Install KB 

          เนื่องจากมีลูกค้าต้องการเช็คว่า ผู้ใช้งานของลูกค้าเองมีจำนวนมาก และยังขาด Tools ที่เข้ามาช่วยในการบริหารจัดการ หรือถึงไม่สามารถบริหารจัดการได้ทั่วถึง แต่ลูกค้าต้องการทราบข้อมูล ในช่วงที่มี Ransomware WannaCry ว่ามีคอมพิวเตอร์เครื่องไหนที่ Update Patch ไปแล้วบ้าง เลยทำการเขียน Scripts ไว้เพื่อทำการกวาดข้อมูลของเครื่องผู้ใช้งาน ของลูกค้าเองครับ



###-----------------------------------------------------------###
###--------Author : Mr.Yingkamol Prukrattanakul----###  
###---MCP, MCSA, MCSE, MCT, MCST, SEC+----###
###------Email<yingkamol_7@hotmail.com>--------###
###----------------------------------------------------------###
###/////////////////////////////..........\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\###
###///////////////////////////////......\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\###



function Hotfixreport
    {
$computer = Get-Content D:\IPlist.csv
$MS17010= 'KB4012598', #Windows XP, Vista, Server 2003, 2008
               'KB4018466', #Server 2008
               'KB4012212', 'KB4012215', 'KB4015549', 'KB4019264', #Windows 7, Server 2008 R2
               'KB4012214', 'KB4012217', 'KB4015551', 'KB4019216', #Server 2012
               'KB4012213', 'KB4012216', 'KB4015550', 'KB4019215', #Windows 8.1, Server 2012 R2
               'KB4012606', 'KB4015221', 'KB4016637', 'KB4019474', #Windows 10
               'KB4013198', 'KB4015219', 'KB4016636', 'KB4019473', 'KB4016871', #Windows 10 1511
               'KB4013429', 'KB4015217', 'KB4015438', 'KB4016635', 'KB4019472' #Windows 10 1607, Server 2016
$ErrorActionPreference = 'Stop'


ForEach ($computer in $computers)

         {

        try
            {

            $PATCH = Get-HotFix -cn $computer  | out-string -stream | select-string -pattern $MS17010
            $PATCH  >> "$env:USERPROFILE\Desktop\PATCH.txt"
            }

        catch

            {
            $NOPATCH = "System NOPATCH:$computer"
            $NOPATCH | Write-Warning
            $NOPATCH >> "$env:USERPROFILE\Desktop\NOPATCH.txt"
            }
         
        }

    }
Hotfixreport > "$env:USERPROFILE\Desktop\Hotfixreport.txt"

ไม่มีความคิดเห็น:

แสดงความคิดเห็น