Powershell interview questions

Ratings:
(4)
Views:644
Banner-Img
  • Share this blog:

Powershell Interview Questions

How do you comment out code in powershell?

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

What is Windows Powershell ?

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

Where is Powershell located in sharePoint ?

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

What are cmdlet’s?

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

Can you tell me two major differences between $Other_Language and PowerShell ?

This question is an fantastic opportunity get an insight into the candidate understanding of PowerShell core concepts and his/her favourite PowerShell features.

For example, one of the most fundamental difference between bash and PowerShell is that bash is text-oriented whereas PowerShell is object-oriented.

A good candidate should be able to tell that. A great candidate, would most likely go on and on about the benefits of the object-oriented nature of PowerShell.

Also, if a candidate cites 2 valid differences between the two languages, but not a major one, the candidate might have a partial knowledge of PowerShell.

How would you ping a remote computer with 5 packets using PowerShell ?

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.

Powershell Scripting Interview Questions

What is the difference between ConvertTo-CSV and Export-CSV commands?

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

How will you check the default path for PowerShell Modules ?

Get-Content env:psmodulepath

How will you check what commands have been added after adding the new snapin to powershell ?

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

What are the 4 types of FORMAT commands that can be used to format data?

  • Format-Wide
  • Format-List
  • Format-Table
  • Format-Custom

What is that path where PowerShell looks to get modules information and how would you know about them?

Get-Content env:psmodulepath

  1. C:\Users\...\Documents\WindowsPowerShell\Modules
  2. C:\Windows\system32\WindowsPowerShell\v1.0\Modules

What are two ways of extending PowerShell?

  1. PSSnapins
  2. Modules

You have servers that are not exposed to internet. How would you update help on those servers? Give commands

  • Save-Help –DestinationPath <Path Name>
  • Update-Help –SourcePath <Path Name> or Update-Help –SourcePath <Path Name> -Force

What are the 2 methods through which pipeline input would work?

  1. ByValue
  2. ByPropertyName

What argument can be used to convert an object into a string or convert the property of an object into the string?

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

What Is Windows Powershell? 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. How Do You Comment Out Code In Powershell? 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 #>

You liked the article?

Like : 0

Vote for difficulty

Current difficulty (Avg): Medium

Recommended Courses

1/15

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.


Stay Updated


Get stories of change makers and innovators from the startup ecosystem in your inbox