Solved

Powershell Format-List problem

Posted on 2007-11-20
3
1,049 Views
Last Modified: 2012-06-27
Hi,

I am running the following powershell command:


get-alert | where {$_.ResolutionState -eq 0 } | Format-List MonitoringObjectDisplayName,Name,ResolutionState,RepeatCount,TimeRaised


Which displays the following:

MonitoringObjectDisplayName : SQL1
Name                        : The SQL Server Service Broker or Database Mirroring
                               transport is disabled or not configured
ResolutionState             : 0
RepeatCount                 : 1
TimeRaised                  : 20/11/2007 6:41:23 PM

The problem is the TimeRaised field is no in LocalTime, it is GMT time I suspect. I want to convert it
to my local time. (In my case GMT+10) if I try the following it does not work

get-alert | where {$_.ResolutionState -eq 0 } | Format-List MonitoringObjectDisplayName,Name,ResolutionState,RepeatCount,TimeRaised.ToLocalTime()


MonitoringObjectDisplayName : SQL1
Name                        : The SQL Server Service Broker or Database Mirroring
                               transport is disabled or not configured
ResolutionState             : 0
RepeatCount                 : 1

** No TimeRaised field **

Any suggestions on the syntax to make this work?

Thanks,

Ward
0
Comment
Question by:whorsfall
  • 3
3 Comments
 
LVL 18

Accepted Solution

by:
BSonPosh earned 500 total points
ID: 20322860
You can use calculated fields for Format-List

Format-List MonitoringObjectDisplayName,Name,ResolutionState,RepeatCount,@{l="TimeRaised";E={$_.TimeRaised.ToLocalTime()}}
0
 
LVL 18

Expert Comment

by:BSonPosh
ID: 20322904
FYI: For more info on Calculated Properties look at help for format-table (it works the same.)
PS> get-help format-table -full
0
 
LVL 18

Expert Comment

by:BSonPosh
ID: 20322957
I just saw your post on NG :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now