Trevor Sullivan's Tech Room

Minding the gap between administration and development

Posts Tagged ‘win7’

Checking Status of a Windows 7 System Image

Posted by Trevor Sullivan on 2011/12/30

If you’re running Windows 7, you may periodically create a “System Image” which is essentially just a VHD backup of your system. When you invoke the task, you will be presented with a dialog box similar to the following, which shows the progress of the backup:


If you are scripting something, and want your script to proceed when the backup has completed, you can run this command line:

wbadmin.exe get status

This program will "block" (continue running) and report progress, as a percentage, until the backup has completed.



Posted in tools | Tagged: , , , , , , , | Leave a Comment »

ConfigMgr: You Receive Error 0x80070490 in a Capture Task Sequence

Posted by Trevor Sullivan on 2011/10/24

If you ever work with Operating System Deployment (OSD) in Microsoft’s System Center Configuration Manager (SCCM / ConfigMgr) 2007, you might build a task sequence that only performs an OS image capture (as opposed to an OS build & capture). You might think — logically — that you only need a single task sequence step to perform this action: a “Capture Operating System Image” step. Unfortunately, this isn’t the case. If you attempt to run a task sequence like this, you’ll probably receive a 0x80070490 error code, which means “element not found.”


Read the rest of this entry »

Posted in configmgr, OSD | Tagged: , , , , , , , , , , , | Leave a Comment »

Restricting Settings by Active Directory Site with Only One GPO

Posted by Trevor Sullivan on 2011/06/30


Have you ever wanted to configure a setting using a single Active Directory (AD) Group Policy Object (GPO), but have a different value for each logical AD “site” in your IT environment? Well, even if you haven’t, there are other folks out there that do. Here is a paraphrased version of an inquiry that I received recently:

“I am working on a Windows 7 deployment, and I would like to have custom wallpapers depending on the physical location. This I am able to do but there are 20+ Active Directory sites and can do it with a GPO assigned to each site. However, it would be easier to manage just a single GPO. Is this possible?”

In short, this person wants 20+ different wallpapers, but doesn’t want to have to create 20+ unique GPOs in order to configure the wallpaper. The most common suggestion in this case, at least historically, would probably be to write a custom user-based logon script (as opposed to a computer startup script) that checks the current AD site, and sets the wallpaper based on that. Granted, that would be a pretty solid solution, however with Group Policy Preferences (GPP), we have another option that requires no knowledge of scripting!

Let’s explore how to use Group Policy Preferences to consolidate multiple desktop wallpaper configurations (per AD site) into a single GPO!

Read the rest of this entry »

Posted in Active Directory, tools | Tagged: , , , , , , , , , , , | 2 Comments »

Silently Installing the Windows 7 AIK

Posted by Trevor Sullivan on 2011/02/08

So I’m working on some automated lab build “stuff” and I tried to silently install the Windows 7 AIK using a simple call to msiexec. Apparently there is something built into the Windows 7 AIK MSI package that prevents it from being installed non-interactively. This is a bit frustrating.

Upon execution of the msiexec command, I received a message in the MSI log, stating: “This MSI can only be installed with full UI.”


I would surmise that, with some MSI hacking, or using a transform, this behavior could be circumvented.

Update (2011-02-09)

Simon and Samuel both posted a solution in the comments. You can use a transform included in the WAIK, like this:

msiexec /i waikx86.msi TRANSFORMS=”waikx86.mst” /qn
msiexec /i waikamd64.msi TRANSFORMS=”waikamd64.mst” /qn

Thanks for the help folks!

Posted in configmgr, OSD, tools | Tagged: , , , , , , , , , , , | 6 Comments »

Removing Permanent WMI Event Registrations

Posted by Trevor Sullivan on 2011/01/18


Since I’ve worked on the PowerEvents PowerShell module, several folks have been confused about how to remove event registrations once they’ve been created. I wrote some documentation that’s included in the download, that explains how to manually remove these registrations using the built-in wbemtest tool. This is the fool-proof method, since wbemtest is included in every Windows installation.

In the interest of making things easier, however, I wrote a WinForms utility in C# a little while back. This utility simply enumerates the various permanent event objects in the WMI repository (filters, consumers, and bindings), and allows you to remove them. That’s all it does 🙂

In the remainder of this blog post, I’ll talk about the manual method of removing event objects, and show you the utility I just mentioned.

The Manual Method

