What is Windows 2012 PowerShell?

SHARE WITH YOUR NETWORK!

Table of Contents

What is Windows 2012 PowerShell?

 

Windows Server 2012 and other operating systems (Windows 8, 8.1) have the ability to use Windows PowerShell commands that are built on .NET framework. Windows PowerShell is a powerful command line that allows administrators to perform any adding, changing of any option you see on the Graphical User Interface (GUI), and perform other manipulations that can’t be done from the GUI, thus expending the Administrators power and capabilities.

Most people will find PowerShell difficult to use and time consuming when making changes. While they can perform the same thing on the GUI, PowerShell has the ability to perform other manipulations that grant you more control, reliability, and scalability all while saving you a lot of time. For example, you can execute the same command on multiple computers and perform many tasks, which you normally do separately, in just one single line.

Windows Server 2012 comes with two versions of PowerShell:

  • PowerShell (regular version): Looks like a DOS command prompt and executes all the commands in DOS plus cmdlets that only PoweShell can perform.
  • PowerShell ISE: Enhanced version of PowerShell. Can write, test and debug in the same window, as well as support telesense which helps you to choose commands.

In this article, I will touch on a few regular and some special commands to show you the capabilities of PowerShell.

question-icons

 

Before starting, if you create a user, group, or OU name with spaces, you MUST enter it between double quotes i.e.: “My City OU”

 

-Creating an Organizational Unit (OU)

Creating-an-Organizational-Unit-Windows-Powershell

 

 

-Creating a user inside an Organizational Unit (OU)

creating-a-user-inside-an-Organizational-Unit-Windows-PowerShell

 

 

-Setting a password for the user

password-request-prompted-300x242

 

 

 

 

 

 

 

 

 

-Setting the password for the user in question in Windows PowerShell

setting-a-password-for-the-user-windows-powershell

 

 

Once you hit enter a popup window will ask you for the password for the user in question.

resetting-user-password-windows-powershell

 

 

The popup window will prompt you for the OLD password then will ask you to enter a new one and confirm it.

 

– Adding a group

windows-powershell-adding-a-group

 

When creating a group, you need to specify the scope (Domain local, global, or Universal) and the category (Security, or Distribution)

 

– Adding a user to a group

windows-powershell-adding-a-user-to-a-group

 

 

– Removing a user from the group

windows-powershell-adding-a-user-to-a-group

 

 

When removing a user from the group you are only making that user lose his membership to that specific group.

 

– Removing an Organizational Unit (OU)

 

warning-icon

 

Deleting an object OU will delete all the objects inside it; therefore, you must be very careful.

Normally, and by default, OUs are protected from accidental deletion, therefore before you delete you must either:

 

1- Go to properties for the OU and under the tab “Object” (Need to be on advanced feature) uncheck <Protect object from accidental deletion> click Apply then OK.

windows-powershell-organizational-unit

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

After unchecking the option, you can type in the command and hit enter. A confirmation box will then pop up to confirm your action of deleting the OU.

confirmation-message

 

 

 

 

2- Another option is to type in the command from the PowerShell as follows:

command-lline

 

 

Extended commands that can only be done using PowerShell

1- Remote to another server:

remote-to-another-server-command-line

 

 

Once you hit enter you will be prompted to enter your password:

password-request-prompted

 

 

 

 

 

 

 

 

 

If you get an error (Enter-PSSession: Connecting to remote server server_ name failed with the following error message: WinRm cannot process the request) accessing the computer name, you need to enable the WinRm from the server you want to remote into using its PowerShell:

error-message-windows-powershell

 

 

 

As an answer you will get “WinRM firewall exception enabled”.

WinRM-firewall-exception-enabled

 

 

 

 

 

Enabling or disabling your firewall would not make any difference.

warning-icon

 

If you want to activate the WinRM on all computers automatically, you will need to run the following command from the AD server:

Get the list of computers that you want to have WinRm active.

win-rm-active

 

 

 

Set the list of servers to have WinRm automatically enabled.

winrm-auto-enabled

 

 

2- Get XX number of event logs from different computer(s)

With the command below you can view XX number of security event logs for one or more computers (separated by commas) in your environment. In the command below, we are only retrieving 10 security event logs.

event-log

event-logs

 

 

Or simply if you want to get to choose a computer name each time you run this command, just run the following:

 

choose-computer-name

 

 

 

3- Get last 10 security event logs from all computers:

The following command will get the last 10 security event logs from all computers in your environment:

event-logs-windows-powershell

 

 

4- Shutting down one, two or all computers in your organization (be careful):

 

computer-shutdown-windows-powershell

 

Explore our Advanced Email Security Solutions

Protect your clients and simplify your operations with reliable, scalable email security solutions. Get in touch today to learn how we can support your success.

SHARE WITH YOUR NETWORK!

Ready to See the Difference?
Discover our advanced security products today.

Scroll to Top