Posts Tagged ‘Write-Progress’
Thursday, June 18th, 2009 by Jeffery Hicks
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.  
More »
Tags: powershell, scripting, wmi, Write-Progress, XML
Posted in Howto, Windows PowerShell | Comments Off
Thursday, March 19th, 2009 by Jeffery Hicks
I love that part of my job is helping people out in the forums as ScriptingAnswers.com. A recent post asked about finding out what network drives were mapped on a remote computer using PowerShell. The task sounded familiar so I poked around my script pile and found an old VBScript that used WMI and the Win32_NetworkConnection class. Great. Get-WMIObject to the rescue:
Get-WMIObject win32_networkconnection -computername Desk23
You even get a nicely formatted summary. But you me, I can't resist tinkering so I wrote a function that enhances this basic command I call Get-NetConnection  
More »
Tags: ErrorActionPreference, function, Network, powershell, regular expression, Trap, Win32_Netconnection, wmi, Write-Progress
Posted in Windows PowerShell | 2 Comments »
Monday, March 2nd, 2009 by Jeffery Hicks
In a recent discussion in the PowerShell forum at ScriptingAnswers.com, a member was trying to parse the HOSTS file on a number of desktops. This is a thankless but probably useful task that seems perfectly suited to a scripted solution. What we came up with was a way to turn entries in the HOSTS file to objects in PowerShell. Once we have an object then we can do all sorts of fun things with it. Here is an enhanced version of the original solution.  
More »
Tags: HOSTS, New-Object, Ping, powershell, Regex, Regular Expressions, scripting, Write-Progress
Posted in Windows PowerShell | 4 Comments »
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 »
Tags: Add-Member, automation, com, function, Microsoft Word, New-Object, objects, powershell, scriptblock, scripting, Write-Progress
Posted in Windows PowerShell | Comments Off
Thursday, August 14th, 2008 by Jeffery Hicks
While getting caught up on my podcast back log I was listening to an episode of Mind of Root. In it Steven Murawski mentioned my Get-Packet and Analyze-Packet PowerShell scripts. One of his (legitimate) issues with Analyze-Packet was the way it presented results. The original version simply wrote information to the console. It didn't use a good object model so that you could format the results the way you wanted. I took this as a challenge to improve the script.  
More »
Tags: Add-Member, DNS, Network Trace, New-Object, Packet, powershell, scripting, sniff, Write-Progress
Posted in Windows PowerShell | 3 Comments »