• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 549
  • Last Modified:

Process Monitor Date \ Time \ Command Line Data

Hi Everyone,

I am trying to output the process command line and date but the date format is in US, although running get-culture returns UK status.  There are two things I need to knowm, how I can change the date format to dd/mm/yyyy hh:mm:ss and to format the output to a readable table format. here is the script I have put to gether :

$a =  gwmi win32_process -computername localhost

$a | foreach-object{ $_.Name + " " + $_.commandline + " " + $_.ConvertToDateTime( $_.CreationDate )}
0
CaussyR
Asked:
CaussyR
1 Solution
 
footechCommented:
If you want to be able to display it in a table format, you really need to keep the output as objects with their properties.  If you just output everything as strings then it's much less flexible, and will be subject to formatting problems due to the variable length of the information you want to output.  Using Select-Object and calculated properties is a good choice here.

I'm a little curious why you chose a WMI query to retrieve process information here instead of Get-Process.  It adds a little complexity to converting the datetime info.  But here's a method to get it in your desired format.
$a | Select Name,commandline,@{n="CreationDate";e={$_.ConvertToDateTime($_.CreationDate).ToString("dd/MM/yyyy HH:mm:ss")}}

Open in new window

0
 
CaussyRAuthor Commented:
Thank you very much...
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now