In the first posts I showed how you can create (Create your own MDT Webservice - Part 1, Create your own MDT Webservice - Part 2) and access (Calling a webservice from a script using MDT 2008) a simple webservice to be used in Deployments to ease access to the MDT Database.
In the last post you could find a complete set of stored procedures do manipulate the MDT Database on-the-fly (Get access to the MDT Database). Now we are going to combine this. For the ones just interested to download the stuff, find the link at the end of this post. It will include the SQL Script from the last post. Also be sure to come back regularly to this page for changes. BUT use this on your own risk! It is provided AS IS and I will not be responsible for any damage to your systems!
The rest might be interested in some additional comments on what it contains and how you can use it.
First a short description of the Webservices.
There are three webservices:
- MDT.asmx
- SCCM.asmx
- AD.asmx
The largest one gives access to the MDT Database. This publishes more or less each stored procedure from the last post. I think we can pass to repeat all 70+ functions of it. Just go through the last post for a complete list. :-)
The second will cover SCCM. It will give you access to the following functions:
- AddComputerAssociation (ReferenceComputerMacAddress, ReferenceComputerUUID, DestinationComputerMacAddress, DestinationComputerUUID, SiteCode)
Adds an association between two computers
- AddComputerAssociationByID (ReferenceComputerResourceID, DestinationComputerResourceID, SiteCode)
Adds an association between two computers by the Resource IDs
- AddComputerToCollection (MacAddress, UUID, CollectionID, ComputerName, SiteCode)
Adds a computer to the specified collection. It will also add the Computer to the SCCM Server if not already known.
- AddComputerToCollectionByID (ResourceID, CollectionID, ComputerName, SiteCode)
Adds a computer to the specified collection.
- GetAssignedSite (IPAddress, IPSubnet)
Returns the SiteCode for the given IP Address / IP Subnet
- GetEncryptDecryptKey (MacAddress, UUID)
Returns the USMT Encryption Key for a computer
- GetEncryptDecryptKeyByID (ResourceID)
Returns the USMT Encryption Key for a computer
- GetOSDAdvertisements()
Returns a list of all OSD Advertisements
- GetOSDCollections(siteCode)
Returns a list of all Collections with any advertised OSD Task Sequence
- GetOSDTaskSequences (SiteCode)
Returns a list of all OSD Task Sequences
- GetResourceID (MacAddress, UUID, SiteCode)
Returns the ResourceID of a computer if known to SMS/SCCM.
- GetStateStorePath (MacAddress, UUID)
Returns the StateStorePathfor a computer
- GetStateStorePath (ResourceID)
Returns the StateStorePathfor a computer
- GetTaskSequences (Sitecode)
Returns a list of all Task Sequences
- HasOSDAdvertisement (MacAddress, UUID, Sitecode)
Checks if an OSD Advertisement is available for the computer
- HasOSDAdvertisementByID (ResourceID, Sitecode)
Checks if an OSD Advertisement is available for the computer
- IsComputerKnown (MacAddress, UUID, SiteCode)
Checks if a given Computer is known to SMS/SCCM
And finally we have a couple of functions for Active Directory
- GetADSite ()
Returns the Active Directory site for the IP Address of the Requester
- GetADSiteByIPAddress (IPAddress)
Return the Active Directory site for the IPAddress
- GetADSites()
Returns a list of all Active Directory Sites
- GetDomains()
Returns a list of all Active Directory Domains in the Forest
- GetForest()
Returns information about the Forest
- GetSCCMAssignedSite ()
Returns the SCCM Assigned Site for the IP Address of the Requester
- GetSCCMAssignedSiteByIPAddress (IPAddress)
Returns the SCCM Assigned Site for the IP Address
- GetSCCMServerLocatorPoints
Returns a list of configured SCCM Server Locator Points
- GetSCCMSite ()
Returns the SCCM Site for the IP Address of the Requester
- GetSCCMSiteByIPAddress (IPAddress)
Returns the SCCM Site for the IP Address
- GetSCCMSiteServer ()
Returns the SCCM Default Management Point for the supplied site code
- MoveComputerToOU (Computername, OUPath)
Moves the computer to the specified OU
To use these webservices you would need to download the files and extract it to some location which you can publish as Virtual Directory with IIS. It can be set up the same way you set up the MDT Webservice. Have a look in the MDT Documentation for further information. I might add this later :-). Now find the web.config and adjust some of the settings to your environment. Find the following entries and change to appropriate values:
<appSettings>
<add key="RootServer" value="{YourSCCMRootServer}"/>
<add key="SLPServer" value="{YourSLPServer}"/>
<add key="RootSiteCode" value="{YourRootSiteCode}"/>
<add key="ADDomain" value="DC=YourDomain,DC=com"/>
<add key="ADUsername" value="Yourdomain\someAccount"/>
<add key="ADPassword" value="SomePassword"/>
</appSettings>
<connectionStrings>
<add name="MDT" connectionString="{Valid_Connection_String_To_MDT_Database}"/>
<add name="SCCM" connectionString="{Valid_Connection_String_To_SCCM_Database"/>
</connectionStrings>
ADDomain, Username and Password is only required if you want to use the AD Webservice to move computers to a different ou during or after deployment. We use this to prestage a computer in a OU without any GPO and then move it to the proper OU after the Task Sequence has finished.
The SCCM Connection String is only necessary to get the USMT StateStore Path and the Encryption Key. All other Functions will use WMI.
All Webservices use a VB.Net API which you could also use in your custom Web-Frontends. etc. Find the appropriate DLL files in the BIN folder.
And as I said last time, this is a version 1 (OK, actually it's a version 2 :-) ). It is working, but there might be issues I'm not aware of. So just come back with any problem or feedback you have. I can also include additional Functions I haven't thought of so far. Any comments are welcome.
All Files mentioned in this article are available from our new Codeplex page http://mdtcustomizations.codeplex.com/. This is a repository for MDT Scripts, Front Ends, Web services and other Utilities for use with ConfigMgr/SCCM and MDT.
Note: If you experience an error about AddDefaultSettings if you execute the sql script please download the latest sql script from the last post.
Change History:
Version 1 - published 11.02.2009: Initial Release
Version 2 - published 02.02.2009: added missing stored procedure AddDefaultSettings to the sql script.
Version 3 - published 15.03.2009: changed GetADSite, added GetADSiteByIPAddress, GetSCCMAssignedSite, GetSCCMAssignedSiteByIPAddress, GetSCCMServerLocatorPoint, GetSCCMSite, GetSCCMSiteByIPAddress, GetSCCMSiteServer
Version 4 - published 18.04.2009: added GetOSDCollections, added GetADSites, added GetDomains, added GetForest