/\/\o\/\/ PowerShelled

This blog has moved to http://ThePowerShellGuy.com Greetings /\/\o\/\/
$AtomFeed = ("Atom.xml")
$PreviousItems = (" MSH get-dateFormat function "," Working with a Path in MSH "," MSH MSN Instant messenger project (broken off) "," Running (Un-block) a downloaded script in MSH "," Timing the loading of your profile in MSH "," Tuning MSH in your Profile "," Einstein 2 + subtopic. "," Burn MSH ?? "," Monad and Adam (and a preview of my to-be AD provi... "," Windows MineSweeper cheat "," ")

Tuesday, November 29, 2005


Logging your MSH session

It's Easy to log a session in MSH,

you just use start-transcript and stop-transcript.

MSH>gc "C:\Documents and Settings\mow\My Documents\msh_transcript.20051129213303.txt"
MSH Transcript Start
Start time: 20051129213303
Username : CP340339-A\mow
Machine : CP340339-A (Microsoft Windows NT 5.1.2600 Service Pack 2)
Transcript started, output file is C:\Documents and Settings\mow\My Documents\msh_transcript.20051129213303.txt
MSH Transcript End
End time: 20051129213308

You may have seen the big list of supported date formats in last post, that we could parse to a date-object ....

Now ....guess what .... this one was not on the List ;-(

So An example of using -Match and [dateTime]::Parse to get a "real" date from the used dateformat in the Logfile :

MSH>"20051129213308" -match "(....)(..)(..)(..)(..)(..)"

Tuesday, November 29, 2005 9:33:08 PM

so now you have a "real" date object to work with,
the regex is a bit lazy becouse I just used "." (any Char), ofcourse its better to check on Digits, just liked the example of using -match (b.t.w. could not do this with Match-string) and then using the Matches with a RangeOperator, showing the flexbility there.

*edit* Sorry, another Edit in 5 minutes but I realy did think I was to lazy,
here is the "better" version (checking for digits) :

MSH>"20051129213308" -match "(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})"

Tuesday, November 29, 2005 9:33:08 PM

but normal I still think I would prefer a RegEx-Object for this work.

$regex = new-object System.Text.RegularExpressions.regex("pattern")

You can than use the Replace Method of it, also I had a bit of problems with match-string doing this.
and the replace flexibility I like, also I know it a bit better from .NET and VBScript.But I did not play with match-string enough yet to make it final ;-), and I think the RegEx does deserve a blog entry on his own (altough you can find a lot of info on using regEx, already just try a Search in google)

anyway for small checks -match is ideal, and seems to work better as match-string.

Ohh, and yeah this was about logging, that works easy in Monad, altough I would have picked another date format for it ;-)

gr /\/\o\/\/

Anonymous Lee
You can also investigate the [DateTime]::ParseExact method from the .Net framework:


MSH:9 C:\Program Files\Microsoft Command Shell >[DateTime]::ParseExact("20051129213308",
>> "yyyyMMddHHmmss",
>> [System.Globalization.CultureInfo]::InvariantCulture)

Tuesday, November 29, 2005 9:33:08 PM
Blogger DontBotherMeWithSpam
i am wondering if i am the only person who can't get an info (get-help) on "start-transcript"...

I only have to figure out what to do from the command definition only...

But I think it's pretty intuitive what to do just from the definition though.
Post a Comment

Links to this post:

Create a Link

<< Home


October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   May 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006   December 2006  

$Links = ("PowerShell RC1 Docs"," PowerShell RC1 X86"," PowerShell RC1 X64"," Monad GettingStarted guide"," Monad Progamming Guide"," Monad SDK"," Monad videos on Channel 9"," MSH Community Workspace"," scripts.readify.net "," MonadSource"," www.reskit.net"," PowerShell Blog"," Under The Stairs"," computerperformance powershell Home"," proudlyserving"," MSH on wikipedia"," MSHWiki Channel 9"," Keith Hill's Blog"," Precision Computing"," PowerShell for fun"," MSH Memo (Japanese)"," monadblog")

find-blog -about "PowerShell","Monad" | out-Technorati.
find-blog -contains "","" | out-Technorati.
Web mow001.blogspot.com

This page is powered by Blogger. Isn't yours?