Capturing Virtual Machine Blue Screens via Powershell


Eric Sloof at ntpro.nl has a nice post on how to capture screen shots of virtual machine blue screens using Powershell.  You can find the code here.

He then incorporated a Powershell script from Carter Shanklin that pushes a screenshot through Microsoft Office Document Imaging Library (MODI), OCR software found in Office 2003+, to extract the text from the image.

Very nice. Definitely go download his application, the Virtual Machine Blue Screen Detector.  Detailed post here.

The final product, which reads out the BSOD can be found here.

Powershell script to change from static to dynamic IP addressing


I’ve been working on validating an email server migration plan which has required utilizing test servers isolated from the production network.  Because they are offnet, I have to frequently switch my laptop from the production to test networks, which involves reconfiguring my network card from dynamic to static IP addresses.

I could use Windows XP’s alternate IP addressing capability to change IP addresses, but I find it takes several minutes for XP to make the automatic changeover.  I wanted to create a configuration script that would make the desired changes so that I could save shortcuts to those scripts on my desktop, which would allow for quick NIC setting modifications.

I originally tried to use the netsh command to specify NIC settings, but despite all the example syntax I found online, I was only able to get the static to dynamic changes to work, not the dynamic to static.

I finally decided to use Powershell to make these changes.  I found the following scripts at PowerShell Pro and modified them ever so slightly for my own use.

### set static IP addressing – save as setstatic.ps1
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration `
| where{$_.IPEnabled -eq “TRUE”}
Foreach($NIC in $NICs) {
  $NIC.EnableStatic(“192.168.1.5”, “255.255.255.0”)
  $NIC.SetGateways(“192.168.1.254”)
  $DNSServers = “198.168.1.1”,”198.168.1.1″
  $NIC.SetDNSServerSearchOrder($DNSServers)
  $NIC.SetDynamicDNSRegistration(“FALSE”)
}
###

### set dynamic addressing – save as setdynamic.ps1
$NICs = Get-WMIObject Win32_NetworkAdapterConfiguration `
| where{$_.IPEnabled -eq “TRUE”}
Foreach($NIC in $NICs) {
 $NIC.EnableDHCP()
 $NIC.SetDNSServerSearchOrder()
}
###

I then created shortcuts to the two .ps1 files using the following targets:

%windir%\system32\WindowsPowerShell\v1.0\powershell.exe c:\scripts\setdynamic.ps1

%windir%\system32\WindowsPowerShell\v1.0\powershell.exe c:\scripts\setstatic.ps1

I saved each shortcut to my desktop, and now I can switch IP addresses in about 15 seconds.

Getting started with Powershell for system administration


SynJunkie has written a nice, detailed post that shows some of the administrative tasks that can be performed with Powershell.  He shows how to perform many different system administration functions, from editing the registry to filtering event logs.

If you’ve never used Powershell before, I’d recommend you check it out.  It’s a free download from Microsoft, and is available for Windows XP and Windows Vista, Windows Vista x64, Windows Server 2003, and Windows Server 2003 x64.  Powershell is built into Windows Server 2008.

You can also download the Windows PowerShell 1.0 Documentation Pack. The Documentation Pack includes the Windows PowerShell Getting Started Guide, the Windows PowerShell Primer, the Windows PowerShell Language Quick Reference, and Windows PowerShell V1.0 Release Notes.

The Windows PowerShell Quick Reference, which is a quick reference guide to commonly-used Windows PowerShell commands, is also available as a separate download.  You can also get the Windows PowerShell Graphical Help File, which is the Windows PowerShell help in graphical help format (.chm file).

Lastly, Frank Koch has written two Powershell books that are available as a free download.  The first one is subtitled “An introduction to scripting technologies for people with no real background knowledge”, and is available here.  The second book focuses on server administration, and can be found here.

Posted in script. Tags: . 2 Comments »

Running Powershell On Windows Server 2008 Core


While being an unwilling participant in an excessively long conference call I was able to get Powershell up and running on my Server Core box, thanks to Dmitry’s detailed instructions.

Of course this is an unsupported configuration, which means Microsoft won’t help you if you experience problems.

VMware VI Toolkit for Windows Beta is now available


The VMware VI Toolkit for Windows Beta is now available for download. The toolkit provides cmdlets for managing, monitoring, automating, and handling life-cycle operations for VMware Infrastructure components – virtual machines, datacenters, storage, networks, etc.

Less experienced administrators can use PowerShell commands included in the VI Toolkit to manage their VMware virtual infrastructure from the command line. Advanced administrators can develop PowerShell scripts that may be reused by other administrators or integrated into other applications.

The VI Toolkit for Windows 1.0 ships with 101 cmdlets: 97 PowerShell-based cmdlets and 4 Microsoft .NET cmdlets for use through PowerShell – The so called Web Service Access Cmdlets.

You can launch the VI Toolkit (for Windows) Console in one of two ways:

  1. From the Start menu, click Programs > VMware > VMware Infrastructure Toolkit > VMware VI Toolkit.
  2. Double-click the desktop icon (if you have chosen the option at installation). The VI Toolkit console window opens in a PowerShell window.

For more information see the VI toolkit for Windows Admin guide or the VMware community discussions. Don’t forget to download and install Windows Powershell before using this toolkit.

Howto: Filter Message Tracking logs in Microsoft Exchange using Powershell


Today I’ve been working with a vendor, trying to figure out why not all of my client’s users are receiving a certain notification email. I enabled message tracking in Exchange 2003, but it creates a log file that’s in a fairly unreadable format.

I found this post that describes using the Microsoft Log Parser utility to run SQL queries against the message tracking logs. Even after reading the documentation and unofficial Log Parser reference site, I was having difficulties constructing the queries; I just wanted to know who received the email and what date and time they got it.

WindowsITpro.com had an article on Log Parser, but since I don’t subscribe to their site, I only got the first few paragraphs of the article.

This batch file generator gave me too much information. It seemed like exporting this information was way more difficult than it should have been.

Then I came across this Powershell script Glen wrote that generates a form that allows you filter the message tracking log files based on your criteria. It took all of three minutes to download and run, and I was able to save the information into a .csv file. Brilliant!

One more thing… if you want to use message tracking on an Exchange 2000 cluster, see Microsoft KB327977. And if your inetinfo.exe utilization suddenly goes through the roof, check out Microsoft KB811409. Both of these issues appear to be resolved in KB813840.

[updated 06-29-2007]

I found another Exchange log search tool. It doesn’t use Powershell, and I haven’t used it personally, but I would love to hear if it works or not.