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 traits of PowerShell?
Ans: The key traits of PowerShell are
PowerShell is item-based totally and not textual content based totally
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 incorporates strings, integers and objects. It does now not have special variables as it's far pre-defined with PowerShell
Q4. Explain what's 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 outline optional objects, and they are not regularly used
Q5. What does it mean cmdlet’s?
Ans: Cmdlet’s are easy build in instructions written in .Internet language like C# or VB added by Windows PowerShell
Q6. Explain what is PowerShell Loop?
Ans: Automating repetitive project with the assist of PowerShell loop is referred to as PowerShell Loop. Through PowerShell, you could execute For each loop, While loop and Do While loop.
Q7. Explain are you able to create PowerShell scripts for deploying additives in SharePoint?
Ans: If you have created a web component using VS 2010 then, you may deploy it using cntrl+f5. However to spark off the net component feature you could write a PowerShell script (.Ps1) and execute it after deployment
Q8. Explain approximately the PowerShell’s contrast operators?
Ans: Comparison Operators compares cost in PowerShell. Four forms of evaluation operators are used equality, in shape, containment and update. In PowerShell, one of the key contrast operators is –eq that is used in preference to “=” signal for affirming variables. Likewise, there are different operators like –ne for “no longer same” , -gt ( extra than ) or –lt (much less than).
Q9. Explain what is PowerShell pipeline is used for?
Ans: PowerShell pipeline is used for becoming a member of two statements such that the output of 1 statement will become the input of the second.
Q10. Explain what is PowerShell get-command?
Ans: Get command in PowerShell is used to fetch different cmdlets, for instance you are searching out 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 could map a network force in PowerShell?
Ans: To map a community power in PowerShell you need to use the command like
# PowerShell Map Network Drive
$Net = $( New – Object – ComObject Wscript.Network )
$Net.MapNetworkDrive( “S:”, expertmyTectra )
In right here the pressure letter is “S:” and the Network percentage is known as ‘professional’ on a pc called ‘myTectra.’
Q12. Mention what are the three methods that PowerShell makes use of to ‘Select’?
The maximum common way is in a WMI Query Language (WQL) announcement. In this approach Wmiobject makes use of ‘-query’ to introduce a conventional ‘Select * from’ a word
The second context for ‘Select’ in PowerShell is Select-String. This cmdlet tests for a word, word or any sample match
Another manner is Select Object
Q13. What is the feature of Get-ServiceStatus in PowerShell?
Ans: The cmdlets of home windows enable you to filter out the window services. PowerShell can list which offerings are ‘Running’ and which might be ‘Stopped’ via scripting with home windows.
Q14. Explain what PowerShell Scripting is?
Ans: PowerShell document incorporates a series of PowerShell commands with every command performing on a separate line. To use a textual content report as a PowerShell script, its filename must have.PS1 extension. To run a script you want
Type the instructions in a text editor
Save the document with .Ps1 extension
Execute the document in PowerShell
Q15. What is the usage of hash desk in PowerShell?
Ans: A hash desk is also referred as dictionary. It is an array that allows you to shop information in a “key-value” pair association. The “key” and “price” may be of any facts and duration. To claim a hash desk you have to use @ observed via curly braces.
Q16. Explain what is using Array in PowerShell?
Ans: The use of Array in PowerShell is to run a script towards far flung computer systems. In order to create an array, you need to create a variable and assign the array. Arrays are represented by “@”symbol, they're represented as hashtable but not followed through curly braces.
For instance, $arrmachine = @ ( “machine1” , “machine2” , “machine3”)
Q17. Mention what is the command that may be used to get all child folders in a particular folder?
Ans: To get all baby folders in a particular folder, you need to use parameter recurse in the code.
Get-ChildItem C:Scripts –recurse
Q18. Explain how you may convert the item into HTML?
Ans: To convert the item into HTML
Get-Process l Sort-item – property CPU –descending l convert to – HTML l Out-document “procedure.Html”
Q19. Explain how you may rename a variable?
Ans: To rename a variable,
Rename-Item- Path Env: MyVariable –NewName MyRenamedVar
Q20. Explain what is the feature of $input variable?
Ans: The $input variable allows a characteristic to get right of entry to statistics coming from the pipeline
Q21. What is the code to find the call of the set up software at the contemporary laptop?
Ans: Get-WmiObject-Class Win32_Product- ComputerName . L Format-extensive-column1
Q22. Explain how you can locate in PowerShell that each one the sq. Services are on one server?
There are two approaches to do that
get-wmiobject win32_service l wherein-item $_name-like “*sq.*”
Q23. What is the exceptional manner to discover all of the sq. Offerings on one server?
Ans: There are methods to do this.
Get-wmiobject win32_service wherein-object $_.Name -like "*sq.*"
Q24. Which class can help us discover whether or not the mc 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 totally PC
Q25. What is Variable Interpolation?
Ans: When you add a variable to a double-quoted string, PowerShell replaces the variable name by way of its value. This feature is known as variable interpolation.