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

From https://social.technet.microsoft.com/Forums/en-US/b137b6c1-bee8-49ad-a97a-9f1d4cc5200d/code-to-delete-rootccm-namespace

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

w

Connecting to %s