Powertip Of The Day-getting installed updates

Source: Internet
Author: User

Original article address:Http://app.en25.com/e/es.aspx? S = 1403 & E = 4914 & elq = a3fdfdb4961d4feabec6e309570c5e33

Original article:

Powershell is great for parsing log files. here is a function that extracts all installed Windows updates from an internal log file and returns the information as pure powershell objects. have a look as this Code uses a number of powerful parsing and Wrapping Techniques:

Function get-Updates {
Get-content $ ENV: WinDir \ windowsupdate. Log -Encoding Utf8 |
Where-Object { $_ -Like '* Successfully installed *' } |
Foreach-Object {
$ Info = $ _. Split ( "'T" )
$ Hash = @{}
$ Hash . Installdate = [ Datetime ] $ Info [6]. Remove ( $ Info [6]. Lastindexof ( ":" ))
$ Hash . Product = $ Info [-1]. Split ( ":" )[ - 1]. Trim ()
New-Object Psobject -Property $ Hash
}
}

Get-Updates

 

Translation:

PowershellIt is very powerful in converting log files. The following functions extract all installedWindows updatesAnd use the informationPowershellObject display in a more pure way. BelowCodeSome very powerful conversion and packaging techniques are used:

Function get-Updates {
Get-content $ ENV: WinDir \ windowsupdate. Log -Encoding Utf8 |
Where-Object { $_ -Like '* Successfully installed *' } |
Foreach-Object {
$ Info = $ _. Split ( "'T" )
$ Hash = @{}
$ Hash . Installdate = [ Datetime ] $ Info [6]. Remove ( $ Info [6]. Lastindexof ( ":" ))
$ Hash . Product = $ Info [-1]. Split ( ":" )[ - 1]. Trim ()
New-Object Psobject -Property $ Hash
}
}

Get-Updates

 

 

Notes:

If you useGet-content $ ENV: WinDir \ windowsupdate. LogThe output information will be very messy.WhereAfter filtering and retrieving only some key columns and converting the data, it looks clearer.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.