PowerShell Interview Questions for Freshers/PowerShell Interview Questions and Answers for Freshers & Experienced

How will you cross-check what commands have been added after adding the new Snapin to PowerShell?

The following commands with example:

Command :>Get-Command -pssnapin<snapin name>

Lists every commands that have added when the snapin was added to the shell.

What are the type of format command and what are they?

There are four types of format command.

1. Format-Wide
2. Format-List
3. Format-Table
4. Format-Custom

What Are Two Ways Of Extending Powershell?

There are two ways:

1. PSSnapins
2. Modules

Do you tell me, whether argument can be used to convert an <object> to a <string> or convert the property of an <object> into <string>?

Expand is the argument that needs to be used with the property name to convert an object property easily into a string.


Command :>Get-ADcomputer –filter * | select-Object –expand name

Could you explain about set a registry value with PowerShell?

I have to use the registry provider and <Set-ItemProperty>.

The registry is an integral part of Windows, so it is hardly area-specific knowledge. It is actual likely that any scripter has already performed this task at least once, maybe even on almost-daily basis.

Can you tell me the difference, In PowerShell, between a function and an “advanced Function”?

This little bit be a tricky question for an average candidate, but normally, the good candidate should know that the only one thing that makes a function advanced and unlocks the tooling which comes with it is : [ CmdletBinding() ].

A candidate would be enthusiastic about all the powerful tools enabled by the advanced functions. Any scripter who strives to build professional – grade tools should be the thankful for all the work PowerShell is doing for us.

What is Manage Dependencies?

The Manage dependencies is important to specify the modules that your module is dependent on in the Module Manifest. This manage dependencies allows the user to not have to worry about installing the proper versions of the modules that yours take a dependency on. To specify the modules which dependent, you should use required module field in the module manifest. This will help to load any listed modules into the global environment prior to importing your module unless they’ve already been loaded.

For example, some modules may be loaded by a different module. It is possible to identify the specific version to load using “RequiredVersion” field rather than “ModuleVersion” field. When using the “ModuleVersion”, it will load newest version available with lowest of the ver specified. When not using the “.<RequiredVersion>” field, to identify a specific version it is important to monitor the version updates to the required module. It is significant to be aware of any breach changes that could affect the user experience with the module.

Example: >RequirdModules = @(@{ModuleName=”myDependentedModule”; ModuleVersion=”2.0″; Guid=”dfc45206-1e49-459d-a8ad-5b571ef94859″})

Example: RequirdModules = @(@{ModuleName=”myDependentedModule”; RequiredVersion=”1.5″; Guid=”dfc45206-1e49-459d-a8ad-5b571ef94859″})

Can you explain about PSScriptAnalyzer?

The tool named as “PSScriptAnalyzer” is a free static code analysis tool that works on PowerShell code. The “PSScriptAnalyzer” will find the most common issue seen in the powershell script , and often a recommendation for how to fix the issue. This is easy to implement and classifies the issues as Errors (severe, must be highlighted), Warning (need to be revised and should be highlighed), and Information (checking out for best practices). Every packages published to the PowerShell Gallery will be scanned using the tool “<PSScriptAnalyzer>”, and any errors will be reported back to the holder and must be highlighted.

The best practice is to run command “Invoke-ScriptAnalyzer” with -Recurse and -Severity Warning.

Review the results, and ensure that:

All the Errors are corrected or addressed in your script documentation.

All the Warnings are reviewed and addressed where applicable.

Do you explain renaming a variable?

To rename a variable,

Rename-Item- Path Env: <MyVariable> –NewName <MyRenamedVar>

What is $PSScriptRoot in PowerShell?

$PSScriptRoot is an Automatic Variable, which are built-in variables that comprise records about the PowerShell surroundings itself. $PSScriptRoot includes the listing direction of the script being done currently.

Originally $PSScriptRoot used to be solely relevant to script modules, however commencing with PowerShell 3.0, it works for all PowerShell script files. From the console, if I kind $PSScriptRoot and press ENTER, it returns nothing.

