Windows Powershell is a great tool for writing Windows based administration scripts. It is getting popular day-by-day due to its object oriented capabilities. Also the administrators find it very handy for writing scripts in a Windows platform much similar to the Unix based shell scripting.
How to Install PowerShell ISE and Enable PowerShell Scripts
PowerShell 2.0 is installed by default on Windows 7 and Windows Server 2008 R2. The PowerShell ISE (Integrated Scripting Environment) is installed by default on Windows 7, but not Windows Server 2008 R2. You can use the following information to install the ISE on your 2008 R2 server (as long as it’s running the full GUI and not the Core installation).
Launch PowerShell from the start menu or type “powershell” at Cortana search box on Windows 10:
On Windows 10 :
Run the following:
If you attempted to run this on the Core (no GUI) installation of Windows Server, you would receive the following error:
PowerShell scripts are disabled by default.
Typing commands into the ISE and executing them will work, but once they are saved as a script, you will receive the following error when you attempt to execute it:
ScriptName.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see “get-help about_signing” for more details.
Using the following command, the execution of scripts is set to “RemoteSigned” which requires that scripts downloaded from the Internet be signed by a trusted publisher:
The execution policy can be also changed for a single session by starting powershell with the argument from the command line:
PowerShell.exe -ExecutionPolicy RemoteSigned
Scripting with Windows PowerShell
Windows PowerShell commands, called cmdlets, let you manage the computers from the command line. Windows PowerShell providers let you access data stores, such as the registry and certificate store, as easily as you access the file system. In addition, Windows PowerShell has a rich expression parser and a fully developed scripting language.
Windows PowerShell includes the following features:
- Cmdlets for performing common system administration tasks, such as managing the registry, services, processes, and event logs, and using Windows Management Instrumentation (WMI).
- A task-based scripting language and support for existing scripts and command-line tools.
- Because cmdlets and system data stores use common syntax and naming conventions, data can be shared easily and the output from one cmdlet can be used as the input to another cmdlet without reformatting or manipulation.
- Simplified, command-based navigation of the operating system, which lets users navigate the registry and other data stores by using the same techniques that they use to navigate the file system.
- Objects can be directly manipulated or sent to other tools or databases.
- Independent software vendors and enterprise developers can build custom tools and utilities to administer their software.
New Features of Wondows PowerShell 5.0
- Windows PowerShell 5.0 includes significant new features that extend its use, improve its usability, and allow you to control and manage Windows-based environments more easily and comprehensively. The major improvements are in the areas of Desired State Configuration, security, performance, remoting, and language enhancements.
- Windows PowerShell 5.0 is backward-compatible. Cmdlets, providers, modules, snap-ins, scripts, functions, and profiles that were designed for Windows PowerShell 4.0, Windows PowerShell 3.0, and Windows PowerShell 2.0 generally work in Windows PowerShell 5.0 without changes.
- Windows PowerShell 5.0 is installed by default on Windows Server 2016 and Windows 10. To install Windows PowerShell 5.0 on Windows Server 2012 R2, Windows 8.1 Enterprise, or Windows 8.1 Pro, download and install Windows Management Framework 5.0. Be sure to read the download details, and meet all system requirements, before you install Windows Management Framework 5.0 Preview.