Solved

Powershell Format-List problem

Posted on 2007-11-20
3
1,065 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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Active DirectoryScript to change the Pager Field 1 90
Disk Ram Peak 1 54
Questions about this React unit test 4 70
Remote Exchange powershell returns different results 12 42
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…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

679 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