Windows Power Shell Commands
Windows Power Shell Commands
networking tasks can save a lot of time. This is true not only because you can script the tasks for
application on multiple computers, but you also save time by not having to navigate through
sometimes complex user interface (UI) dialog boxes when you use PowerShell to configure
individual computers. Following are some PowerShell commands for basic tasks that many IT
Administrators perform on a regular basis, and I thought they might help you get started with
PowerShell too.
After you install Windows Server 2012, the computer is assigned an automatically generated
name. In most cases, you won't want to keep the random name, you'll want to assign a name for
the computer that matches your organization's naming conventions. Instead of navigating
through all of the Windows UI to rename and restart the computer, try opening Windows
PowerShell and typing the following commands, making sure to replace "ComputerName" with
the actual name that you want to use:
Rename-Computer ComputerName
Restart-Computer
Most servers are configured with a static IP address rather than having DHCP client enabled and
receiving an IP address dynamically from a DHCP server. You can use the command below to
configure the Internet Protocol version 4 (IPv4) properties of a network connection with a static
IP address. Before running this command, ensure that you replace the example parameter values
with values that are appropriate for your network.
If you add a DNS server to your network, you can use the following command to configure IPv4
properties of a statically configured network connection with the IP address of the new DNS
server.
To join a computer to a domain, you can run the following command after replacing the domain
name with one that's appropriate for your deployment:
Restart-Computer
Install Active Directory Domain Services (AD DS) and DNS and create a new domain in a
new forest
If you have a test environment, you probably recreate it on a frequent basis for new
configurations and new tests. Or you might be setting up a new organization domain and
network. Either way, the following commands install AD DS and DNS with a new forest, new
root domain, and domain name of corp.contoso.com to help you speed-install these roles.
Note that you can install all of the Windows Server 2012 server roles by using the command
Install-WindowsFeature, which really streamlines the configuration of servers.
After you install DNS, it's recommended that you create a DNS Reverse Lookup Zone. You can
use the following command to configure a reverse lookup zone for a network with the network
ID 10.0.0.x:
You can use the following command - after you change the parameter values - to create a new
user account in Active Directory. Keep in mind that when you run this command, you'll need to
type in the password value at the Windows PowerShell prompt, so this particular method of
using this command is not intended for use in scripts.
If you want to assign Active Directory Group membership to the account you just created, you
can use this next command. This example assigns group membership to both Enterprise Admins
and Domain Admins, so make sure you change these values and the domain name when you use
the command, if these are not the memberships and name that you want to assign.
Add-ADPrincipalGroupMembership -Identity
"CN=User1,CN=Users,DC=corp,DC=contoso,DC=com" -MemberOf "CN=Enterprise
Admins,CN=Users,DC=corp,DC=contoso,DC=com","CN=Domain
Admins,CN=Users,DC=corp,DC=contoso,DC=com"
Note 3: PowerShell assumes that the value immediately after the command is the feature to
install, thus explicitly adding -Name is optional.
http://www.computerperformance.co.uk/windows_server/add-windowsfeature.htm