PDQ.com mobilePDQ.com desktop

Managing Domain Memberships with PowerShell

Stephen Valdinger

Let’s go through some steps that may prove helpful in speeding up your processes in joining machines to a domain, or helping you to migrate machines to a new domain at scale. We will utilize some pretty simple PowerShell to accomplish this task. So without further ado, grab a drink, sit back, and let’s do this!

Checking Domain Membership

We need some logic to see if the machine is currently a member of a domain. That’s pretty simple with PowerShell. The code looks like this (and will return a true/false value):

(Get-WMIObject win32_computersystem).partofdomain

Removing a Machine from a Domain

This also is going to return to us a true/false value. Given that we want to put the machine on a new domain, let’s use some logic to automate removing the machine from its current domain membership.

If ( (Get-WMIObject win32_computersystem).partofdomain 

Don't miss the next post!

Using PowerShell to Install Printers

When installing printers, we will need to do the four things; Add Driver to the Store, Install the Driver, Create Printer Port, and Install the Printer