Friday 13 May 2016

Tuning With PowerShell

Tuning With PowerShell

Use the secret Windows features. Windows 10 is more than just a beautiful interface. With PowerShell you can venture into the hidden machine space of the operating system

Dialog boxes and mouse operation – this is how Windows 10 presents itself to the average user. But if you want to dig deep into all the finesse and options of the operating system, then you should use PowerShell which will allow you to complete tasks more efficiently, automate workflows via script, manage your computer and much more.

However, you should always be careful while using PowerShell as some commands go deep into the system. Therefore, in this workshop we will demonstrate some basic functions of the command line for power users.


1 Call Powershell


In order to open the PowerShell app in Windows 10, simply type ‘‘PowerShell” in the search field of the Start bar. After clicking on the option “Windows PowerShell” right on top of the list, a dark blue console window with white font will open.

2 Place on the desktop


To be able to start PowerShell faster in future, the app can be placed as a tile in the Start menu or on the desktop. For this, right-click on ‘‘Windows PowerShell” and go to the command ‘‘Attach to ‘‘Start””. You can now open PowerShell using the mouse in the Start menu. If you wish to place the PowerShell on the desktop, then drag the app out of the Start menu using the mouse.

3 Configure PowerShell


If you do not see the standard display of PowerShell as a dark blue console window with white font or if the standard font size is too small for you then you can change the preset layout. Right-click on the window edge of the console and select ‘‘Properties” in the context menu. The window with the tabs ‘‘Options”, ‘‘Font type”, ‘‘Layout” and ‘‘Colours” will be displayed. Try different settings and see the effects. Once you are happy with the results, accept the settings by clicking on OK.

4 Use the help system


No one needs to learn the commands of PowerShell by heart. It is enough to know the most important commands - the rest can be accomplished with the help of the internal help system. The simplest form of the help command is ‘‘get-help”.

However, you have to supplement it with an additional specification, for example, with the name of a Cmdlet, one of the integrated PowerShell commands ‘‘get-help clear-host” gives some basic information about this Cmdlet. With “get-help clear-host full”, you will learn about the parameters which you can use to add the Cmdlet.

It becomes really interesting when you use ‘‘-online” instead of ‘‘-full” i.e. ‘‘get-help clear-host -online”.

Like the alias-name of »clear-host«, you can read ‘‘cls” there. MSDOS veterans will recognise the command as it has the same task here as it had there: It deletes all the entries on the screen.

5 Identify the Shell variant


With the help of the command ‘‘get-host”, you can find out which PowerShell variant is running on your computer. More parameters are not required - unless you wish to use this Cmdlet to change the text and background colours or the size of the window.

Suitable sample scripts are given on the Technet page when you enter the command ‘‘get-help get-host -online”.

6 Working with Script Editor


If you wish to change a script or write a new one, you should use the graphical script editor “PowerShell ISE. Type ‘‘PowerShell ISE” in the search field and create a link as described in step 2. ‘‘ISE” stands for ‘‘Integrated Scripting Environment”. The editor reworked for Windows 10 with its graphical interface is very helpful for beginners. Hence, the command area on the right side of the editor has a list of all the permitted entries. Write errors are as good as excluded as a window with a selection of commands opens immediately upon typing.

In order to update the internal help system, click on ‘‘Help” and ‘‘Update Windows PowerShell Help” in the menu of the editor.

7 Deploy packet manager Oneget


If you enjoy experimenting and want to experience a bit of Linux feeling under Windows, you should try the following: Use PowerShell ISE to install the new software. For this, you need to start the script editor as Administrator. After right-clicking on the desktop link, call the command ‘‘Run as Administrator”. When the PowerShell windows opens, first allow the following security question ‘‘Set-ExecutionPolicy – Scope CurrentUser RemoteSigned”. Confirm the security question of the system with ‘‘Yes, all”. Use the command ‘‘Install-Package testonegetcs” to install the packet manager ‘‘Oneget.

As soon as you confirm the command, the message appears that the ‘‘NuGet” is missing. You can add the NuGet with ‘‘Yes”. PowerShell will now load the relevant EXE file. This may take a bit longer.

With ‘‘Find-Package notepad”, you can start the search for the editor ‘‘Notepad++” which knows the syntax of all the popular programming languages. Due to special writing of the program (Plus sign!), the following command is ‘‘Install-Package notepadplusplus”. Confirm the question ‘‘Are you sure you want to install software from ‘‘Chocolatey’?”, with ‘‘Yes”.