Skip to main content

Practice Exercises for PowerShell Beginner


Practice Exercise1: File Operations/Searching/Basic PowerShell Operators

1.) Create a folder TestingPurpose and 3 Subfolders inside it SubFolder1, SubFolder2

2.) Create some test files inside these folders:

TypeATest1.txt, TypeATest2.txt  … TypeATest50.txt into SubFolder1

TypeBTest51.txt, Purpose52Test2.txt … TypeBTest100 into SubFolder2

Needless to say that you have to use logic for creating these files. Not one by one

3.) Move all files which have an odd number in its name to SubFolder2

4.) Move all files which have even number in its name to SubFolder1

5.) Rename folder SubFolder1 to EvenFilesContainer and SubFolder2 to OddFilesContainer

5.) Prepare a list of all files currently existing inside folder TestingPurpose

     Example: MasterFile.txt:

As of YYYYMMDD HH: MM files inside Testing Purpose are:





6.) Delete all files which start with TypeA


Practice Exercise 2:  Windows Service Related

Write PowerShell One-liners for:

1.) Get all services which are stopped

2.) Get all services whose name starts with letter "A"

3.) Get all services which are set to start automatically (look for property      StartType  : Automatic)

4.) Restart-Service Winmgmt

5.) Export the service name and status into a text file.


Service Name,  Status

Service A,   Running

Service B,    Stopped

6.) Export the service name, StartType, and status into an HTML file.


Practice Exercise 3:  Windows Process Related

Write PowerShell One-liners for:

1.) Get all windows processes whose name starts with letter "A"

2.) Get list of processes whose name is svchost and PM more than 100MB

3.) Get Process Name, Process ID and handleCount whose PM is more then 100MB and CPU more than 1000s

4.) Export the results of (3) to html and CSV format


Practice Exercise 4:  User Input

Simple interest calculation on any principal amount involves variables like Principle amount, Interest rate and tenure for which you are calculating SI

Simple interest can be calculated by using below formula

SI = P * R * T / 100


P = Principal amount

 R = Rate of Interest

T = Time(in years)

Write a PowerShell to take user inputs and show the results user


Practice Exercise 5:  Programming using PowerShell

Write a logic using nested loops(for loop or while loop) to draw the below pattern












Note: Copy the solution only after trying it yourself





for($i=0; $i -le 10; $i++){
for ($j=$i; $j -ge 0; $j--){
Write-Host "#" -NoNewline
Write-Host ""


Practice Exercise 6:  Programming using PowerShell

Write a logic to produce the mathematical table of a given number. The number should be a dynamic value and provided by the user at the run time.


$table_of = [int] (Read-Host "Which table you want. Enter number")

for($i=1; $i -le 10; $i++){

Write-Host $table_of"*"$i "=" ($table_of*$i)} 



  1. Hi Vijay,

    Do you have these exerices answers at some point

  2. [int]$p = Read-Host -prompt "Enter your principal amount"
    [uint16]$t = Read-Host -Prompt "Enter the time in number of months"
    [uint16]$r = Read-Host -Prompt "Enter the interest amount"

    $Interesetamount = $($p * $t *$r)/100

    Write-Host $Interesetamount

  3. I think this is a really good article. You make this information interesting and engaging. You give readers a lot to think about and I appreciate that kind of writing. slot pragmatic

  4. I love the way you write and share your niche! Very interesting and different! Keep it coming! daftar sekarang

  5. You've shared some excellent material. I'm grateful for this post because it contains a lot of useful information. Thank you for sharing this piece of writing. Devops Services India

  6. It is an enterprise specializing within the production of high-tech injection molding machines. South America, Commonwealth of Independent States, Southeast Asia, Africa, Middle East and Europe. Many plastic injection professionals use a basic rule of thumb of two.5 occasions the floor sq. inches of the half to be produced. So, in case you have a part with forty two sq. inches, you then would want a press dimension with 105 tons of stress. If you add 10% for a security factor, you will need to make use of a press with a high precision machining minimal of one hundred fifteen tons of clamping drive.

  7. Great blog ! I am impressed with suggestions of author.
    Tattoo Machine Grips


Post a Comment

Popular posts from this blog

Practice Exercises for PowerShell Intermediate

  Dear Friend, If you have already gone through     practice exercises for PowerShell beginner,    This is another opportunity to take your Scripting knowledge to next level. Please go through the problems, develop a clear understanding, make a rough sketch and apply your PowerShell knowledge to solve the problems.  Use PowerShell's help as much possible in case you need, but don't directly search on the internet. Trust me, solving these problems will definitely boost your confidence. Problem 1: Service restart on multiple computers and logging. Write a PowerShell script to read the computer names from a text file Then, Stop a given service (say Print Spooler service ) and wait for 30 seconds after logging the status into a dedicated log file. Ensure no child process is alive so that graceful stop of service can be confirmed If there is any child process, kill it forcefully and log the information into the log file After waiting for 30 seconds, start the service Check for the s

5 Tips to secure a job in Azure Cloud

I assume most of you are already doing well in your careers and have got no good reason to switch job profile. But at the same time, there may be many who due to many reasons, want to explore new carrier opportunities. This post is just to help those who are seeking a rewarding carrier in Cloud Computing.  Since I am working on Azure in my profession (Microsoft Azure, Technical Lead in an MNC), I will only be able to provide inputs for Azure, But I have nothing against other cloud service providers. You can still go through this post for reference. How to get a dream job and start a career in the world of Microsoft Azure? Time Required: 2 months ' Step1: Set Your Goal. There are so many areas in Cloud Services where you can contribute, doesn't matter what you are doing currently. It is very easy to get lost. So spend a decent amount of time thinking about what exactly you want to do. For example, If you are more interested in deploying the VMs, VNets, configure load bala