PowerShell Interview Questions and Answers

by Venkatesan M, on May 13, 2017 1:03:41 PM

PowerShell Interview Questions and Answers

Q1. Explain what is PowerShell?

Ans: Power shell is an extendable command shell and a scripting language for Windows.

Q2. What are the key characteristics of PowerShell?

Ans: The key characteristics of PowerShell are

  • PowerShell is object-based and not text based
  • Commands in PowerShell are customizable
  • It is a command line interpreter and scripting environment

Q3. In PowerShell what does variables holds?

Ans: In variables PowerShell contains strings, integers and objects.  It does not have special variables as it is pre-defined with PowerShell

Q4. Explain what is the significance of brackets in PowerShell?


  • Parenthesis Brackets (): Curved parenthesis style brackets are used for compulsory arguments.
  • Braces Brackets {} : Curly brackets are employed in blocked statements
  • Square Brackets []: They define optional items, and they are not frequently used

Q5.  What does it mean cmdlet’s?

Ans: Cmdlet’s are simple build in commands written in .net language like C# or VB introduced by Windows PowerShell

Q6. Explain what is PowerShell Loop?

Ans: Automating repetitive task with the help of PowerShell loop is known as PowerShell Loop.  Through PowerShell, you can execute  For each loop,  While loop  and Do While loop.

Q7. Explain can you create PowerShell scripts for deploying components in SharePoint?

Ans: If you have created a web part using VS 2010 then, you can deploy it using cntrl+f5. However to activate the web part feature you can write a PowerShell script (.ps1) and execute it after deployment

Q8. Explain about the PowerShell’s comparison operators?

Ans: Comparison Operators compares value in PowerShell.  Four types of comparison operators are used equality, match, containment and replace.  In PowerShell, one of the key comparison operators is –eq that is used instead of “=” sign for declaring variables.  Likewise, there are other operators like –ne for “not equal” , -gt ( greater than ) or –lt (less than).

Q9. Explain what is PowerShell pipeline is used for?

Ans: PowerShell pipeline is used for joining two statements such that the output of one statement becomes the input of the second.

Q10. Explain what is PowerShell get-command?

Ans: Get command in PowerShell is used to fetch other cmdlets, for example you are looking for cmdlet between letter L and R then your PowerShell get-command will be like
# PowerShell Get – Command Range
Get-Command [ L–R ]*

Q11. Explain with an example how you can map a network drive in PowerShell?

Ans: To map a network drive in PowerShell you have to use the command like
# PowerShell Map Network Drive
$Net = $( New – Object – ComObject Wscript.Network )
$Net.MapNetworkDrive( “S:”, \\expert\myTectra )
In here the drive letter is “S:” and the Network share is called ‘expert’ on a computer called ‘myTectra.’

Q12. Mention what are the three ways that PowerShell uses to ‘Select’?


  • The most common way is in a WMI Query Language (WQL) statement. In this technique Wmiobject uses ‘-query’ to introduce a classic ‘Select * from’ a phrase
  • The second context for ‘Select’ in PowerShell is Select-String. This cmdlet checks for a word, phrase or any pattern match
  • Another way is Select Object

Q13. What is the function of Get-ServiceStatus in PowerShell?

Ans: The cmdlets of windows enable you to filter the window services.  PowerShell can list which services are ‘Running’ and which are ‘Stopped’ by scripting with windows.

Q14.  Explain what PowerShell Scripting is?

Ans: PowerShell file contains a series of PowerShell commands with each command appearing on a separate line. To use a text file as a PowerShell script, its filename should have.PS1 extension. To run a script you need

  • Type the commands in a text editor
  • Save the file with .ps1 extension
  • Execute the file in PowerShell


Q15.  What is the use of hash table in PowerShell?

Ans: A hash table is also referred as dictionary. It is an array that allows you to store data in a “key-value” pair association. The “key” and “value” can be of any data and length.  To declare a hash table you have to use @ followed by curly braces.

Q16. Explain what is the use of Array in PowerShell?

Ans: The use of Array in PowerShell is to run a script against remote computers.  In order to create an array, you have to create a variable and assign the array.  Arrays are represented by “@”symbol, they are represented as hashtable but not followed by curly braces.

For example, $arrmachine = @ ( “machine1” , “machine2” , “machine3”)

Q17. Mention what is the command that can be used to get all child folders in a specific folder?

Ans: To get all child folders in a specific folder, you have to use parameter recurse in the code.
Get-ChildItem C:\Scripts –recurse

Q18. Explain how you can convert the object into HTML?

Ans: To convert the object into HTML
Get-Process l Sort-object – property CPU –descending l convert to – HTML l Out-file “process.html”

Q19. Explain how you can rename a variable?

Ans: To rename a variable,
Rename-Item- Path Env: MyVariable –NewName MyRenamedVar

Q20.  Explain what is the function of $input variable?

Ans: The $input variable enables a function to access data coming from the pipeline

Q21.  What is the code to find the name of the installed application on the current computer?

Ans: Get-WmiObject-Class Win32_Product- ComputerName . l Format-wide-column1

Q22. Explain how you can find in PowerShell that all the sql services are on one server?

There are two ways to do this

  • get-wmiobject win32_service l where-object {$_name-like “*sql*”}
  • get-service sql*

Q23. What is the best way to find all the sql services on one server?

Ans: There are two ways to do this.

  • get-wmiobject win32_service | where-object {$_.name -like "*sql*"}
  • get-service sql*

Q24. Which class can help us identify whether the m\c is 32 bit or 64?

Ans: win32_computersystem. This can be used as follows:
PS C:\> $server = gwmi -cl win32_computersystem
PS C:\> $server.SystemType X86-based PC

Q25.  What is Variable Interpolation?

Ans: When you add a variable to a double-quoted string, PowerShell replaces the variable name by its value. This feature is called variable interpolation.


Topics:Powershell Interview Questions and AnswersInformation Technologies (IT)



Top Courses in Python

Top Courses in Python

We help you to choose the right Python career Path at myTectra. Here are the top courses in Python one can select. Learn More →

aathirai cut mango pickle