While experimenting with the PowerEvents module, you might accumulate many WMI event filter and consumer objects. At some point, you’ll probably want to clear those out. As of this writing, the PowerEvents module needs further work on the Get-* and Remove-* advanced functions. Until this functionality can be implemented, use the following procedure to remove the filter/consumer bindings.

Here are the individual steps to remove an unwanted event binding:

  1. Open wbemtest as an administrator
  2. Click Connect
  3. In the Namespace field, type root\subscription
  4. Click Connect or press {ENTER}
  5. Click Enum Instances
  6. Type __FilterToConsumerBinding in the text box
  7. Click OK or press {ENTER}
  8. Click the binding instance you want to remove
  9. Click the Delete button

Upon removal of the __FilterToConsumerBinding instance, the consumer will no longer respond to events. This process can be repeated to remove filters and consumers. Rather than enumerating instances of __FilterToConsumerBinding however, you would use “__EventFilter” or any of the five consumer class names.

The WMI Event Helper Utility

The utility I wrote a little while back is intended to display all filters, consumers, and event bindings to you, so that you can remove them from a friendly GUI. Although it works quite well in my personal testing, the tool has one important limitation, albeit it probably won’t affect most people.

The Limitation

In its current form, it does not allow you to specify a WMI namespace where the event objects reside. As I said, most folks should be OK, but you should be aware that you can create WMI filter objects in ANY WMI namespace, not just root\subscription (the default). The out-of-box consumer instances can be created in either root\default or root\subscription (latter is default). Finally, event bindings can be created in ANY WMI namespace.

Unless you’re explicitly specifying an alternate WMI namespace when creating the various WMI event objects, you won’t be affected by this. Just be aware that, if you’re a power user, you might want to make sure you don’t have event objects in other namespaces.

The Tool

Here’s what the tool looks like:


As you can see, it lists filters, consumers, and bindings in the root\subscription namespace. You might notice that above the consumer list, there’s a “Consumer Type” combo box. By clicking the arrow, or scrolling through the list using your mouse scroll wheel (the control must have focus), you can select the Consumer Class that you want to enumerate instances of.

Simply click on the item you want to delete, and select the appropriate “Remove” button. That’s all there is to it!

You can download the WMI Event Helper utility on the PowerEvents project page.


This blog post has covered the removal of WMI permanent event objects both manually, and using a C# event management utility. For more information, please review the comprehensive documentation included in the PowerEvents module release download.

Posted in .NET, powershell, scripting, wmi | Tagged: , , , , , , , , , | Leave a Comment »

PowerShell Module: Enable Wake for Devices

Posted by Trevor Sullivan on 2010/09/23

So in my last post, I shared a PowerShell script that enables you to enable devices to wake up computers. This script relies solely on a WMI interface, but despite the remote nature of WMI, I had provided no method of entering a remote computer name. That changes with the release of my first ever formal PowerShell module! I’ve taken the code from the “enable device wake” script and adapted it to a PowerShell advanced function. I also added the cmdlet binding attribute to it, which makes it an official script cmdlet.

This command more or less replaces the functionality that powercfg.exe -DeviceEnableWake offers.

It has full support for:

  • Script example documentation
  • Named and positional parameters
  • Supports -WhatIf and -Confirm common parameters
  • Configuring remote computers

Download Set-DeviceWake v1.0


Here is an example screenshot of the script’s execution. Please let me know if you have any feedback in the comments or at! As I said before, this is the first PowerShell module that I’ve shared, and I want to make sure it’s done right!

Running on Multiple Computers

(Updated on 2010-09-28)

So, you might be wondering how you can deploy this to multiple computers. The ComputerName parameter only takes a single computer name, rather than an array. You basically have three options here:

  1. Run from management workstation: Wrap the Set-DeviceWake function in a foreach loop, and pipe a text file with a bunch of computer names into the ForEach-Object
  2. Run from management workstation: Wrap the Set-DeviceWake function with Start-Job and a list of computer names
  3. Run on each PC individually: Deploy the script to target workstations via GPO (if they’re Windows 7), or deploy via systems management software, such as ConfigMgr

I don’t have examples handy just yet, but just thought I’d share this information at least!

Posted in .NET, powershell, scripting, tools, wmi | Tagged: , , , , , , , , , , | Leave a Comment »

ccmsetup.exe: Trailing slash in “Source” parameter

Posted by Trevor Sullivan on 2010/08/05

Hello everyone!

