Active Directory W2008 R2 – Remove DNS record with Powershell and WMI
The Simplest way of removing a DNS record from your active directory is using WMI.
With Server 2008 R2 you can use powershell to get the record by setting a filter for the domainname and pipe the object to the wmiobject remove routine like this:
'WMI Query - DNS Remove Windows 2008 R2 Server - Powershell Example Get-WmiObject -ComputerName [YourAD-DNSServer] -Namespace 'Root\MicrosoftDNS' -class MicrosoftDNS_AType -Filter "domainname = '[E.G.:YourComputerName]'" | remove-wmiobject
There are several online solutions available, but most of them use the wrong namespace and wrong filter parameter.
This one workls perfectly.
Ensure that you are using an administrative powershell with domainadmin privileges.
SCCM – Delete computer object via powershell and wmi [edit]
After one hour of research i found a solution on how to delete a computer object in sccm from a remote computer via Powershell. First of all you need to get the computer object from your sccm namespace "ROOT\SMS\site_[yoursite] -> SMS_R_SYSTEM.
All machine items are stored in SMS_R_SYSTEM, so i used a wmi query with a filter to get the object i need.
There are several ways you can get the computer object, another example is a WMI query, that returns the object.
// Powershell $compObject = get-wmiobject -query "select * from SMS_R_SYSTEM WHERE Name='[computername]'" -computername [sccm-server] -namespace "ROOT\SMS\site_[yoursite]"
You should check if the $compObject is empty or not and if not you can just use psbase to delete the object from the sccm server completly (not only from the collection) by using this statement
// Powershell $compObject.psbase.delete()
How to deal with multiple objects [edit]
Special thanks to Leeni, who wrote a comment at this post on how to deal with multiple entries at your SCCM server. If your WMI query returns more than one object you have to handle this a bit different.
To check if your query returned more than one object try this:
$compObject.psbase.length
or
$compObject.psbase.syncroot
Both properties are only set if your result contains more than one object, so you can easily check if these objects are empty or not.
If they are not empty you have to delete your $compObject this way
$compObject.psbase.syncroot | % { $_.delete() }
This pipes your syncroot object to a foreach loop (% is an alias for foreach) and delete every object one after another.
McAfee Uninstaller v0.1
Ich habe ein kleines Programm geschrieben um den McAfee Agenten / Virusscan Enterprise auf dem System zu deinstallieren, oder die Epo GUID neu zu setzen. Je nach dem, ob McAfee Prozesse beendet werden dürfen wirft das Programm einen Hinweis, dass der Dienst vorher erst beendet werden muss, bevor die Deinstallation durchgeführt werden kann.
Deinstalliert werden kann VSE 8.0, 8.5, 8.7 und 8.8, sowie der McAfee Agent.
Über die Hilfe bekommt man die Kommandozeilenparameter
Das ganze wurde in AutoIt entwickelt und mit SciTe kompiliert. Im Anhang findet ihr den Sourcecode.
Was ihr noch benötigt sind die resourcefiles von hier: http://www.autoitscript.com/forum/topic/51103-resources-udf/ und separate Icons.
Anbei das AU3 Script, sowie das Formfile für das Programm coda
Hier die Form1.kxf und die mcafeeuninstall.au3