Software Testing - create a PowerShell script part 1

0 28
Avatar for Otek
Written by
2 years ago

Hello guys,

This time in my Software Testing series, I will be to cover something different. One of my last tasks at work was to test something using a newly created Windows user. To not generate it every time manually, I decided to create a PowerShell script to do that for me :) Also, it will be helpful for other team members - they Can also use it in their tasks :) So I also decided to show You what PowerShell is, how to run it, and in the next episodes how to write some scripts that actually does something: Create a new user, give them some permissions, create a loop, and so on :) Maybe it will be also helpful for You and help start with scriptwriting :)

Power what?

Let's start with PowerShell itself. Do You hear earlier about it? PowerShell is a cross-platform task automation solution made up of a command-line shell, a scripting language, and a configuration management framework. It is created by Microsoft and Can be run on Windows, Linux, and macOS. It allows You to create a fully automated script that Can be run on your or others' computers. It Can be used for many different tasks - we will cover some of them in that series :) You Can read more about it on the official Microsoft website: https://docs.microsoft.com/en-us/powershell/scripting/overview?view=powershell-7.1.

Ok, so let's dive into it :)

Run PowerShell

Do You have a PowerShell? Well, Windows PowerShell comes installed by default in every Windows, starting with Windows 7 SP1 and Windows Server 2008 R2 SP1 - so if You use one of them or earlier the answer is Yes - You already got it on your system :) But for writing a script we will need something more - PowerShell ISE.

ISE is a shortcut for Integrated Scripting Environment. How to find it? Well, in that article's series I will cover how to work with it on Windows 10 (because it is the most popular system version right now), but if You use the other one it is really easy to find that information on Microsoft website (https://docs.microsoft.com/en-us/powershell/scripting/windows-powershell/starting-windows-powershell?view=powershell-7.1).

In our case, just click the left lower corner Windows icon, start typing PowerShell: now should appear a few applications - choose: Windows Power Shell ISE.

If You don't see it in your environment, probably it is installed, but that feature isn't turned on. How to turn it on is in a great and easy way described here: https://www.tenforums.com/tutorials/145830-how-install-uninstall-windows-powershell-ise-windows-10-a.html.

When You click on that PowerShell ISE should start and looks similar to that screenshot below:

What we Can see here?

The main panel with the number '1' at the beginning is your working area when You will be actually creating Your script :) '1' is a number of lines - that lines numerating will be very helpful when Your script will be longer :)

Below that is a blue console - it looks like a command line and allows You to run script and see information printed by your script :).

By default, on the right side is a list of available commands that You Can use in your script. There are a lot of them - so option to sort by Modules or search by name will be very helpful :)

At the top we got of course a tools tab with standard option such a File, View, Help and so on. There are also some special options such a Debug or Add-ons - we will cover it in next episodes :)

___________________________________________

So that will be the end of first episode - I know that we don't wrote any script, but be patient, that was just an introduction :) We will create something that actually do something in a next episode :) So stay tuned. See ya :)

2
$ 0.39
$ 0.39 from @TheRandomRewarder
Sponsors of Otek
empty
empty
empty
Avatar for Otek
Written by
2 years ago

Comments