Delete CCM Namespace remotely with PowerShell

Get-WmiObject -query “Select * From __Namespace Where Name=’CCM'” -Namespace “root” -ComputerName COMPUTERNAME.DOMAIN | Remove-WmiObject

Copy and paste friendly:

Get-WmiObject -query "Select * From __Namespace Where Name='CCM'" -Namespace "root" -ComputerName COMPUTERNAME.DOMAIN | Remove-WmiObject

Another way to do it, since the pipe “|” is not batch file friendly, is to create a file DeleteCCMns.mof:

#pragma namespace("\\\\.\\Root")
#pragma deleteinstance("__Namespace.Name='CCM'", FAIL)

This way the mof file can be copied to a remote machine and then run mofcomp.exe by using psexec.

copy DeleteCCMns.mof \\%1\admin$\system32
psexec -s \\%1 mofcomp DeleteCCMns.mof



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s