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

Name the type of format commands which are used to format the data.

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

Posted Date:- 2021-11-27 12:34:07

Name the command which is used to copy a file, registry key, or folder?

Copy-Item is a command which is used to copy the files or folders in a file system drive and the registry keys in the registry drive.

Posted Date:- 2021-11-27 12:33:09

Explain the Comparison operator in PowerShell?

Comparison Operators are used in PowerShell for comparing the values. Following are four types of comparison operators:

1. Equality Comparison Operator
2. Match Comparison Operator
3. Containment Comparison Operator
4. Replace Comparison Operator

Posted Date:- 2021-11-27 12:32:19

How to query data with a hash table from Application log?

The query gets data from the Application log to build the hash table one key-value pair at a time. The query gets data from the Application log. The hash table is equivalent to <Get-WinEvent –LogName Application>.

To begin, create the <Get-WinEvent> query. Use the FilterHashtable parameter’s key-value pair with the key, LogName, and the value, Application.


>Get-WinEvent -FilterHashtable @{




Posted Date:- 2021-11-27 12:31:22

How do you listing Local Users and Owner in PowerShell?

Local general user information — number of licensed users, current no. of users, and the owner name — can be found with a selection of “Win32_OperatingSystem” class properties. You can select the properties to display like this:


>Get-CimInstance -ClassName Win32_OperatingSystem |

Select-Object -Property NumberOfLicensedUsers,NumberOfUsers,RegisteredUser

Posted Date:- 2021-11-27 12:30:47

How do you listing all installed hotfixes in PowerShell?

To list all installed hotfixes by using Win32_QuickFixEngineering:


Get-CimInstance -ClassName Win32_QuickFixEngineering

Posted Date:- 2021-11-27 12:30:15

How to listing desktop settings on a local computer?

The following command collects information about the desktops on the local computer:


>Get-CimInstance -ClassName Win32_Desktop

Posted Date:- 2021-11-27 12:28:24

How can Enum support arithmetic operation?

Enums support arithmetic operations, as shown in the following example.


>enum SomeEnum { Max = 42 }

>enum OtherEnum { Max = [SomeEnum]::Max + 1 }

Posted Date:- 2021-11-27 12:27:16

How do you remove all registry keys under a specific key?

If attempt to delete the <HKCU:CurrentVersion subkey> :


>Remove-Item -Path HKCU:CurrentVersion

(To delete contained items without prompting, specify the Recurse parameter )

>Remove-Item -Path HKCU:CurrentVersion –Recurse

If you wanted to remove all items within HKCU:CurrentVersion but not <HKCU:CurrentVersion> itself, you could instead use:

>Remove-Item -Path HKCU:CurrentVersion* -Recurse

Posted Date:- 2021-11-27 12:26:45

How to deleting registry Keys?

Deleting items is essentially the same for all providers. The following commands will silently remove items:


>Remove-Item -Path HKCU:Software_custom

>Remove-Item -Path ‘HKCU:key with spaces in the name’

Posted Date:- 2021-11-27 12:26:04

How to creating registry keys?

Creating new keys in the registry is simpler than creating a new item in a file system. Because all registry keys are containers, you do not need to specify the item type; you simply supply an explicit path, such as:


>New-Item -Path HKCU:Software_custompath

Posted Date:- 2021-11-27 12:25:36

What is the Automatic variable in PowerShell and enlist the common automatic variables?

There are so many predefined variables in PowerShell, which are known as the automatic variables. These variables mainly store the information about the PowerShell, and created and maintained by the PowerShell. Any user can't change or update the value of these variables.

Following are some common automatic variables:

* $$
* $?
* $^
* $_
* $args
* $Error
* $foreach
* $Home
* $input
* $null
* $PSHome
* $PWD

Posted Date:- 2021-11-27 12:24:27

How to declare and create a variable in PowerShell?

Declaration: In PowerShell, you can declare a variable by using the $ (dollar) sign at the beginning of the variable name. Following syntax describes how to declare the variable:

$ <variable_name>
For example: $var

Creation or Initialization: In PowerShell, you can create a variable by assigning the value to a variable using the assignment operator. Following syntax describes how to declare the variable:

$ <variable_name> = <value>

Posted Date:- 2021-11-27 12:23:17

How to get a single registry entry?

The example given finds the value of DevicePath in <HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersion>.

Using <Get-ItemProperty>, use the Path parameter to specify the name of the key, and Name parameter to specify the name of the DevicePath entry.


>Get-ItemProperty -Path HKLM:SoftwareMicrosoftWindowsCurrentVersion -Name DevicePath

Posted Date:- 2021-11-27 12:22:37

What is the use of “Get-ItemProperty” in listing registry entries?

To view the registry entries in a more readable form, use “Get-ItemProperty”:


>Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersion

Posted Date:- 2021-11-27 12:21:58

How to listing registry entries?

To see the names of the entries in the registry key <HKEY_LOCAL_MACHINESoftwareMicrosoftWindowsCurrentVersion>, use <Get-Item>. Registry keys have property with the generic name of “Property” which is a list of registry entries in the key. The command given below selects the Property property and expands the items so that they are displayed in a list:


>Get-Item -Path Registry::HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersion |

>Select-Object -ExpandProperty Property

Posted Date:- 2021-11-27 12:21:33

How to read a text file into an array?

The Get-Content cmdlet command can be used to read an entire file in one step and one element per line of the file content. You can confirm it by checking the length of the content returned :

Example :

PS> Get-Content -Path C:sampledata.txt

PS> (Get-Content -Path C: sampledata.txt).Length


Posted Date:- 2021-11-27 12:21:09

How do you Mapping a Local Folder as a drive?

Using the <”New-PSDrive”> command. The following command will create a local drive P: rooted in the local Program Files directory which is visible only from the PowerShell session:


>New-PSDrive -Name P -Root $env:ProgramFiles -PSProvider FileSystem

Posted Date:- 2021-11-27 12:20:43

How do you avoid recursive prompt for each contained item?

If you don’t want to be prompted for each and every contained item, specify the Recurse parameter:


>Remove-Item -Path C: empNewFolder –Recurse

Posted Date:- 2021-11-27 12:20:03

What are the drawbacks of PowerShell?

* PowerShell which requires DotNet framework which is cost-effective.
* Security-Risks.
* It depends on the webserver to execute. Which may not right thing for any client. This leads to additional space on a server so custom software Development Company does not allow to afford resources for this.

Posted Date:- 2021-11-27 12:19:35

How do you implements multiple conditions?

This following examle shows how to create a <Where-Object> command with multiple-conditions.

This command gets non-core modules which support the Updatable <Help> features. It uses the <ListAvailable> parameter of the Get-Module> command to get every modules on the system. A pipeline operator (|) sends the modules to the <Where-Object> command , that gets modules whose names do not start with Microsoft or PS, and have a value for the <HelpInfoURI> property, that tells the powerShell where to find updated help files for the module. The compare-statements are connected by the <And> logical operator.


>Get-Module -ListAvailable | where {($_.Name -notlike “custom*” -and $_.Name -notlike “PS*”) -and $_.HelpInfoUri}.

Posted Date:- 2021-11-27 12:18:10

How to get processes based on process name using where-object?

The command processes that have a <ProcessName> property value that begins with the letter-p. The Match-operator use the regular expression matches. The scriptblock and statement syntax are same and used interchangeably.


>Get-Process | Where-Object {$_.ProcessName -Match “^p.*”}

>Get-Process | Where-Object ProcessName -Match “^p.*”

Posted Date:- 2021-11-27 12:17:45

What is Try, Catch, and finally in PowerShell?

Try: It is a part of a script where we want the PowerShell to monitor the errors. If an error occurs in this block, the automatic variable $Error stores the error. And then, the PowerShell searches the Catch block to handle the error.

Catch: In a PowerShell script, it is a part which handles the errors generated by the Try block.

Finally: In a PowerShell script, it is a part which releases the resource that no longer needed by a script.

Posted Date:- 2021-11-27 12:17:15

How to get sessions connected to the local computer?

The <PSSessions> command that are connected to the local system. To specify the local system, type the system name, <localhost>, or a dot (.)

The command returns all of the sessions on the local system, even if they were created in different sessions or on different systems.

Posted Date:- 2021-11-27 12:16:38

How to get owershell session in local/remote system?

The <Get-PSSession> command gets the user-managed sessions (PSSessions) from powershell on local and remote computers.



Posted Date:- 2021-11-27 12:16:18

How to get jobs that have not been started?

This “Get-Job” command gets only those jobs that are created but haven’t yet been started. It includes the jobs that are scheduled the jobs to run in the future slots and those not yet scheduled.


>Get-Job -State NotStarted

Posted Date:- 2021-11-27 12:16:02

How to Export history entries up to a specific ID?

Example to save the history in Historysave.csv file as below:

This example iterate the five most recent history entries. The pipeline passes the entire result to the <Export-Csv> command, which formats the history as comma-separated text and saves it in the Historysave.csv file. The file contains the data that is showed when you format the history as a list. This includes the status and begin/start and end times of the command.

>Get-History -ID 3 -Count 5 | Export-Csv Historysave.csv

Posted Date:- 2021-11-27 12:15:26

How do you get a list of the commands entered during the current session?

The <Get-History> command gets the session’s history, (i.e.) the list of commands entered during the present session.

The PowerShell routinely preserves a history of each session. The number of command entries within the session history is decided by the worth of the <$MaximumHistoryCount> preference variable. At start in Windows PowerShell 3.0, the default value is <4096>. By default-, history of files are saved within the home directory, but you’ll save the entire file in any location.



Posted Date:- 2021-11-27 12:15:03

Can you explain how to Display selected parts of a cmdlet by using parameters?

These following examples display the selected portions of the Format-Table command help.

>Get-Help Format-Table -Examples

>Get-Help Format-Table -Parameter *

>Get-Help Format-Table -Parameter GroupBy

The examples parameter displays the the assistance file’s NAME and SYNOPSIS sections, and every one the examples. You can’t identify an example number because the examples parameter is a switch parameter.

The Parameter shows only the content description of the parameters. If you specify only the asterisk-(*) wildcard character, it shows the descriptions of every/all parameters. When Param specifies a parameter name such as <GroupBy>, info (information) about that parameter is shown.

Posted Date:- 2021-11-27 12:14:42

Can you explain about Get-Help?

The command “Get-Help” displays the information about PowerShell concepts and commands functionality, together with <cmdlets>, functions, Common Information Model-(CIM) commands, -workflows, -providers, -aliases, and the scripts.

To get the help content for a given PowerShell cmdlet, type Get-Help follow by the _cmdlet_ name, such as: <“Get-Help”>, <“Get-Process”>.


>Get-Help Format-Table

>Get-Help -Name Format-Table

Posted Date:- 2021-11-27 12:14:14

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*

Posted Date:- 2021-11-27 12:13:39

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.

Posted Date:- 2021-11-27 12:13:14

Explain what is the function of $input variable?

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

Posted Date:- 2021-11-27 12:12:57

Explain how you can rename a variable?

To rename a variable,

Rename-Item- Path Env: MyVariable –NewName MyRenamedVar

Posted Date:- 2021-11-27 12:12:39

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”

Posted Date:- 2021-11-27 12:12:20

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

Posted Date:- 2021-11-27 12:11:49

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

Posted Date:- 2021-11-27 12:11:31

Could you explain about ping a remote computer with 5 packets using PowerShell?

Again, this is basic stuff. I would not get caught up in ideology, the good old ping. Exe is seamlessly valid, as long as the candidate knows the option to specify 5 packets.

If you really want the more “PowerShell” <Test-Connection>, then just want the command to return <$True> if the ping is successful connected and <$False> if it is not connected.

Posted Date:- 2021-11-27 12:10:49

Could you explain the difference between “convertto-csv” and “export-csv” commands?

The command “ConvertTo-CSV” is a one stage process that changes data into csv format and let it persist inside the shell “Export-CSV” is a 2 step process that not only changes data into “CSV” and also writes the output to a “CSV” format file.

Posted Date:- 2021-11-27 12:10:28

How do you check the default path for PowerShell modules?

The command is as follows:

Get-Content env:psmodulepath

Posted Date:- 2021-11-27 12:10:13

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 Experienced,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 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 .