Solved

Powershell Format-List problem

Posted on 2007-11-20
3
1,081 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

630 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