What is your idea about Variable Interpolation?

When a variable is added to double-quoted strings, then PowerShell changes the name of that variable through its value. Typically, this feature in PowerShell is known as variable interpolation.

Can you illustrate the code used to locate the names of installed applications on a current computer?

We will have to employ the following code:

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

Are you aware of the $input variable? What are its functions?

$input variable activates a function that enables pipeline data access.

Can you define how you will assign a different name to a variable?

A variable can be renamed by using -

Rename-Item- Path Env: MyVariable –NewName MyRenamedVar

Can you explain the ways to convert the object to HTML?

In order to convert the object to HTML, we will have to execute -

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

Define what commands to use in order to get child folders into a specified folder?

We will have to apply parameter recurse to get child folders into a specified folder. It will be -
Get-ChildItem C: Scripts –recurse

Can you explain the uses of PowerShell Array?

PowerShell Array is used to run scripts on remote computers. To create a PowerShell Array, users will need to create a variable, as well as they will have to assign the PowerShell Array. PowerShell Arrays are expressed with a “@” symbol and illustrated as a hashtable.
For instance, it would be like -

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

Can you explain the hash table functions in PowerShell?

PowerShell’s hash table can be referred to as a dictionary. Basically, it is a series that enables users in storing data with a pair association known as “key-value”. Here, both “key”, as well as “value”, might comprise any length and data. In order to declare hash table users will have to apply @ in front of curly braces.

What is PowerShell’s Get-ServiceStatus function?

The functions of Get-ServiceStatus enable filtering of window services. PowerShell lists the services that are ‘Running’, also, the services that are ‘Stopped’ through scripting.

Do you know the methods to ‘Select’ in PowerShell?

* The simplest way is WQL (WMI Query Language) statement. This technique uses the ‘-query’ in order to introduce ‘Select * from’.

* Select-String is the next method to ‘Select’ in PowerShell. In this scenario, the matching pattern, phrase, and word are checked by the cmdlet.

* The last way is through Select-Object.

Can you explain how the network drive is mapped in PowerShell?

For mapping network drive, the following PowerShell commands have to be executed -
# PowerShell Map Network Drive

$Net = $( New-Object – ComObject Wscript.Network )
$Net.MapNetworkDrive( “S:”, expertmyTectra )

What do you understand by get-command in PowerShell?

PowerShell’s get-command is applied to fetch cmdlets. For instance, if anyone is searching cmdlet between E and K, then the get-command would look like - get-command [ E–K ]*

What is the use of the PowerShell pipeline?

When we have to join two statements, we use the PowerShell pipeline. In this case, one statement’s output emerges as the second statement’s input.

What is your idea about comparison operators in PowerShell?

Comparison operators in PowerShell compare values. Comparison operators can be classified into four types - Match, Equality, Replace, and Containment. To declare variables, –eq comparison is used. Similarly, –lt is used for less than’, -gt for ‘greater than’, and ‘not equal’ is denoted by –one.

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.

Can PowerShell scripts be created for the deployment of SharePoint components?

If the web part is created employing VS2010, SharePoint components can be deployed with the help of ctrl+f5. Features of the web part can be activated through the PowerShell script.

What is your understanding of cmdlet?

Cmdlet are commands scripted in languages such as PowerShell VB or C#.

How do I enable execution policy in PowerShell?

In order to enable the execution of PowerShell following steps are required to perform-

> Start Windows PowerShell
> Run as an Administrator
> Enable running script by using the command: Set-execution policy redesigned

What are the types of PowerShell operators?

There are 9 types of operators:

1. Arithmetic Operators
2. Assignment Operators
3. Logical Operators
4. Comparison Operators
5. Redirection Operators
6. Split and Join Operators
7. Type Operators
8. Unary Operators
9 Special Operators

What is the hash table in PowerShell?

