Skip to main content

Top 25 PowerShell Interview Questions Prepared by Experts



1)   Explain what is PowerShell?

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

2)   What are the key characteristics of PowerShell?

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

3)   In PowerShell what does variables holds?
In variables PowerShell contains strings, integers and objects.  It does not have special variables as it is pre-defined with PowerShell

4)   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

5)   What does it mean cmdlet’s?
Cmdlet’s are simple build in commands written in .net language like C# or VB introduced by Windows PowerShell

6)    Explain what is PowerShell Loop?
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.

7)   Explain can you create PowerShell scripts for deploying components in SharePoint?
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

8)   Explain about the PowerShell’s comparison operators?
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).

9)    Explain what is PowerShell pipeline is used for?
PowerShell pipeline is used for joining two statements such that the output of one statement becomes the input of the second.

10)   Explain what is PowerShell get-command?
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
Clear-Host
Get-Command [ L–R ]*

11)   Explain with an example how you can map a network drive in PowerShell?
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.’

12)   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

13)   What is the function of Get-ServiceStatus in PowerShell?
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.

14)    Explain what PowerShell Scripting is?
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

15)   What is the use of hash table in PowerShell?
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.

16)   Explain what is the use of Array in PowerShell?
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”)

17)   Mention what is the command that can be used to get all child folders in a specific folder?
To get all child folders in a specific folder, you have to use parameter recurse in the code.
Get-ChildItem C:\Scripts –recurse

18)   Explain how you can convert the object into HTML?
To convert the object into HTML
Get-Process l Sort-object – property CPU –descending l convert to – HTML l Out-file “process.html”

19)   Explain how you can rename a variable?
To rename a variable,
Rename-Item- Path Env: MyVariable –NewName MyRenamedVar

20)    Explain what is the function of $input variable?
The $input variable enables a function to access data coming from the pipeline

21)   What is the code to find the name of the installed application on the current computer?
Get-WmiObject-Class Win32_Product- ComputerName . l Format-wide-column1

Comments

Popular posts from this blog

Automation Testing Python Interview Questions

1.What is Python? What are the benefits of using Python? Answer: Python is a programming language with objects, modules, threads, exceptions and automatic memory management. The benefits of pythons are that it is simple and easy, portable, extensible, build-in data structure and it is an open source. 2.   How Python can be used in software testing?  Answer: 1. To generate test data; parse test results; generate reports; testing API calls etc. 2. Python to extract requirements from a Word document. 3. For testing tasks automation, setting up environments for tests, extracting performance data, etc… 4. Testers use Python extensively in many companies with Selenium for test automation. 5. For writing desktop applications used by testers. 6. Test data manipulation. 7. To build test environment 8. Testing with IronPython on .NET  3.What Python frameworks do you know?  Answer:  Framework called Web2py, PAMIE (Python automation Module for I. E.), The p...

Python Flask Interview Questions and Answers

Q1). What is Flask? Ans1 : Flask is a web micro framework for  Python  based on “Werkzeug, Jinja 2 and good intentions” BSD licensed. Werkzeug and jingja are two of its dependencies. Q2). What is the benefit of using Flask? Ans2:  Flask is part of the micro-framework. Which means it will have little to no dependencies on external libraries. It makes the framework light while there is little dependency to update and less security bugs. Q3). What is the difference between  Django,  Pyramid, and Flask? Ans3:  Flask is a “microframework” primarily build for a small application with simpler requirements. In flask, you have to use external libraries. Flask is ready to use.Pyramid are build for larger applications. It provides flexibility and lets the developer use the right tools for their project. The developer can choose the database, URL structure, templating style and more. Pyramid is heavy configurable. Q4). What is Flask-WTF and what are t...

Python real time Interview Questions and Answers

Q1).What is Python? Ans1:  Python is a high-level, interpreted, interactive and object-oriented scripting language.  Python  is designed to be highly readable. It uses English keywords frequently where as other languages use punctuation, and it h as fewer syntactical constructions than other languages. Q2).Name some of the features of Python. Ans2:  Following are some of the salient features of python − It supports functional and structured programming methods as well as OOP. It can be used as a scripting language or can be compiled to byte-code for building large applications. It provides very high-level dynamic data types and supports dynamic type checking. It supports automatic garbage collection. It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java. Q3).Do you have any personal projects? Really? Ans3: This shows that you are willing to do more than the bare minimum in terms of keeping your skillset up to date. If you work on per...