Chapter 27. Enterprise Computer Management


When working with Windows systems across an enterprise, this question often arises: “How do I do <some task> in PowerShell?” In an administrator’s perfect world, anybody who designs a feature with management implications also supports (via PowerShell cmdlets) the tasks that manage that feature. Many management tasks have been around longer than PowerShell, though, so the answer can sometimes be, “The same way you did it before PowerShell.”

That’s not to say that your life as an administrator doesn’t improve with the introduction of PowerShell, however. Pre-PowerShell administration tasks generally fall into one of several models: command-line utilities, Windows Management Instrumentation (WMI) interaction, registry manipulation, file manipulation, interaction with COM objects, or interaction with .NET objects.

PowerShell makes it easier to interact with all these task models, and therefore makes it easier to manage functionality that depends on them.

Join a Computer to a Domain or Workgroup


You want to join a computer to a domain or workgroup.


Use the -DomainName parameter of the Add-Computer cmdlet to add a computer to a domain. Use the -WorkGroupName parameter to add it to a workgroup.

PS > Add-Computer -DomainName MyDomain -Credential MyDomain\MyUser
PS > Restart-Computer


The Add-Computer cmdlet’s name is fairly self-descriptive: it lets you add a computer to a domain or workgroup. Since a domain join only ...

Get Windows PowerShell Cookbook, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.