Hash the table can be defined as a dictionary. Because it is a series that enables to store data with a pair association is called “key-value” pair. Both “key” and “value” of any length and data. In order to the declaration of hash table developers has to add @ in front of curly braces.

Define scripting in PowerShell?

PowerShell programming files contain a sequence/an array of commands, where each command shows in sequences of separate lines. When using a text/script file, the filename has the.ps1 extension.

PowerShell script can be run by –

> Typing commands in a text editor
> Saving a file with the .ps1 extension and executing the file

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.

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


Get-Command [ L–R ]*

What is PowerShell’s Get-ServiceStatus function?

The methods of “Get-ServiceStatus” enable filtering of window services. PowerShell lists the services that are ‘Running’ and ‘Stopped’ through scripting.

What are the execution policies in PowerShell?

There is a total of four execution policies in PowerShell namely-

* Restricted
* All Signed
* RemoteSigned
* Unrestricted

What is a hash table in PowerShell?

Hash table is a data structure which used the mechanism of value/key pair. The professionals who create PowerShell scripts use variables to store data. For the storage of data in a highly secure environment hash table is used.

What's the significance of brackets in PowerShell?

Due to the object-oriented language, bracket plays an important role in PowerShell. The PowerShell employs four types of brackets namely parenthesis, braces, square and angular brackets. All these brackets come under control structure therefore in order to control the flow of the code brackets are required.

How do you know about the methods to ‘Select’ query in PowerShell?

The PowerShell simplest way is WQL (WMI Query Language) statement. This query technique uses the ‘-query’ in order to query/introduce ‘Select * from.

Select-String is also the next technics to ‘Select’ in the PowerShell command. In this scenario/scope, the matching pattern, idiom, and word is checked by the cmdlet.

The last way is through Select-Object.

How is the command in the n/w-network drive mapped in PowerShell?

The following commands have to be executed –

# Mapping Network Drive

>$Net = $( New-Object – ComObject Wscript.Network )

>$Net.MapNetworkDrive( “S:”, expertmyTectra )

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

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.

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.

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.

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

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.

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

What do you mean by get-command in PowerShell?

PowerShell’s get-command is applied to fetch cmdlets. For single instance, if anybody is searching cmdlet between G and L, then the “get-command” would look like –

>get-command [ G–L ]*

What is the use of the pipeline in PowerShell scripting?

When we have to join two command statements, we use the PowerShell pipeline technique. In this case, one command statement’s output emerges as the second command statement’s input.

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 acts as a command-line interpreter and scripting environment

What is PowerShell?

Power shell is an extendable/scalable command shell and a scripting language for Windows machine/computer. It is platform-independent and open-source.

R4R Team
R4R provides PowerShell Freshers questions and answers (PowerShell Interview Questions and Answers) .The questions on R4R.in website is done by expert team! Mock Tests and Practice Papers for prepare yourself.. Mock Tests, Practice Papers, PowerShell Interview Questions for Freshers,PowerShell Freshers & Experienced Interview Questions and Answers,PowerShell Objetive choice questions and answers,PowerShell Multiple choice questions and answers,PowerShell objective, PowerShell questions , PowerShell answers,PowerShell MCQs questions and answers Java, C ,C++, ASP, ASP.net C# ,Struts ,Questions & Answer, Struts2, Ajax, Hibernate, Swing ,JSP , Servlet, J2EE ,Core Java ,Stping, VC++, HTML, DHTML, JAVASCRIPT, VB ,CSS, interview ,questions, and answers, for,experienced, and fresher R4r provides Python,General knowledge(GK),Computer,PHP,SQL,Java,JSP,Android,CSS,Hibernate,Servlets,Spring etc Interview tips for Freshers and Experienced for PowerShell fresher interview questions ,PowerShell Experienced interview questions,PowerShell fresher interview questions and answers ,PowerShell Experienced interview questions and answers,tricky PowerShell queries for interview pdf,complex PowerShell for practice with answers,PowerShell for practice with answers You can search job and get offer latters by studing r4r.in .learn in easy ways .