Tonight, while I’m traveling in Houston, Texas, I wrestled with ccmsetup.exe for a little while. I was working on getting a ConfigMgr vNext client agent installed on a Windows 7 Ultimate virtual machine, and kept getting a message in my ccmsetup.log saying “Source <path> is inaccessible.


A little bit about %~dp0

Now, whenever I build installer packages for software, whether to run manually, or distribute through ConfigMgr, I generally wrap the commands inside a simple batch file, so I don’t have to constantly type out the entire command, or forget what a particular parameter should be set to.

Because I write lots of simple batch files, and use these packages from both UNC paths, as well as local installs, I use a nifty batch trick: %~dp0. Without going into too much detail, if you use %~dp0 in a batch file, it will reference the folder in which the batch file resides, including a trailing slash. For example, if you want to run a MSI package from a local or UNC path, you could write a dynamic batch file like so:

msiexec /i “%~dp0MyPackage.msi” /quiet

In the above command, the double quotes will take care of any spaces in the path, and the %~dp0 will reference the folder path in which the batch file itself resides. This command also assumes that a Windows Installer package called “MyPackage.msi” resides in the same folder alongside the batch file. Using %~dp0 is great, because no matter where I copy an entire package folder, I always know that I can execute a batch file, and it will use appropriate relative pathing to find the supporting files necessary to run the command.

Anyway, that’s enough history about %~dp0 and why I use it!


The Trailing Slash Issue

Installing the ConfigMgr client is generally quite simple: you can simply execute ccmsetup.exe by double-clicking it, or invoking it, with no parameters from a script. In this circumstance, however, I needed to specify the source folder for where to get the files, otherwise ccmsetup.exe was going to point to my ConfigMgr 2007 management point, rather than the ConfigMgr vNext management point that I wanted it to get the files from. Instead of using the /MP parameter, I elected to simply point ccmsetup.exe to the specific folder where the source files resided (on the ConfigMgr network share).

Naturally, since I was building my agent install batch file right inside the client folder on the site server (\\vnext01\sms_vnx\client), I simply used “%~dp0” to point ccmsetup.exe to its own folder (which was a UNC path). The command I placed into the batch file was the following:

“%~dp0ccmsetup.exe” /retry:1 /source:”%~dp0″ FSP=vnext01.ts.loc

Upon execution of this batch file, is when I experienced the “inaccessible source” error message in ccmsetup.log, as described in my opening paragraph. After encountering this issue, I experimented with a number of different permutations of the command line, none of which worked really. I finally realized that, as best I can tell, ccmsetup.exe appeared to be incorrectly parsing the value passed to the /source parameter. If you include a trailing slash on the <path> you pass to /source, then ccmsetup.exe will actually use the remainder of the command line as the <path>. This is very bad!

In short, if you want ccmsetup.exe to succeed at finding its source files, you must not include a trailing slash on the value you feed into the /source parameter!

The only scenario I have not yet tested, is passing a <path> to /source, that has a trailing slash, but does not have double-quotes around the path. I always recommend using double-quotes for any command-line value that may have spaces in it, so I would not really even consider this scenario, other than for the sake of testing.



Well, I hope this has given some of you some insight into a potential problem, and maybe even saves you a few gray hairs by finding this on Google, instead of stressing over what you are doing wrong. It appears to be a small software bug, and I’m somewhat surprised that no one else seems to have encountered it, but there’s a first time for everything, right?

If you have any feedback, or would like to ask a question, feel free to leave a comment on this article, or e-mail me directly at


Update: If you’d like to help out by recreating the issue, posting your comments, upvoting the bug report on Microsoft Connect, that would be fabulous! Make sure you log into Microsoft Connect, join the ConfigMgr vNext Beta Program, and then click the following link:

If you can reproduce the issue, make sure to click the “I can too” link on the above page.

Posted in configmgr, ConfigMgr vNext, fixes | Tagged: , , , , , , , , , , | Leave a Comment »

AutoIT: Enumerating all Windows

Posted by Trevor Sullivan on 2010/04/09

Here is a short script I wrote using AutoIT, which enumerates all of the windows, to the StdOut stream:

ConsoleWrite(“Enumerating windows”)
$AllWindows = WinList()
ConsoleWrite(“Found ” & UBound($AllWindows) & ” windows”)
for $i = 0 to UBound($AllWindows) – 1
ConsoleWrite(@lf & “Name: ” & $AllWindows[$i][0])
ConsoleWrite(@lf & “HWND: ” & $AllWindows[$i][1])
ConsoleWrite(@lf & “Completed listing windows.”)

