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

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 string or convert the property of an object into string?

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

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

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Powershell interview questions"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Support


    Please leave a message and we'll get back to you soon.

    3 + 5