Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

Using Windows PowerShell to Determine if a Laptop Is on Battery Power

  Microsoft Scripting Guy Ed Wilson here. It is time for another road trip. This time we are heading to Asheville, North Carolina for the Blue Ridge Classic Horse Show. Somewhere deep in my Scripting Guy lineage is an association with Kentucky, which is considered a horse state. Horse shows are really cool. My significant other and I went...

How to Add Data to an XML File Using Windows PowerShell

(image) Hey, Scripting Guy! I need to be able to use Windows PowerShell to add data to an XML file. Unfortunately, there is no Add-XML cmdlet available. I thought about using the Windows PowerShell Add-Content cmdlet and trying to write my data to the file, but it never worked correctly. I never could get all of those angle thingies to line up...

Writing Double Quotation Marks to a Text File Using Windows PowerShell

  (image) Hey, Scripting Guy! I need to be able to write double quotation marks to a text file using Windows PowerShell. I know that in VBScript it was really annoying to do this because the quotation marks ended up getting confused with the quotation mark that was used to indicate the start of a string; when the next quotation mark was...

Deleting Extra Returns and Line Feeds from a Text File Using Windows PowerShell

  (image) Hey, Scripting Guy! Is it possible to use Windows PowerShell to groom a text file by deleting extra returns and line feeds it may contain? Here is the deal. I have a file that we need to download each day. This file contains updated prices for commodities used in our manufacturing operation. We use the updated commodity ...

Parsing an AuditPol.exe Report with Windows PowerShell 2.0

  (image) Hey, Scripting Guy! I have been using AuditPol.exe to verify the audit policy that is configured on our network. The problem is that the report that is generated has a lot of text, and it is not easy to see exactly what is being audited or not. Is it possible to use Windows PowerShell 2.0 to parse the report generated by ...