Reading WMI Information

When creating task sequences you’ll find yourself using alot of WMI filters to determine if a certain task needs ran on a machine. I’ve found WMI Reader to be an excellent tool to dig through WMI. It can be downloaded for free from softpedia.

Managing the dns suffix search order with a script

Recently I ran into an issue where I needed to use a script to change the DNS Suffix search order on multiple Windows XP machines instead of using a GPO (which is the preferred way).

Prior to running the script, this is what you would see when you went to the DNS tab on the Advanced section of the properties for TCP/IP on your network adapter.

Here is what happens after you run the script.
Below is the VBS script. You can easily use ConfigMgr to deploy the script.

On Error Resume NextstrComputer = “.”
arrNewDNSSuffixSearchOrder = Array(“domain1.com”, “domain2.local”)

Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!” & strComputer & “rootcimv2”)
Set colNicConfigs = objWMIService.ExecQuery _
(“SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True”)

For Each objNicConfig In colNicConfigs
strDNSHostName = objNicConfig.DNSHostName
Next

Set objNetworkSettings = _
objWMIService.Get(“Win32_NetworkAdapterConfiguration”)
intSetSuffixes = _
objNetworkSettings.SetDNSSuffixSearchOrder(arrNewDNSSuffixSearchOrder)

Set colNicConfigs = objWMIService.ExecQuery _
(“SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True”)
For Each objNicConfig In colNicConfigs Next

Modifying your primary OS partition

So here’s the scenario that got me into posting this. One of the sysadmins created a new virtual machine in VMWare by cloaning another. The original only had a 20GB drive, but he wanted it to be 40GB. He added the needed space, and then was going to use a partitioning tool to modify the OS partition. Well, he found out that VMWare didn’t like his partition tool and wouldn’t allow it to boot so at that point I pointed out that he could just use diskpart. Apparently he was under the assumption that diskpart wouldn’t allow him to mess with the primary partition… but he soon discovered otherwise. All you need to do to be able to use diskpart to manage your partitions outside of windows is do the following…

  1. Get a WinPE 2.0 disc, or a Windows Vista/7 disc
  2. On the WinPE disc, just get to command prompt, which should be super easy. On the Windows installation discs, you’ll need to select your language, click Install Now, then click SHIFT + F10.
  3. Once the command prompt is up, type diskpart. You’ll then see your prompt change from X:> to DISKPART>
  4. At this point if you don’t know what commands you need, you can go to the below link to read up on it.
    http://technet.microsoft.com/en-us/library/cc766465%28WS.10%29.aspx

Enjoy

Set file associations with a script

So I’m ashamed to be presenting a scripting technique that doesn’t use PowerShell… but I don’t have the time right now to find out how to do it in PowerShell.

I’ve come across the need to set PDF files to open using Adobe Reader instead of another program. After looking into it, I found that I can create a batch file and use the assoc command, like so.

@echo off
assoc .pdf=AcroExch.Document
Simple as that.
Enjoy