Covid-19 Update!!    We have enabled all courses through virtual classroom facility using Skype or Zoom.    Don't stop learning.    Enjoy Learning from Home.

30% Discount Python        30% Discount Webdesign        30% Discount SEO        30% Discount Angular8        Free SQL Class        Free Agile Workshop       Free HTML Sessions        Free Python Basics

Important Windows PowerShell Interview Questions and Answers

Interview Questions and Answers for PowerShell Scripting

1. What is PowerShell?

PowerShell is an extendable command and a scripting language for Windows.

2. What are the key characteristics of PowerShell?

It is development stage technology implemented so that the cloud provides the services globally as per the user requirements. It provides a method to access several servers worldwide.

The key characteristics of PowerShell are:

  • It is object-based and not text based.
  • Commands are able to be modified to suit a particular task.
  • It is a command line interpreter and scripting environment.

    3. What does variables holds in PowerShell?

    Variables in PowerShell contains strings, integers and objects. There is no special variables as it is pre-defined with PowerShell

    4. What are the significance of brackets in PowerShell?

    Curved Parentheses Brackets(): Curved parentheses brackets are meant for compulsory arguments.
    Braces Brackets {} : They are employed in blocked statements
    Square Brackets []: They define optional items, and it is not frequently used

    5. What do you mean by cmdlet’s?

    Cmdlet’s are written in .net language as simple build in commands like C# or VB introduced by Windows PowerShell

    6. Explain what is PowerShell Loop?

    PowerShell loop helps to automate the repetitive task is function is called PowerShell loop. By this you can execute for each loop, while loop and Do While loop.

    7. Explain how can you create PowerShell scripts for deploying components in SharePoint?

    After creating a web part using VS 2010, we can deploy it using cntrl+f5, then to activate the web part characteristic you can write a PowerShell script (.ps1) and perform it after deployment

    8. Explain why PowerShell pipeline is used for?

    Two statements are joined using PowerShell pipeline where the input of second statement becomes the output of one statement

    9. Explain what is PowerShell get-command?

    PowerShell get-command is used to get other cmdlets, suppose you are looking for cmdlet between letter L and R then your PowerShell get-command will be like # PowerShell Get – Command Range Clear-Host Get-Command [L–R]*

    10. What are the three ways that PowerShell uses to ‘Select’?

  • The most common way is Wmiobject uses ‘-query’ to introduce a classic ‘Select * from’ a phrase.
  • The second context is Select-String.
  • Third way is Select Object

    11. What is the function of Get-Service Status in PowerShell?

    The cmdlets of windows enable you to filter the window services. PowerShell can list which services are ‘Running’ and which are ‘Stopped’ by scripting with windows.

    12. Explain what PowerShell Scripting is?

    PowerShell file contains a series of PowerShell commands. Each command will appearing on a separate line. To use a text file as a PowerShell script, filename should have.PS1 extension.
    To run a script we need
  • Type the commands in a text editor
  • Save the file with .ps1 extension
  • Execute the file in PowerShell.

    13. What is the use of hash table in PowerShell?

    A hash table is also referred as dictionary. It is an array that allows you to store data in a “key-value” pair association. The “key” and “value” can be of any data and length. To declare a hash table you have to use @ followed by curly braces.

    14. Explain what is the use of Array in PowerShell?

    Array in PowerShell is used to run script against remote computers. If we create a variable and assign the array by this we can create array. Array is represented by “@”symbol, they are represented as hash table but not followed by curly braces.

    For example, $arrmachine = @ (“machine1”, “machine2”, “machine3”)

    15. Mention what is the command that can be used to get all child folders in a specific folder?

    Use parameter recurse in the code to get all child folders in a specific folder.
    Get-ChildItem C:\Scripts –recurse

    16. Explain how you can convert the object into HTML?

    To convert the object into HTML
  • Get-Process
  • Sort-object– property CPU –descending.
  • Convert to – HTML.
  • Out-file “process.html”.

    17. Explain how you can rename a variable?

    To rename a variable,Rename-Item-Path Env: My Variable –New Name MyRenamedVar

    18. Explain what is the function of $input variable?

    The function of $input variable is to access data coming from the pipeline

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

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