Zum Inhalt

Schlagwort: wmi

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:

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.

Weiterlesen Active Directory W2008 R2 – Remove DNS record with Powershell and WMI

Powershell – Rename domain computer remotely (within an active directory domain as well)

I wanted to rename a couple of computers within our active directory. After some research i figured out thats it seems to be nearly impossible to rename a computer by just touching one object: the ad computer object, or the computer (client) itself. My first thought was „ok, you have to rename both objects, rejoin the computer and hope everything works“. But that’s no solution, that makes me happy, because the more steps you do, the more problems can occure. For examples, what happens if the computer has to reboot, after renaming to get correct rejoined? Do i have to create a local admin account at the clientside to have permissions after the computer lost his connection to ad? And so on… I played around, renamed the ad object, rebooted it – negative, the computer has to be joined again. After that i tried it the „bottom up“ way by renaming the computer by hand, and rebooted it instantly. While the computer was shutting down i noticed, that the computerobject in active directory was renamed before the computer was finished with its shutdown process. So i tried this several times and every time the ad computerobject was renamed properly. YAY!…

Weiterlesen Powershell – Rename domain computer remotely (within an active directory domain as well)

Powershell – SCCM – Readvertise a previously installed softwarepackage remotly (not from console)

Ever came to the situation, that you have to rerun an advertisement on a computer after a failed installation with SCCM? This could happen if you want to install flashplayer or adobe acrobat or some kind of software that is frequently used by the user. We had problems on installing software while wsus was installing its updates and the msi installer said „Hmm… perhaps, another installation is running already, so I cant do anything for you (BLAME!), sorry“. I hate this message, because its a pain in the ass to readvertise these failed softwarepackages on a single computer. As some posts earlier mentioned, I am writing an administration webapplication to administrate our environment. This includes softwaredeployment too. We address our softwarepackages by Active Directory groups. Every time we create a new softwarepackage, we create a seperate computer collection in SCCM and link it to a newly created ad group. Every member of this ad group (computers for instance) gets the linked software by SCCM. While it’s a bit difficult to get some automation into the readvertisement with all these groups and links, we wrote a script, that is triggered by my webgui and does this job on the client computer…

Weiterlesen Powershell – SCCM – Readvertise a previously installed softwarepackage remotly (not from console)

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.

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

  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:

or

Both properties are only set if your result contains more than one object, so you can easily…

Weiterlesen SCCM – Delete computer object via powershell and wmi [edit]