Part - 9 : Installing Windows Features.

In the previous post we see the magic of Windows PowerShell PSRemoting. We have learned how to use it.

In this blog post, we are going to add a new windows feature by doing a PSRemoting to our remote server, or you can say that, by sitting on our own laptop, listening to the music, and we are going to configure our server remotely.

Cool ! No?

To see the list of all available feature and roles available , which we can deploy on our server we uses the Get-WindowsFeature cmdlet.

In the below screenshot, you can see, that I have PSRemoted to our Windows 2012 R2 Server. When we run the Get-WindowsFeature cmdlet, it has returned the list of all windows features.

So, how do you know, which feature is install or not?

We can check it by :

If the feature is already installed, then it's "Install State" is Installed, otherwise it's "Install State" is Available.

You can see a cross [X] in the front of installed features. and empty [ ] in the front of the feature/role which is available to install but not installed yet.

If you want to know about any specific feature thatif it is installed or not, then user Get-WindowsFeature and then provide the name of the feature in -Name parameter.

For example ,after run the below command you can see that 'Management Tools' are not installed on this server.

Get-WindowsFeature-Name'Web-Mgmt-Tools'

To install any feature or role, we use the Install-WindowsFeature cmdlet.

The usage of cmdlet is very simple. Type cmdlet and then provide the name of feature to install.

Let's try installing XPS Viewer. The below command is very simple and not need to

Install-WindowsFeatureXPS-Viewer

In the below screenshot, we can see, that our feature install successfully.

Part -8 : The magic of Windows PowerShell PSRemoting.

Welcome back,

In the pervious blog post, we added our Windows 2012 R2 server to the domain by using Windows PowerShell, I think, our most of work is done on the server, now to do everything else on server we are going to use Windows PowerShell PSRemoting to done our jobs.

What is "Windows PowerShell PSRemoting"?

In simple words, by using PowerShell PSRemoting, we can run command on our server remotely, or we can also connect to their PowerShell console locally ( kind of SSH thing ).

Do I need to enable PSRemoting on Windows 2012 R2 server?

In the Part-2 of this series, we noticed that PSRemoting is enabled by default on Windows 2012 R2 servers.

How to use it?

It is very simple to use.

In the below screenshot, you can see, two of PowerShell consoles, one is opening on Server ( to show you it's computer name, ) and second one is opened on my laptop.Just to show you that we are going to use client PowerShell console, not the server's.

PowerShell tip :

You can use the $env:COMPUTERNAME to find the computer name.

Now on your client machine, create a $credentialvariable and store our admin account's username and password in to it by using Get-Credential cmdlet (if you remember, we done the same thing in our previous blog post) .

$credential=Get-Credential

Now, we need to create another variable to store the PowerShell PSRemoting session information.

In the below command, are are creating a $session variable, and then we are using New-PSSession cmdlet to initiate a session ,in -ComputerName , we have provided the name of our server , and in -Credential we are provided the name of variable $credential in which we have stored our admin username and password credential information.

$session=New-PSSession-ComputerName'DEL-2k12'-Credential$credential

No errors! Great!

All heavy lifting is done. Now, we only need to type Enter-PSSession cmdlet , provide the name of session, which is $session in my case and hit enter. That's all.

Enter-PSSession-Session$session

In the above screenshot, you can see,that we are successfully connected to our server and we are on remote PowerShell console of our windows 2012 R2 Server, you can also see that prompt of PowerShell has also changed too and when I run the ,$env:COMPUTERNAME it give us the name of server.

If you want to exit from your remoting session, just type and run the Exit-PSSession cmdlet.

PowerShell Tip:

By default PowerShell use TCO Port, 5985,5986 for PSRemoting.

Basic troubleshooting.

Some tips for PSRemoting trouble shootings are :

Make sure port 5985, 5986 is opened on the server or not blocked by something else.