While working on my course for TrainSignal on managing Windows Servers with PowerShell, I came up with an interesting use of the Write-Progress cmdlet. I was working on the performance monitoring lesson and realized I could use Write-Progress as rudimentary graphing tool. The cmdlet has a parameter that lets you specify a value that shows…
Tag: PowerShell
ForEach or ForEach-Object
I came across a post the other day that explained differences when using the ForEach enumerator and the ForEach-Object cmdlet. They both essentially do the same thing but as the post mentions there are potential performance differences. One other difference I want to highlight is that the ForEach enumerator doesn’t write to the pipeline at…
Ping IP Range
Last week I came across a post on using PowerShell, or more specifically a .NET Framework class, to ping a range of computers in an IP subnet. The original post by Thomas Maurer is here. I added a comment. And after looking at this again I decided to take the ball and run with it…
Running Remote Processes Here is a video…
Running Remote Processes Here is a video clip from my upcoming course for TrainSIgnal, "Windows Server 2008 PowerShell Training". This clip shows how to work with processes on remote computers.
Export Registry Printer Information I came…
Export Registry Printer Information I came across this post http://www.oncallpros.com/2011/11/02/powershell-export-your-print-configuration-from-registry/ on exporting printer information from the registry in PowerShell. I wanted to offer some constructive suggestions but could find no way to comment so I'll do so here. First, the article introduces some good PowerShell concepts. I like that he is using Test-Path. Although I'd…
My video interview with PowerShell Magazine…
My video interview with PowerShell Magazine about the state and future of PowerShell. Recorded during the PowerShell Deep Dive in Frankfurt. http://www.powershellmagazine.com/2011/11/02/an-interview-with-powershell-expert-jeff-hicks/
Simple Where Filters
The comment about how awkward it is in PowerShell to filter out folders with Get-ChidlItem, or its alias dir, came up the other day on Twitter. I’ll be the first to admit that running a DIR command and wanting to skip folders, or perhaps you only want top level folders, is more cumbersome than we…
Convert Text to Object
Today I have another tool in my new battle regarding turning command line tools into PowerShell tools. The bottom line is we want to have objects written to the pipeline. At the PowerShell Deep Dive in Frankfurt there was a suggestion about providing tools to help with the transformation from CLI to PowerShell and this…
Re-Use PowerShell Scriptblocks
//Re-Use PowerShell Scriptblocks// I commented on a blog post today that showed how to use a hash table with Select-Object to format file sizes say as KB. dir $env:temp -rec | select fullname,@{Name="KB";Expression={$_.length/1kb}} Since you most likely will want to use something similar for other directories, don't feel you have to re-invent the wheel. Save…
Turning CLI Tools into PowerShell Tools Deep Dive Demos
Last week I did a presentation at the PowerShell Deep Dive in Frankfurt about turning command line tools into PowerShell tools. A video recording should be posted later. But in the meantime, here is a copy of my slide deck, in PDF and a zip file with my demos and scripts. I have some followup…
Friday Fun Convert Object to Hash Table
I’ve been working on a few PowerShell projects recently and one requirement I had was to turn an object into a hash table. I thought this was something that was already handled in PowerShell but I couldn’t find a cmdlet or an easy .NET technique. So I wrote my own function, ConvertTo-Hashtable. The function is…
Filter Left
When writing WMI queries expressions in Windows PowerShell, it is recommended to use WMI filtering, as opposed to getting objects and then filtering with Where-Object. I see expressions like this quite often: [cc lang=”PowerShell”] get-wmiobject win32_process -computer $c | where {$_.name -eq “notepad.exe”} [/cc] In this situation, ALL process objects are retrieved and THEN filtered….
Renaming Files with PowerShell
I am not a big fan of file names with spaces. I realize they are easy to read and obviously much more “natural”, but they are simply a royal pain to deal with, especially when working from a command prompt or PowerShell. So naturally the solution is to rename these files and replace the space…
Compress Files By Extension
I never seem to build my test virtual machines with enough disk space. Which means at some point I start dealing with space issues and resort to all sorts of hacks to buy myself a little time. One thing I do is look for files that I can compact using NTFS compression. For examples text…
Friday Fun What a CHAR!
Last week I posted a PowerShell snippet on Twitter. My original post piped an array of integers as [CHAR] type using an OFS. Don’t worry about that. As many people reminded me, it is much easier to use the -Join operator. -join [char[]](116,103,105,102) I’ll let you try that on your own. The [CHAR] type is…