PowerShell – Interview preparation – 1

Hi All,

Greetings for the day!!!

On Microsoft 365 Junction, I am starting the series for PowerShell interview preparation. Today sharing first article in this series. I’ll keep updating this list.

Feel free to discuss any PowerShell related question or topic. Happy to write an article. Just mention your topic in comment section.

Q. What standard should be followed while naming PowerShell script CMDLETs?

  • PowerShell uses a verb-and-noun name pair to name CMDLETs
  • For example, the Get-Command CMDLET is included in PowerShell. It is used to get all the CMDLETs registered in the command shell.
  • The verb identifies the action that the CMDLET performs.
  • The noun identifies the resource on which the CMDLET performs its action.

Q. What are PowerShell modules ?

  • A PowerShell module can be defined as a set of PowerShell functions, CMDLETs.
  • These are grouped to manage all the aspects of a particular feature.
  • In more simple terms its package of PowerShell functions, CMDLETs, variables, providers, aliases, and workflows (basically PowerShell members).
  • These modules then used as reference in other PowerShell scripts.
  • We can share these PowerShell modules with others.
  • Example: We see all installed module using – Get-Module CMDLET

For more details on PowerShell Modules, please have a look – PowerShell – Exploring Module CMDLETshttps://knowledge-junction.in/2022/12/12/__trashed-2/

Q. In PowerShell script, how to check if module is already imported or not?

  • We can use “Get-Module” CMDLET to verify if given PowerShell module is imported or not.
  • Next is sample code:
if ( -not (Get-Module -ListAvailable -Name PnP.PowerShell)) {
    Write-Host "Module is not imported"
    Import-Module PnP.PowerShell
} #if ( -not (Get-Module -ListAvailable -Name PnP.PowerShell))

else
{
    Write-Host "Module is imported"
}

Q. How to add regions to PowerShell script ?

  • In Windows PowerShell 3.0 one of the feature is added to Microsoft PowerShell ISE is region feature.
  • Region feature allows us to mark the section in the script that will collapse and expand.
  • We can start the region by using # sign and “region” keyword.
#region variable declarations

  • Code which we want to include the region.
  • end the region with “endregion” keyword
#endregion

Example:Below is the sample code for declaring variables in PowerShell script

#region Variable declarations
    $adminUrl = "https://knowledgejunction1-admin.sharepoint.com"
    $intranetUrl = "https://knowledgejunction1.sharepoint.com/"
    
    $CSVFilePath = "C:\\csvfilepath.csv"

#endregion

Q. Which PowerShell CMDLET is used to write the data to the CSV file

  • Export-CSV CMDLET is used to write the data / content to CSV file.
  • The Export-CSV CMDLET is very simple and only has a few properties that are useful:
    • Path – (Required) Location of the CSV file
    • NoTypeInformation – Removes the type information header from the output. Not needed any more in PowerShell 6
    • Delimiter – Default is comma, but we can change it
    • Append – Append to an existing CSV file
    • Force – Useful in combination with Append
    • NoClobber – Don’t overwrite existing files
    • UseQuotes – (PowerShell 7 only) wrap values in quotes or not
  • For more details on Export-CSV CMDLET, please have a look our article. PowerShell tutorial – Write a CSV file with PowerShell using the Export-CSVhttps://knowledge-junction.in/2022/10/31/write-a-csv-file-with-powershell-using-the-export-csv-function/

Q. How to know the current version of PowerShell on my system ?

  • Using $PSVersionTable variable
PowerShell - Know the current version of PowerShell - PSVersionTable
fig : PowerShell – Know the current version of PowerShell – PSVersionTable

REFERENCES

Thank you🙂 Life is Beautiful🙂

Have a nice day🙂🙂

Prasham Sabadra

LIFE IS VERY BEAUTIFUL. ENJOY THE WHOLE JOURNEY :) Founder of Microsoft 365 Junction, Speaker, Author, Learner, Developer, Passionate Techie. Certified Professional Workshop Facilitator / Public Speaker. Believe in knowledge sharing. Around 20+ years of total IT experience and 17+ years of experience in SharePoint and Microsoft 365 services Please feel free me to contact for any SharePoint / Microsoft 365 queries. I am also very much interested in behavioral (life changing) sessions like motivational speeches, Success, Goal Setting, About Life, How to live Life etc. My book - Microsoft 365 Power Shell hand book for Administrators and Beginners and 100 Power Shell Interview Questions - https://www.amazon.in/Microsoft-Administrators-Beginners-Interview-Questions/dp/9394901639/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=1679029081&sr=8-11

You may also like...

1 Response

  1. June 14, 2025

    […] This is second article in a list. Please check first set of interview questions – PowerShell – Interview preparation – 1 – https://microsoft365junction.com/2024/12/23/powershell-interview-preparation-1/ […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Microsoft 365

Subscribe now to keep reading and get access to the full archive.

Continue reading