Tuesday, October 3, 2017

PowerShell -Part 2: Install/Update Help File, Enabling PowerShell Scripting and Remoting

By default Powershell runs under normal user access privileges. You need to run Powershell as Administrator for running certain commands.
How to run Powershell as Administrator using Powershell cmdlet?
Execute Start-Process Powershell –verb runas command in powershell cmdlet
Run Powershell as Administrator 

Install/Update the Powershell Help File:
You need to execute Update-Help command in Powershell cmdlet to install or get update on Powershell Help file.
Note: You need to run Powershell as Administrator
Using Update-Help command Install or Update Powershell Help File

Enable Powershell Script Execution:
Due to security provision, the ability to execute Powershell scripts is disabled by default. In order to execute Powershell script Execution Policy must be set.

You need to run Powershell cmdlet as Administrator and execute Set-ExecutionPolicy RemoteSigned.
Set Execution Policy
Enable Powershell Remoting:
By default, Powershell is configured to run remote commands on other Windows Computers. However the computers will not allow remote commands to be executed on them. On each computer that you want remote commands to execute on, run the following Powershell command in cmdlet (Remember: You need to run Powershell cmdlet as Administrator)
Enable –PSRemoting and follow the instructions as you are prompted.

Note: Windows Server 2012 machines will allow remote commands to be executed by default.

PowerShell -Part 1: Introduction to Powershell and how to check and change Powershell version

PowerShell -Part 1: Introduction to Powershell and how to check and change Powershell version
Powershell is a commandline tool for Windows Administrators. It hooks in to .NET Framework.
Powershell provides:
(A). cmdlets for performing common system administration tasks to manage such as:
            - The registry
            - Services
            - Processes
            - Event logs
            - Windows Management Instrumentation (WMI)
(B). A task-based scripting language and support for existing scripts and command-line tools.
(C). Common syntax, Naming Convention, Pipelining
(D). Simplified, command-based navigation of the Operating System: For example, the registry and other data stores can be accessed by using the same techniques that are used to navigate the file system.
(E). Object Manipulation: Object can be directly manipulated or sent to other tools or databases.
(F). Most importantly Powershell is an Object Based Scripting Language: Powershell provides the programming power and accessibility of an object oriented programming language in a scripting environment.

How to find your Powershell Version?
By typing $PSVersionTable in Powershell cmdlet, you can check Powershell version in your system:
Check Powershell Version

Powershell 5 is part of Windows Management Framework (WMF) 5.0. Similarly Powershell 2.0, 3.0 and 4.0 are part of WMF 2.0, 3.0 and 4.0 respectively.

Important Note:
Systems that are running the following server applications should not run Windows Management Framework 4.0:
1.      System Center 2012 Configuration Manager (Not Including SP1)
2.      System Center Virtual Machine Manager 2008R2 (Including SP1)
3.      Microsoft Exchange Server 2007
4.      Windows Small Business Server 2011 Standard

How to change Powershell Version?
You can change Powershell version by using following syntax in Powershell command-line:
powershell –version 2.0 (Here I am changing to Powershell version 2.0.)
Powershell Version Change Command in Powershell Cmdlets

Now your Powershell version changed to 4.0 and you can validate by running $PSVersionTable command
Powershell Version after changing the version

Powershell Backward Compatibility:
1.      Powershell 2.0 is fully backward compatible with 1.0. Any script written on 1.0 will run on 2.0.
2.      Powershell 3.0 and 4.0 are fully backward compatibility with 2.0.
3.      You can run 2.0 and Powershell 3.0 or 4.0 side by side on the same computer.
4.      Powershell 3.0 and 4.0 cannot be run side by side on the same computer.
NOTE: When you install either Powershell 3.0 or 4.0, they will replace Powershell 1.0.