header

For BE/B.Tech/BCA/MCA/ME/M.Tech Major/Minor Project for CS/IT branch at minimum price Text Message @ 9424820157

PowerShell Interview Questions

PowerShell Interview Questions



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


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


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


4.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 ]*


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


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


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


8.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 –

1.Typing commands in a text editor

2.Saving a file with the .ps1 extension and executing the file


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


10.What are the types of PowerShell operators?

There are 9 types of operators:

Arithmetic Operators 

Assignment Operators

Logical Operators

Comparison Operators

Redirection Operators

Split and Join Operators

Type Operators

Unary Operators

Special Operators


11.What are Arithmetic Operators?

There are :

(+ )Addition

(-)Subtraction

(*)Multiplication

(/)Division

(%)Modulus


12. Why do you use Logical Operators?

The logical conditional operators are used to connect the expression statements collectively to form a single expression. The command expressions which contain the logical operators usually result in shows in the Boolean values True (1) or False (0).

AND

OR

NOT


13. Explain the functionality of brackets in PowerShell?

(): Curved parenthesis brackets are used for compulsory arguments.

{}: Curly brackets are employed in blocked statements

[]: Square brackets are they define optional items, and they are not frequently used.


14. What does in PowerShell Loop?

Looping/Repetitive task with the help of looping in PowerShell is known as PowerShell Loop.  Using PowerShell, you can execute “For each” loop,  “While” loop  and “Do While” loop.


15. Could you explain how do you convert the object into HTML?

The following command statement is to convert the object into HTML:

Command :>Get-ProcesslSort-object – property CPU –descendingl convert to – HTML l Out-file “custom.html”.


16. Do you explain renaming a variable?

To rename a variable,

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


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


18.What Are Two Ways Of Extending Powershell?

There are two ways:

PSSnapins

Modules


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

There are four types of format command.

Format-Wide

Format-List

Format-Table

Format-Custom


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


21.How do you check the default path for PowerShell modules?

The command is as follows:

Get-Content env:psmodulepath


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


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


24. How to get sessions connected to a computer?

Example:

>Get-PSSession -ComputerName “Servername”

The command <PSSessions> that are connected to the <”Servername”> system.

The command returns every sessions on <“Servername”>, even if they were created in different sessions or on different computers.


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

Example:

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

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


26. What are the benefits of PowerShell?

-PowerShell is an <Object-Oriented> scripting language so reusability possible for all time.

-PowerShell which serves more functions compared to <cmd.exe> and <VBScript>.

-It supports fully Automation of tasks, so it is saving time.

-It supports all .NET Objects and Forms

-It supports all Background Jobs.


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


28. Explain the array in PowerShell?

An array in a PowerShell is a type of data structure which stores the collection of values in the single variable.


29. What are cmdlets in PowerShell?

The cmdlets are the commands which are written in a .net language like VB or C# introduced by the Windows PowerShell. The cmdlets return the object of Microsoft .NET framework to the next commands in the pipeline. The PowerShell cmdlets follow the verb-noun pattern, such as get-help, set-Item.


No comments:

Post a Comment



Please go through below tutorials:


Mule 4 Tutorials

DEPLOY TO CLOUDHUB C4E CLIENT ID ENFORCEMENT CUSTOM POLICY RABBIT MQ INTEGRATION
XML TO JSON WEBSERVICE CONSUMER VM CONNECTOR VALIDATION UNTIL SUCCESSFUL
SUB FLOW SET & REMOVE VARIABLE TRANSACTION ID SCATTER GATHER ROUND ROBIN
CONSUME REST WEBSERVICE CRUD OPERATIONS PARSE TEMPLATE OBJECT TO JSON LOAD STATIC RESOURCE
JSON TO XML INVOKE IDEMPOTENT FILTER FOR EACH FLAT TO JSON
FIXWIDTH TO JSON FIRST SUCCESSFUL FILE OPERATIONS EXECUTE ERROR HANDLING
EMAIL FUNCTIONALITY DYNAMIC EVALUATE CUSTOM BUSINESS EVENT CSV TO JSON COPYBOOK TO JSON
CHOICE ASYNC

Widely used Connectors in Mule 3

CMIS JETTY VM CONNECTOR SALESFORCE POP3
JMS TCP/IP WEBSERVICE CONSUMER QUARTZ MONGO DB
FILE CONNECTOR DATABASE CONNECTOR


Widely used Scopes in Mule 3

SUB FLOW REQUEST REPLY PROCESSOR CHAIN FOR EACH CACHE
ASYNC TCP/IP COMPOSITE SOURCE POLL UNTIL SUCCESSFUL
TRANSACTIONAL FLOW

Widely used Components in Mule 3

EXPRESSION CXF SCRIPT RUBY PYTHON
JAVASCRIPT JAVA INVOKE CUSTOM BUSINESS EVENT GROOVY
ECHO LOGGER


Widely used Transformers in Mule 3

MONGO DB XSLT TRANSFORMER REFERENCE SCRIPT RUBY
PYTHON MESSAGE PROPERTIES JAVA TRANSFORMER GZIP COMPRESS/UNCOMPRESS GROOVY
EXPRESSION DOM TO XML STRING VALIDATION COMBINE COLLECTIONS BYTE ARRAY TO STRING
ATTACHMENT TRANSFORMER FILE TO STRING XML TO DOM APPEND STRING JAVASCRIPT
JSON TO JAVA COPYBOOK TO JSON MAP TO JSON JSON TO XML FLATFILE TO JSON
FIXWIDTH TO JSON CSV TO JSON


Widely used Filters in Mule 3

WILDCARD SCHEMA VALIDATION REGEX PAYLOAD OR
NOT MESSAGE PROPERTY MESSAGE IDEMPOTENT FILTER REFERNCE
EXPRESSION EXCEPTION CUSTOM AND


Exception Strategy in Mule 3

REFERENCE EXCEPTION STRATEGY CUSTOM EXCEPTION STRATEGY CHOICE EXCEPTION STRATEGY CATCH EXCEPTION STRATEGY GLOBAL EXCEPTION STRATEGY


Flow Control in Mule 3

CHOICE COLLECTION AGGREGATOR COLLECTION SPLITTER CUSTOM AGGREGATOR FIRST SUCCESSFUL
MESSAGE CHUNK AGGREGATOR MESSAGE CHUNK SPLITTER RESEQUENCER ROUND ROBIN SOAP ROUTER