Generally, a host is something which stores or holds information on which other components depend to function properly. So a PowerShell host is nothing but a tool or a software which has all the necessary files which allows us to execute the PowerShell commands. PowerShell is the engine and hosts will allow us to use PowerShell engine to work with all the available commands.
The host may also provide us with enhanced GUI and certain features to develop, debug or version control mechanism for our PowerShell Scripts. For example, the simplest host we can mention here is the PowerShell Console and PowerShell ISE which are provided by Microsoft as out-of-the-box tools in Windows 7 and later clients. Some third party hosts which can be really helpful and worth mentioning to work with PowerShell scripts are PowerGUI, PowerShell Plus, Primal Script, PowerShell Studio, Visual Studio Code and even Visual Studio. Some of them are paid software and some of them are freeware. So, depending on the kind of work you are going to do and the features required, we can go with any of these tools. For my posts here, I’ll be using Visual Studio Code. I started using VS code recently to work with PowerShell Scripts and it’s my new love.
However, I would like to give a brief introduction to the default hosts provided to us by Microsoft in our Windows operating systems. (May or may not be present by default in some versions of Windows Server OS, but nothing that we cannot do to install it).In a Windows Operating system, you will find the basic PowerShell Console and PowerShell ISE shortcuts in the Start menu itself. In a 32-bit OS, the two shortcuts will be available and they are the 32-bit version of PowerShell. However, in a 64-bit OS, 4 different shortcuts are available as shown below:
PowerShell Console Vs PowerShell ISE
PowerShell Console allows you to use all the commands available in the PowerShell Engine. However, it does not give you with a script editor. PowerShell ISE on the other hand gives you the same features as PowerShell Console plus a script editor where you can open multiple scripts at a time and work on those.
So depending on the actions you want to perform with your scripts, you can use any mode of the hosts as required.
- PowerShell ISE comes with a toolbar where you can find many tools which will easy your life while working with the scripts.
- Use the x86 or x64 version of the hosts depending on your system architecture. They are designed to work best in the same architecture.
- Use Debugging mode and Debuggers in PowerShell ISE to debug your scripts.
- Use shortcuts such as
- F5 to run the script
- F8 to run a selection of the script
- F10 to go to next statement in debugging mode
- Make use of the Environment Variables for various usage.
I’ll discuss on all the points in my upcoming posts. Happy Scripting 🙂