Note: Please ensure that you check the “console” option when compiling this script for execution. If you do not check this box, there will be no StdOut stream created, which means you will get no output.

Posted in scripting, tools | Tagged: , , , , , , , , , , , | Leave a Comment »

Handy Process Management Utilities

Posted by Trevor Sullivan on 2009/12/17

Hey guys,

I just wanted to share a couple of cool utilities to assist with managing processes.

ImageCFG (

ImageCFG is a utility that lets you tweak the CPU affinity of an executable. What does this mean? Well, if you have a multi-core system, or even a hyper-threaded (virtual multi-core) system, you can restrict which cores a process can execute on. This may be desirable if there is a program that tends to hog processor time, such as a video editing application, and you want to allow it to run, but only on a restricted set of resources.

Prio (

Although I haven’t used Prio yet, it looks to be a great, free (for personal use) program. A couple of features it offers are:

  • Save process priority settings – useful if there’s a program you always want to run in low priority / background mode
  • Always elevate certain processes – maintain good security with UAC, and convenience at the same time!
  • TCP / IP task manager tab – lets you view open network connections in real-time through task manager


I had a need for a piece of the Prio tool, but didn’t need the entire toolset (or be able to use it freely for commercial use), so I wrote a small C# utility called “SetProcessPriority” that does just what I need it to, instead. This utility searches for a process by it’s friendly name (eg. ‘notepad‘, but without the ‘.exe’) every 2 seconds, and sets the process’ priority to “Below Normal.” This was necessary to server as a work-around to a software bug I was having with the Microsoft ConfigMgr console.

Here is the C# code for it:

using System;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;

namespace SetProcessPriority
    class Program
        static void Main(string[] args)
            if (args.Length != 1) return;

            string procname = args[0];
            while (1 == 1)
                    Process[] procs = Process.GetProcessesByName(procname);
                    foreach (Process proc in procs)
                        proc.PriorityClass = ProcessPriorityClass.BelowNormal;
                catch { }

You can compile the above code in Visual Studio 2008, targeting the .NET 2.0 framework. Once you’ve compiled it into a .NET assembly, you can simply write a batch script to call it, like this:

SetProcessPriority notepad


Anyway, I hope this post helps someone out, out there!

Merry Christmas to all!

Posted in scripting, tools | Tagged: , , , , , , | Leave a Comment »

Deploying Windows 7 RSAT

Posted by Trevor Sullivan on 2009/11/19

If you’ve got a large number of Windows 7 machines that you’ve already deployed, but now need to silently deploy the Remote Server Administration Tools (RSAT), you’re in luck. It’s quite simple to do, and Microsoft provides the necessary tools to automate this deployment.

The RSAT pack is downloaded as a MSU file, so it is more or less treated like other Windows Updates. Normally, you can just double-click an MSU file to install it, but to automate working with MSU Windows Update files, on Vista and later, we use the wusa.exe utility. Once the RSAT is installed, it must be enabled manually by the end user, in the “Programs and Features” Control Panel applet. To automate working with Windows Features, we use the dism.exe (Deployment Image Servicing and Management Tool) utility.

Download the RSAT 64-bit or 32-bit file, to a folder on your computer. Create a batch file called InstallRsat64.cmdin the same folder, and open it with your favorite text editor, and place the following in its contents:

wusa "%~dp0amd64fre_GRMRSATX_MSU.msu" /quiet /norestart /log:"%WINDIR%\Logs\RSAT Install (64-bit).log"
dism /Online /Enable-Feature /FeatureName:RemoteServerAdministrationTools /FeatureName:RemoteServerAdministrationTools-ServerManager /FeatureName:RemoteServerAdministrationTools-Roles /FeatureName:RemoteServerAdministrationTools-Roles-CertificateServices /FeatureName:RemoteServerAdministrationTools-Roles-CertificateServices-CA /FeatureName:RemoteServerAdministrationTools-Roles-CertificateServices-OnlineResponder /FeatureName:RemoteServerAdministrationTools-Roles-AD /FeatureName:RemoteServerAdministrationTools-Roles-AD-DS /FeatureName:RemoteServerAdministrationTools-Roles-AD-DS-SnapIns /FeatureName:RemoteServerAdministrationTools-Roles-AD-DS-AdministrativeCenter /FeatureName:RemoteServerAdministrationTools-Roles-AD-DS-NIS /FeatureName:RemoteServerAdministrationTools-Roles-AD-LDS /FeatureName:RemoteServerAdministrationTools-Roles-AD-Powershell /FeatureName:RemoteServerAdministrationTools-Roles-DHCP /FeatureName:RemoteServerAdministrationTools-Roles-DNS /FeatureName:RemoteServerAdministrationTools-Roles-FileServices /FeatureName:RemoteServerAdministrationTools-Roles-FileServices-Dfs /FeatureName:RemoteServerAdministrationTools-Roles-FileServices-Fsrm /FeatureName:RemoteServerAdministrationTools-Roles-FileServices-StorageMgmt /FeatureName:RemoteServerAdministrationTools-Roles-HyperV /FeatureName:RemoteServerAdministrationTools-Roles-RDS /FeatureName:RemoteServerAdministrationTools-Features /FeatureName:RemoteServerAdministrationTools-Features-BitLocker /FeatureName:RemoteServerAdministrationTools-Features-Clustering /FeatureName:RemoteServerAdministrationTools-Features-GP /FeatureName:RemoteServerAdministrationTools-Features-LoadBalancing /FeatureName:RemoteServerAdministrationTools-Features-SmtpServer /FeatureName:RemoteServerAdministrationTools-Features-StorageExplorer /FeatureName:RemoteServerAdministrationTools-Features-StorageManager /FeatureName:RemoteServerAdministrationTools-Features-Wsrm

This should install all of the available RSAT components for 64-bit Windows. The code below should install the 32-bit version (just call the batch file InstallRsat32.cmd).

wusa "%~dp0x86fre_GRMRSAT_MSU.msu" /quiet /norestart /log:"%WINDIR%\Logs\RSAT Install (32-bit).log"
dism /Online /Enable-Feature /FeatureName:RemoteServerAdministrationTools /FeatureName:RemoteServerAdministrationTools-ServerManager /FeatureName:RemoteServerAdministrationTools-Roles /FeatureName:RemoteServerAdministrationTools-Roles-CertificateServices /FeatureName:RemoteServerAdministrationTools-Roles-CertificateServices-CA /FeatureName:RemoteServerAdministrationTools-Roles-CertificateServices-OnlineResponder /FeatureName:RemoteServerAdministrationTools-Roles-AD /FeatureName:RemoteServerAdministrationTools-Roles-AD-DS /FeatureName:RemoteServerAdministrationTools-Roles-AD-DS-SnapIns /FeatureName:RemoteServerAdministrationTools-Roles-AD-DS-AdministrativeCenter /FeatureName:RemoteServerAdministrationTools-Roles-AD-DS-NIS /FeatureName:RemoteServerAdministrationTools-Roles-AD-LDS /FeatureName:RemoteServerAdministrationTools-Roles-AD-Powershell /FeatureName:RemoteServerAdministrationTools-Roles-DHCP /FeatureName:RemoteServerAdministrationTools-Roles-DNS /FeatureName:RemoteServerAdministrationTools-Roles-FileServices /FeatureName:RemoteServerAdministrationTools-Roles-FileServices-Dfs /FeatureName:RemoteServerAdministrationTools-Roles-FileServices-Fsrm /FeatureName:RemoteServerAdministrationTools-Roles-FileServices-StorageMgmt /FeatureName:RemoteServerAdministrationTools-Roles-HyperV /FeatureName:RemoteServerAdministrationTools-Roles-RDS /FeatureName:RemoteServerAdministrationTools-Features /FeatureName:RemoteServerAdministrationTools-Features-BitLocker /FeatureName:RemoteServerAdministrationTools-Features-Clustering /FeatureName:RemoteServerAdministrationTools-Features-GP /FeatureName:RemoteServerAdministrationTools-Features-LoadBalancing /FeatureName:RemoteServerAdministrationTools-Features-SmtpServer /FeatureName:RemoteServerAdministrationTools-Features-StorageExplorer /FeatureName:RemoteServerAdministrationTools-Features-StorageManager /FeatureName:RemoteServerAdministrationTools-Features-Wsrm

I do realize that the line extends way off to the right, but just copy the whole thing, and you will get the entire command-line. If you have any issues with dism.exe, check out the log file located in %WINDIR%\Logs\Dism\dism.log.

Please leave any questions in the comments section below! Thanks for reading!

Posted in tools | Tagged: , , , , , , , , , , , | 11 Comments »