Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Output is missing using Regex

$
0
0

I am not getting a output when try to use get a substring.  I need to use Regex to get the KB number out of ProductName.  I need the custom label on it.

This is the broken code.

gwmi -class win32_reliabilityRecords -filter "sourcename = 'Microsoft-Windows-WindowsUpdateClient'" |
select @{LABEL = 'KB#' ; EXPRESSION = {(Select-string -Pattern '{^"KB"/w*$}' -InputObject $_.ProductName)}}|fl

I get the product name but 

gwmi -cl win32_reliabilityRecords -filter "sourcename = 'Microsoft-Windows-WindowsUpdateClient'" | select productname

I know can have code in the curly brackets.

gwmi -cl win32_reliabilityRecords -filter "sourcename = 'Microsoft-Windows-WindowsUpdateClient'" |
Select @{LABEL = "Date";EXPRESSION = {$_.ConvertToDateTime($_.TimeGenerated)}} | fl

I have one other question is this a hashtable and/or code block? 

@{LABEL = "Date";EXPRESSION = {$_.ConvertToDateTime($_.TimeGenerated)}}

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles