Community
cancel
Showing results for 
Search instead for 
Did you mean: 
idata
Community Manager
1,681 Views

SCCM Delete Provisioning Data from script

I am looking for a way to do a full unprovision of a provisioned SCCM client from the command. I want to do it the same way as the SCCM console does, because that will take care of all of the cleanup required so I can then re-provision them.

Tags (1)
0 Kudos
6 Replies
idata
Community Manager
44 Views

Hello,

I'd recommend writing some sort of wrapper script around the unprovisionex.exe utility provided by Intel. This tool ought to do what you're looking for.

http://communities.intel.com/docs/DOC-1763 http://communities.intel.com/docs/DOC-1763

Trevor Sullivan

Systems Engineer

OfficeMax Corporation

idata
Community Manager
44 Views

Trevor, will the unprovisionex.exe take care of all of the cleanup as well? SCCM creates an AD object for the AMT device and that needs to be deleted as part of the process. If I go into the SCCM Console and select "delete provisioning data" for a specific client, it will take care of the cleanup, the syste detects that it is not provisioned, has an auto-provision policy and re-provisions on its own.

If I can find out how SCCM performs the unprovision, I can automate the process completely.

idata
Community Manager
44 Views

Hello,

The source code for ConfigMgr isn't available, and you'd probably have to talk to Microsoft developers to figure out every detail of what it's doing when it does a full unprovision. Most of these additional actions can be easily automated with VBscript or Powershell, such as deleting the AD computer account for the AMT device, as you mentioned.

I'm not sure about automating revocation of the AMT Web Server certificate assigned to the client, but I would imagine there are APIs to tie into your Microsoft Certificate Authority.

Trevor Sullivan

Systems Engineer

OfficeMax Corporation

idata
Community Manager
44 Views

In follow-up to this, I actually discovered a method of invoking SCCM's unprovisioning command on a vPro system (or an entire ConfigMgr collection). You can perform this operation using the ConfigMgr WMI provider.

There are two key methods on the SMS_Collection WMI class that you would be interested in:

http://msdn.microsoft.com/en-us/library/dd339667.aspx AMTOperateForMachines

http://msdn.microsoft.com/en-us/library/dd339692.aspx AMTOperateForCollection

If we were to use these methods via a Powershell script, or interactive Powershell session, we would execute code that looks something like this:

-----------------------------------------------------------

# Define SCCM server

$SccmServer = 'sccmsp1'

# Define SCCM WMI provider path

$SccmNamespace = 'root\sms\site_lab'

# Define WMI class name

$SccmCollection = 'SMS_Collection'

# Define target SCCM (AMT) resource to unprovision

$AmtResourceId = "1234"

# Build WMI path string from previously defined variables

$WmiString = "\\${SccmServer}\${SccmNamespace}:${SccmCollection}"

# Get and store a reference to the SMS_Collection WMI class

$SccmCollectionClass = [wmiclass]"$WmiString"

# Perform a partial unprovision on the target resource ID

$UnprovisionResult = $SccmCollectionClass.AMTOperateForMachines($AmtResourceId, 32)

# Perform a full unprovision on the target resource ID

$UnprovisionResult = $SccmCollectionClass.AMTOperateForMachines($AmtResourceId, 64)

------------------------------------------------------------------

FYI, I have not tested the code above, and do not recommend running it in a production environment until it has been tested. Other than some possible syntax problems though, it should theoretically work. Since the AMTOperateForMachines WMI method takes an array as the first parameter, you might have to surround a non-array with @() to force Powershell to interpret it as an array ... again, I am not sure of this though, as I haven't had an opportunity to test this code.

$UnprovisionResult = $SccmCollectionClass.AMTOperateForMachines(@($AmtResourceId), 32)

Hope this helps!

Trevor Sullivan

Systems Engineer

OfficeMax Corporation

idata
Community Manager
44 Views

This was very helpful. I was able to create a VBScript that invokes this method to run the full unprovision.

idata
Community Manager
44 Views

Eschloss, I know this is an old post but is there any chance i can get a copy of your vbs for this?

Or maybe someone else has a similar script i can use?

much appreciated

thanks

Stéphane