Windows PowerShell v2: TFM on its way!

SAPIEN Press has once again joined forces with Don Jones and Jeffery Hicks to bring you the latest and greatest information on Windows PowerShell, version 2. Windows PowerShell: TFM, in its third edition, will be released shortly after the release of Windows 7 and Windows PowerShell v.2. The text and the sample code will be […]

Read More

July PowerShell One-Liner

This month’s PowerShell one-liner queries the WMI Win32_Product class for a specified computer and builds a formatted report of all installed applications sorted by vendor. You’ll be able to tell at a glance what is installed, when it was installed, where it was installed from and the product version. Be warned that querying this WMI class may take several minutes or longer.

This one line expression defaults to the local computer, but you can substitute any computername you want. You can also add support for alternate credentials. I’ve broken the expression into several lines for publication purposes but this is in fact a oneline expression.

Read More

Inventory Report to XML

Lately I seem to be answering a number of PowerShell XML related questions. When that happens I figure its time for an example. I have a script that I think originally was posted in a forum. I apologize that I didn’t note where it came from. But I’ve enhanced it (as I am likely to do). The script reads a bare bones XML file of computernames and builds a new XML file with inventory information such as operating system, computer system, logical disks and more retrieved from WMI. My script will hopefully serve as examples for working with XML files. I also use Write-Progress so that you can track what the script is doing.

Read More

Special Forces Training Needs You!

In case you missed it, I’ll be doing our Windows PowerShell Special Forces training in Columbus, OH at the end of next month. In addition to the normal 3 day class, I’ll also be offering a bonus 2 day class for more experienced PowerShellers covering advanced topics and managing Active Directory. If you are inclined, you can also sign up for the entire week at a discount.

Classes will be held at in the friendly offices of Quest Software, but space is limited because these are very intense, hands-on sessions. If you’ve been putting off getting training, don’t wait any longer. This is the most unique training event I think you’ll ever experience.

Read More

Select-PropertyValue

Because PowerShell is all about the objects, I often point out to beginners to use the Select-Object cmdlet to see all the properties of an object and their values.

get-process powershell | select *

Using Get-Member is helpful to discover property names but sometimes you need to see a value to know which property or properties you really want to work with. That’s where my Select-Object suggestion comes in. Unfortunately not every property is defined for every object so you can end up with a lot of empty properties. What I wanted was a way to only display properties for an object that have a value. Here’s my solution.

Read More

Write PowerShell Scripts for YOU!

I’m often training administrators to use Windows PowerShell or offering guidance in a number of forums. As you might imagine I see a lot of code samples. Of course I help with the immediate challenge, but often I see opportunities where a few slight tweaks to the code layout can make a difference in readability and troubleshooting. Here’s what I’m talking about.

Read More

Updated PowerShell TreeForm

Not too long ago I wrote a blog post about a Windows Form PowerShell script to display a folder tree. I got some feedback about an error when running the script. The problem was that I was casting a variable in one of the functions to a specific type. Normally this is considered a best practice. But in this situation the [System.Windows.Forms.TreeNode] class depends on the parent class being loaded in your PowerShell session. Even though I thought I had tested thoroughly on PowerShell v1 and v2 I must have missed something and the [System.WIndows.Forms] class was getting loaded into my shell prior to running the script, which is why I never saw the error. Anyway, I’ve since modified the problematic function to remove the type casting.

Read More

VBScript Includes

I’ve been using VBScript for a very long time. One drawback it has always had as a scripting language is an INCLUDE statement. In other languages you can use something like INCLUDE scriptfile at the beginning of the script. This would load any functions and variables in the specified script file into your current script. In PowerShell we can accomplish this by dot sourcing scripts. I never knew of a way to do the same thing with VBScript until now.

Read More

Search

Enter any query and press enter
Advanced search operators:
+ ⟶ Term must appear
- ⟶ Term must not appear
"" ⟶ Exact string must appear
How do I use these?

Join our mailing list

Enter your email address to subscribe to our mailing lists for Monthly Blog Digests, Product Announcements and more (you can choose which you receive once you sign-up!)

Tags

Categories

Archives

Dashboard