Wait - Stop - Let's start over. I must digress a moment, please be patient as I give this former colleague of mine an appropriate introduction.
This Buckeye transplant to the state of Texas is much more then a former workmate, his legacy persists in innumerable ways. I won't take your time listing many of them, but I do have to share at least one. Notice the name of my blog? It isn't named after a South Park character, nor is it named after some pirate fetish. No this transplanted Buckeye is the source of FatBeard. He has a peculiar ability to derive nicknames that persist way beyond any code or script he has ever written. I fell prey to his moniker making over 3 years ago.
OK - now that you know how FatBeard came to be, lets move on with the PowerShell related post.
Texas asked me the following:
When I type Get-ChildItem (dir, ls) and get a file listing I want to see the LastWriteTime in Military format. Easy enough! I sent him this:
Get-ChildItem | select @{Name="LWT";Expression={"{0:d} {0:HH}:{0:mm}" -f ($_.LastWriteTime)}}
His response went something like this (paraphrased for the children in the audience) . "You obtuse gluteus maximus, why would I want to type that each and every time I need a directory listing." Admittedly, he had a point.
Thus begins my first foray into extending types. Using this as my guide (http://msdn.microsoft.com/en-us/library/ms714665(VS.85).aspx), I was able to quickly accomplish the task.
My steps were as follows:
- Navigate to C:\Windows\System32\WindowsPowerShell\v1.0 and make a copy of FileSystem.format.ps1xml
- Rename the copied file (CustomFileSystem.format.ps1xml)
- Open the renamed file and look for the
tag. - You should find something like this -
[String]::Format("{0,10} {1,8}", $_.LastWriteTime.ToString("d"), $_.LastWriteTime.ToString("t")) - As you can see, this handles the LastWriteTime formating for FileSystem related information. All we need to do is change it to meet our need. This should do -
[String]::Format("{0,10} {1,2}:{2,2}:{3,2}", $_.LastWriteTime.ToString("d"),
$_.LastWriteTime.ToString("HH"), $_.LastWriteTime.ToString("mm"),
$_.LastWriteTime.ToString("ss"))- Save the file.
- We now need to load the new formatting. Easy enough!
Update-FormatData -prependPath 'C:\WINDOWS\system32\windowspowershell\v1.0\ CustomFileSystem.format.ps1xml' - Verify your custom formatting by typing a few Get-ChildItem commands.
Now that wasn't to hard was it! Well Texas is happy now and you know how to modify object formatting (and how FatBeard came to be).
Enjoy!
1 comment:
There has a powerful conversion software, it can convert many kinds of formats, many detailed information, you can refer to this:
Rip Blu-ray for Mac is The professional Blu-ray Ripper Mac tool can help you straight Rip Blu ray DVD to MKV, MPEG, MP4, AVI, 3GP, MOV, WMV, FLV, SWF, MP3, HD MP4, HD WMV, HD AVI, MPEG4/MPEG2 TS HD video, etc.
blu-ray disc ripper ||
mac blu ray ripper ||
Blu-ray Converter
Post a Comment