Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

How Do You Comment Out Code In Powershell?

Answer»

Like other languages powershell ALSO supports single/Inline comments line and multi line comments.

Starting with PowerShell V1 there’s only # to MAKE the text after it a comment.

In PowerShell V2 “<# #>” can be used for BLOCK comments (multi-line) and more specifically for SYNOPSIS, DESCRIPTION, NOTES, LINK help comments.

Example: Sinlgle/Inline comments

 # This is a single or inline comment starts with hash in Powershell

Example: Block comments (multi-line)

<# this is a first line of comment

this is a second line of comment

this is a THIRD line of comment

.

.

.

this is a last line of comment

#>

Like other languages powershell also supports single/Inline comments line and multi line comments.

Starting with PowerShell V1 there’s only # to make the text after it a comment.

In PowerShell V2 “<# #>” can be used for block comments (multi-line) and more specifically for SYNOPSIS, DESCRIPTION, NOTES, LINK help comments.

Example: Sinlgle/Inline comments

 # This is a single or inline comment starts with hash in Powershell

Example: Block comments (multi-line)

<# this is a first line of comment

this is a second line of comment

this is a third line of comment

.

.

.

this is a last line of comment

#>

2.

What Is Windows Powershell ?

Answer»

Windows POWERSHELL is a new Windows command-line shell designed ESPECIALLY for system ADMINISTRATORS. In the SharePoint administration CONTEXT, Windows PowerShell is ANOTHER administration tool that supersedes the existing Stsadm.exe.

Windows PowerShell is a new Windows command-line shell designed especially for system administrators. In the SharePoint administration context, Windows PowerShell is another administration tool that supersedes the existing Stsadm.exe.

3.

Where Is Powershell Located In Sharepoint ?

Answer»

On the START MENU, click All PROGRAMS -> Click Microsoft SHAREPOINT 2010 Products -> Click SharePoint 2010 MANAGEMENT Shell.

On the Start menu, click All Programs -> Click Microsoft SharePoint 2010 Products -> Click SharePoint 2010 Management Shell.

4.

What Are Cmdlet’s?

Answer»

Windows PowerShell introduces the concept of a cmdlet which are SIMPLE BUILD in commands, written in a .net language LIKE C# or VB.

Windows PowerShell introduces the concept of a cmdlet which are simple build in commands, written in a .net language like C# or VB.

5.

How Would You Ping A Remote Computer With 5 Packets Using Powershell ?

Answer»

Again, this is basic STUFF. I wouldn’t get caught up in ideology, the good old ping.exeis PERFECTLY valid, as long as the CANDIDATE knows the option to specify 5 packets.

If you really WANT the more PowerShelly Test-Connection, then ask : I just want the command to return $True if the ping is successful and $FALSE if it is not.

Again, this is basic stuff. I wouldn’t get caught up in ideology, the good old ping.exeis perfectly valid, as long as the candidate knows the option to specify 5 packets.

If you really want the more PowerShelly Test-Connection, then ask : I just want the command to return $True if the ping is successful and $False if it is not.

6.

What Is The Difference Between Convertto-csv And Export-csv Commands?

Answer»

ConvertTo-CSV is a one step process that only CONVERTS data into csv format and let it remain INSIDE the SHELL Export-CSV is a 2 step process that not only converts data into CSV and also WRITES the output to a CSV format file.

ConvertTo-CSV is a one step process that only converts data into csv format and let it remain inside the shell Export-CSV is a 2 step process that not only converts data into CSV and also writes the output to a CSV format file.

7.

How Will You Check The Default Path For Powershell Modules ?

Answer»

Get-Content ENV:psmodulepath

Get-Content env:psmodulepath

8.

How Will You Check What Commands Have Been Added After Adding The New Snapin To Powershell ?

Answer»

Get-Command -pssnapin <SNAPIN NAME> –> Lists all commands that got added when the snapin was added to the SHELL

Get-Command -pssnapin <snapin name> –> Lists all commands that got added when the snapin was added to the shell

9.

What Are The 4 Types Of Format Commands That Can Be Used To Format Data?

Answer»
  • Format-Wide
  • Format-List
  • Format-Table
  • Format-Custom

10.

What Are Two Ways Of Extending Powershell?

Answer»

11.

What Argument Can Be Used To Convert An Object Into A String Or Convert The Property Of An Object Into The String?

Answer»

expand is the argument that should be USED with the property NAME to convert an OBJECT property SIMPLY into a string.

e.g Get-ADcomputer –filter * | select-Object –expand name

expand is the argument that should be used with the property name to convert an object property simply into a string.

e.g Get-ADcomputer –filter * | select-Object –expand name

12.

How Would You Set A Registry Value With Powershell?

Answer»

Yeah, we start easy, but it is not that intuitive. This requires to know that there is no registry-specific cmdlets, so we have to use the registry PROVIDER and Set-ItemProperty.

The registry has been an integral part of Windows for ever, so this is hardly area-specific knowledge. It is very LIKELY that any POWERSHELL scripter has already PERFORMED this task at least once, MAYBE even on a almost-daily basis.

Yeah, we start easy, but it is not that intuitive. This requires to know that there is no registry-specific cmdlets, so we have to use the registry provider and Set-ItemProperty.

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

13.

You Have A Script Which Uses Read-host To Prompt The User For An Ip Address. You Need To Make Sure The User Inputs A Valid Ip Address. How Would You Do That ?

Answer»

A GOOD candidate would probably USE one of 2 ways :

  • SPLITTING the address in 4 elements and try to cast them to a [byte]
  • A regular expression

A great candidate would use the much simpler and more robust method : let the .NET Framework do the hard WORK and just try to cast the input string to the [System.Net.IPAddress] class.

By the way, the candidate should KNOW that what we get from Read-Host is a [string].

A good candidate would probably use one of 2 ways :

A great candidate would use the much simpler and more robust method : let the .NET Framework do the hard work and just try to cast the input string to the [System.Net.IPAddress] class.

By the way, the candidate should know that what we get from Read-Host is a [string].

14.

What Is The Difference, In Powershell, Between A Function And An “advanced Function” ?

Answer»

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

A GREAT candidate would be PRETTY enthusiastic about all the powerful tools enabled by advanced functions. Any PowerShell scripter who strives to BUILD professional-grade tools should be THANKFUL for all the work PowerShell is doing for us.

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

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

15.

How You Can Convert The Object Into Html?

Answer»

To CONVERT the object into HTML

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

To convert the object into HTML

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

16.

How You Can Rename A Variable?

Answer»

To RENAME a VARIABLE,

Rename-Item- PATH ENV: MyVariable –NewName MyRenamedVar

To rename a variable,

Rename-Item- Path Env: MyVariable –NewName MyRenamedVar

17.

What Is The Function Of $input Variable?

Answer»

The $INPUT variable enables a function to access data COMING from the PIPELINE

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

18.

What Powershell Scripting Is?

Answer»

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

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