Posts Tagged ‘objects’
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.   More »
Good, Better, Best
Thursday, May 21st, 2009 by Jeffery Hicks
I'm very happy to see more and more people getting their hands dirty with Windows PowerShell. A common challenge I see across different support forums is getting information from one part of a script to another. Very often the user has created a function and is attempting to use its output elsewhere in their script. Often I can tell the scripter is coming from a VBScript background or at least thinking that way. There's nothing necessarily wrong with writing a PowerShell script in a VBScript style, but these scripts are missing out. Let me walk you through several iterations of a function to demonstrate.   More »
Sometimes an Apple is an Orange
Thursday, May 7th, 2009 by Jeffery Hicks
I was helping a member out in the PowerShell forum at ScriptingAnswers.com. He was trying to create a multistring registry entry on a remote computer using the .NET registry classes. Creating registry values is really not that complicated. Here's a short example.   More »
Get Local Member
Thursday, April 9th, 2009 by Jeffery Hicks
I've been dealing with the topic of enumerating local group membership in several PowerShell forums from different people. My responses have pretty much been the same. But if these people are asking its a safe bet there are others who are also in need. The bottom line has been to query a local group, typically Administrators, and return a list of group members. If the member is a domain account, then get a little extra information. I put together a script called Get-Localmember.ps1 that I think will get the job done for most of you.   More »
Objects in motion
Tuesday, December 2nd, 2008 by Alex Riedel
Writing scripts to automate administrative tasks can be challenging. Not only do you need to master the particular scripting language you intend to use, you…   More »
More fun with Microsoft Word and PowerShell
Friday, August 15th, 2008 by Jeffery Hicks
I needed a demonstration for one of my last online PowerShell classes on using COM objects in PowerShell. I took an old VBScript that used Microsoft Word to get document statistics such as word and page count and transformed it into PowerShell. I quickly realized I could flesh out the demo into a larger function that I can actually use. Given that I generate a lot of Word docs, being able to get some document statistics is helpful. So I created a function called Get-DocStatistic.   More »
Analyze-Packet
Monday, July 14th, 2008 by Jeffery Hicks
If you've been trying out the Get-Packet script you've seen that there is a great deal of information. I wanted an easy way to analyze the data so I put together a script called Analyze-Packet that will slice and dice a saved network trace and produce a summary report.   More »
How can I write a PowerShell function that outputs a table?
Wednesday, February 20th, 2008 by Don Jones
This is a REALLY common question, and if you have any experience with VBScript, or Perl, or some similar scripting language, you'll go down completely…   More »