PowerShell, Scripting, WDS, Windows
comments 5

Managing Windows Deployment Services (WDS) using PowerShell – Part 1

I just can’t believe that I have not written anything here for a month. There were several things that happened last month and I did not really have any energy left to write some content here. There were several interesting things I learned and experimented. Now that I am done with quite a few things, I will start (hopefully.!) writing regularly.  I will also resume the WQL series shortly.

I regularly use Windows Deployment Services (WDS) to deploy OS in my lab environment. I used WDSUtil.exe a bit to automate a few aspects of this work. However, WDSUtil spits out lot of text and using this for automation isn’t really good idea. I can use PowerShell to parse the output but it is not worth the effort. It is not easy to objectify the output of WDSUtil using PowerShell. There is a lot of flexibility in using objects than simple text. I strongly believe in “everything PowerShell” when it comes to automation. So, I started looking at Windows Deployment Server COM object model to see if I can use that in PowerShell. Looks like, I can.    

If you started Googling or Bing for any references related to WDS COM objects, give it up now. There is absolutely no documentation. So, I thought it will be good to share that information here. In this series of posts, I will write about    

  • Exploring WDS COM objects
  • Using COM objects to perform several WDS management tasks
  • Mapping between WDSUtil and COM object interfaces
  • Finally, put everything in a PowerShell module

Introduction to WDS COM object

On a server with WDS role, you can find the WdsMgmt.WdsManager COM object. If you are wondering how the heck I came to know about this, use the following code snippet.    

You can put this in your profile and use the Get-COMObjects cmdlet to see a list of COM objects on the system. Or you can use a COM object explorer. Coming back to the subject of this post, once we have the COM object, it is just a matter of exploring what all capabilities it exposes. To do that we can simply create an instance of the COM object using New-Object cmdlet.    

Now $wdsObject has an instance of WDS COM. We can see a list of all members of this instance using Get-Member cmdlet.    

Name MemberType Definition
GetDeviceManager Method IWdsDeviceManager GetDeviceManager (string)
GetDeviceManagerFromDn Method IWdsDeviceManager GetDeviceManagerFromDn (string)
GetDeviceManagerFromLdapServer Method IWdsDeviceManager GetDeviceManagerFromLdapServer (string)
GetForestDeviceManager Method IWdsForestDeviceManager GetForestDeviceManager (string)
GetImageProcessor Method IWdsImageProcessor GetImageProcessor ()
GetNewCollection Method IWdsCollection GetNewCollection (GUID)
GetValidator Method IWdsValidator GetValidator ()
GetWdsServer Method IWdsServer GetWdsServer (string)
GetWdsServers Method IWdsCollection GetWdsServers (bool)

For the sake of this introduction post, I will start with GetWdsServer().    

Since I am running WDS role on the local machine, I supplied localhost as a parameter to GetWdsServer() method. I used Get-Member again to see the member of $wdsServer and this is what I found.   

Name MemberType Definition
ConfigurationManager Property IWdsConfigurationManager ConfigurationManager() {get}
DomainName Property string DomainName () {get}
DriverManager Property IWdsDriverManager DriverManager () {get}
ImageManager Property IWdsImageManager ImageManager () {get}
Name Property string Name () {get}
PendingDeviceManager Property IWdsPendingDeviceManager PendingDeviceManager() {get}
SetupManager Property IWdsSetupManager SetupManager () {get}
TransportServer Property IWdsTransportServer TransportServer () {get}

To keep this post short, I will just briefly explain what each of these properties are and how they can be used. I will provide detailed explanation in the upcoming posts.  

Setup Manager
SetupManager interface can be used to bring up a WDS server itself.  

Configuration Manager
ConfigurationManager interface has all the elements required  

  • To start, stop and restart WDS Services
  • To enable and disable WDS Services
  • Authorize and unauthorize a DHCP scope
  • and several WDS policy related properties

Image Manager
ImageManager interface can be used to  

  • Add boot / install images and image groups
  • Delete boot / install images and image groups
  • Capture WDS images
  • Create Discovery images

Driver Manager
DriverManager interface can be used to add, remove, and manage driver packages.  

Pending Device Manager
PendingDeviceManager has the necessary interfaces to list, approve, and reject all pending or rejected or approved device deployment requests.  

Name & DomainName properties are the name of the WDS server and name of the domain where this WDS is installed. With this information handy, we will look at each of these options separately in the upcoming posts. Stay tuned.!

Filed under: PowerShell, Scripting, WDS, Windows


Ravikanth is a principal engineer and the lead architect for Microsoft and VMware virtualized and hybrid cloud solutions within the Infrastructure Solutions Group at Dell EMC. He is a multi-year recipient of Microsoft Most Valuable Professional (MVP) award in Windows PowerShell (CDM) and Microsoft Azure. Ravikanth is the author of Windows PowerShell Desired State Configuration Revealed (Apress) and leads Bangalore PowerShell and Bangalore IT Pro user groups. He can be seen speaking regularly at local user group events and conferences in India and abroad.

  • Pingback: Tweets that mention Managing Windows Deployment Services (WDS) using PowerShell – Part 1 -- Topsy.com()

  • Dwassman

    Are you still planning on completing Part 2? I am having difficultly accessing info abou the driver packages in WDS and was hoping you would cover the DriverManager.

  • I kinda gave up on this. But, I feel like going back to it when ever some one asks me this question. I will see if I can pull the DriverManager part for you. The biggest problem is the WDS COM object. It is very cryptic.

  • guest

    good post. very handy.
    though your line
    $wdsServer = $wdsManager.GetWdsServer(“Localhost”)
    should be
    $wdsServer = $wdsObject.GetWdsServer(“Localhost”)assuming you created the wds com object using your previous examples with the variable $wdsobject thanks

  • Garthm9

    Hi, I am trying to retrieve the installed boot images on a WDS server. What I have thus far is:

    $s = gc “G:testlist.txt”

    Invoke-Command -ComputerName $s -ThrottleLimit 500 { $wdsObject = New-Object -ComObject WdsMgmt.WdsManager $wdsObject | GM >> H:WDS.txt #$line1 = &’wdsutil’ /get-AllImages /Server:stwism0289 /Show:Boot $local = $wdsObject.GetWdsServer(“Localhost”) $line1 = $local.ImageManager.RetrieveBootImage(“x86”) $line1 >> H:line1.txt $line2 += $line1 |?{$_ -match “86”} $line2 >> H:line2.txt #”$($line1)” foreach ($l in $lines2){ $line = $l | ?{$_ -match “wim”} $line >> H:line.txt } “$line” } -AsJob

    Nothing is getting returned.

    When I call the objects locally, I get the following:
    PS C:Userstest> $local.ImageManager.RetrieveBootImage(“x86”)Cannot find an overload for “RetrieveBootImage” and the argument count: “1”.At line:1 char:38+ $local.ImageManager.RetrieveBootImage <<< $local.ImageManager.RetrieveBootImage
    MemberType : MethodOverloadDefinitions : {IWdsImage RetrieveBootImage (WDS_CPU_ARCHITECTURE_TYPE, string)}TypeNameOfValue : System.Management.Automation.PSMethodValue : IWdsImage RetrieveBootImage (WDS_CPU_ARCHITECTURE_TYPE, string)Name : RetrieveBootImageIsInstance : True

    Any idea how I can retrieve the boot image info?