I’ve been working on my second training course for Train Signal on managing Windows Server 2008 with Windows PowerShell, specifically the lesson on managing processes. I thought I’d share a little tidbit I worked out. In fact, I hope you’ll stay tuned for other little goodies over the next several weeks. The training video will…
Windows PowerShell Fundamentals Video Training
I’m very happy to report that my first training offering for Train Signal is now available. I have assembled a course that should cover just about everything you need to know to get started right away using Windows PowerShell. You can get the course online or on disk. If the disks are like other train signal courses,…
Select Object Properties with Values
Here’s another concept I know I’ve written about in the past but that needed an update. A common technique I use when exploring and discovering objects is to pipe the object to Select-Object specifying all properties, get-service spooler | select *. There’s nothing wrong with this approach but depending on the object I might get…
Friday Fun Export Transcript to Script
Over the years I’ve posted variations on this technique and discuss it often in my training classes. The idea is to take your PowerShell transcript and transform it into a PowerShell script. Remember that there is very little difference between running commands in the shell and in a script. Thus, any commands that have been…
Verbose or Debug?
This morning there was some discussion on Twitter about when to use Write-Verbose and when to use Write-Debug. They both can provide additional information about what your script or function is doing, although you have to write the code. Typically, I use Write-Verbose to provide trace and flow messages. When enabled, it makes it easier…
Friday Fun Add Scripting Signing to the ISE
Today’s fun involves adding a menu item to the PowerShell ISE to make it easy to sign your scripts. I’m not going to go into the details about getting and installing a code signing certificate. I also assume you only have one installed. You can get this certificate by seasrching the CERT: PSDrive. [cc lang=”PowerShell”]…
Filtering Empty Values in PowerShell
I saw this tip today and wanted to leave a comment but couldn’t see how. So I thought I’d post my comments here. This is actually a question I see often and there are better ways to write this kind of code. The posted tip used an example where you wanted to find processes where…
ByValue, I Think He’s Got It
Recently I responded to an email from a student seeking clarification about the difference between ByValue and ByProperty when it comes to parameter binding. This is what makes pipelined expressions work in Windows PowerShell. When you look at cmdlet help, you’ll see that some parameters accept pipeline binding, which is what you are looking for….
Friday Fun Re-Run Last Command
Ok, I’ll be the first to admit you might not find a production use for this tip, but that’s what makes it fun. Interactively, you can always hit the up arrow to get the last command in your command buffer. But what if you are running a script and for some reason want to re-rerun…
Get Shared Resource
I was poking around WMI the other day in PowerShell and was intrigued by the Win32_Share class. This is a great way to find out what items are shared on a server such as printers and folders, although it’s not limited to those types of resources. I thought this would make a useful function; one…
Friday Fun PowerShell PowerBall Numbers
Like many of you, I dream about hitting the lottery and retiring to live the good life. Unfortunately I rarely play so I guess my odds are winning are pretty slim. But for the latest installment of Friday Fun, I thought I would have PowerShell help me pick some numbers for PowerBall. It is not…
Find Non System Service Accounts with PowerShell and WMI
As easy as Get-Service is to use in PowerShell, it has one limitation for IT Pros: it can’t show you what account the service is running under. In old school terms, “What is the service account?” Fortunately you can get that information using WMI. Here’s a query you can use that takes advantage of some…
Get Top Level Folder Usage
This is too long to tweet, even written as a one liner. But this will search a folder for top level subfolders and return the file usage for each. [cc lang=”PowerShell”] $folder=”S:\” dir $folder | where {$_.psIscontainer} | foreach { $stat= dir $_.fullname -recurse | Measure-Object -property length -Sum New-Object PSObject -property @{Folder=$_.FullName;Files=$stat.count;Size=$stat.Sum;}} [/cc] Again,…
Get Properties with Values
One of my nuisance issues when using WMI with Windows PowerShell, is that when looking at all properties I have to wade though many that have no value. I’d prefer to only view properties that have a populated value. Here’s one way.
ScriptingGeek Savings This Weekend
This weekend you can save some money on gear and tees from ScriptingGeek.com. Coupon Code: StarSavings Discount: $5 off any order! Coupon Code: BrightSavings Discount: $10 off subtotal of $50+ Coupon Code: SpangledSavings Discount: $30 off subtotal of $100+ Disclaimer: Please enter coupon code StarSavings, BrightSavings, or SpangledSavings before completing checkout. Discount is applied to…