Chapter 27. Enterprise Computer Management
27.0 Introduction
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.
27.1 Join a Computer to a Domain or Workgroup
Problem
You want to join a computer to a domain or workgroup.
Solution
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
Discussion
The Add-Computer
cmdletâs name is fairly self-descriptive: it lets you add a computer to ...
Get PowerShell Cookbook, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.