PowerShell ISE – resolving issue – Get-SPWebApplication : The term ‘Get-SPWebApplication’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. Bit about Add-PSSnapin

PowerShell ISE - SharePoint module - "Microsoft.SharePoint.PowerShell" imported using "Add-PSSnapin"
PowerShell ISE - SharePoint module - "Microsoft.SharePoint.PowerShell" imported using "Add-PSSnapin"

Hi All,

Greetings for the day ๐Ÿ™‚ LIFE IS BEAUTIFUL ๐Ÿ™‚

Today small common issue ๐Ÿ™‚ and quick resolution ๐Ÿ™‚

Background / Details :

  • SharePoint migration going on. We have migrated our SharePoint 2010 application to SharePoint 2013 application
  • Databases are mounted to our new SharePoint 2013 web application
  • Sites are opening properly in SharePoint 2010 UI
  • Next step is to Visually upgrade all Site Collections so that they have SharePoint 2013 UI
  • Since we have huge number of site collections, PowerShell our friend ๐Ÿ™‚
  • So started to write the PowerShell script and first step to get the web application to fetch all site collections to upgrade as
$webApp = Get-SPWebApplication -Identity "http://knowledgejunction.sharepoint.com/"

Issue / Error :

Get-SPWebApplication : The term ‘Get-SPWebApplication’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that
the path is correct and try again

PowerShell ISE - Error while executing "Get-SPWebApplication" CMDLET
Fig : PowerShell ISE – Error while executing “Get-SPWebApplication” CMDLET

Solution :

  • Issue isSharePoint module is not imported in PowerShell ISE – SharePoint snap-in is not added
  • We could import SharePoint module by using Add-PSSnapin command as
#Add Microsoft SharePoint snap-in to the current session of PowerShell  
Add-PSSnapin Microsoft.SharePoint.PowerShell
PowerShell ISE - SharePoint module - "Microsoft.SharePoint.PowerShell" imported using "Add-PSSnapin"
Fig : PowerShell ISE – SharePoint module – “Microsoft.SharePoint.PowerShell” imported using “Add-PSSnapin”
  • After adding SharePoint snap in to the current session of PowerShell SharePoint CMDLETS working like a charm ๐Ÿ™‚

Bit about “Add-PSSnapin”

  • Add-PSSnapin” CMDLET adds one or more Windows PowerShell snap-ins to the current session
Add-PSSnapin
   [-Name] <String[]>
   [-PassThru]
   [<CommonParameters>]
  • Once we add sanp-in, we can use the cmdlets and providers that the snap-ins support in the current session as we did for SharePoint snap-in
  • "Add-PSSnapin" adds the snap-in only to the current session of PowerShell ISE. To add the snap-in to all Windows PowerShell sessions, we need to add it to our Windows PowerShell profile
  • Before adding a snap-in, "Add-PSSnapin" checks the version of the snap-in to verify that it is compatible with the current version of Windows PowerShell. If the snap-in fails the version check, Windows PowerShell reports an error

Thanks for reading ๐Ÿ™‚ If its worth at least reading once, kindly please like and share ๐Ÿ™‚ SHARING IS CARING ๐Ÿ™‚

Enjoy the beautiful life ๐Ÿ™‚ Have a FUN ๐Ÿ™‚ HAVE A SAFE LIFE ๐Ÿ™‚ TAKE CARE ๐Ÿ™‚

Prasham Sabadra

LIFE IS VERY BEAUTIFUL :) ENJOY THE WHOLE JOURNEY :) Founder of Knowledge Junction and live-beautiful-life.com, Author, Learner, Passionate Techie, avid reader. Certified Professional Workshop Facilitator / Public Speaker. Scrum Foundation Professional certificated. Motivational, Behavioral , Technical speaker. Speaks in various events including SharePoint Saturdays, Boot camps, Collages / Schools, local chapter. Can reach me for Microsoft 365, Azure, DevOps, SharePoint, Teams, Power Platform, JavaScript.

You may also like...

2 Responses

  1. June 16, 2021

    [โ€ฆ] Add Microsoft SharePoint snap-in to the current session of PowerShell. Otherwise for SharePoint CMDLET we get an error as discussed in last article โ€“ PowerShell ISE โ€“ resolving issue โ€“ Get-SPWebApplication : The term โ€˜Get-SPWebApplicationโ€™ isโ€ฆ [โ€ฆ]

  2. June 27, 2021

    […] Add Microsoft SharePoint snap-in to the current session of PowerShell. Otherwise for SharePoint CMDLET we get an error as discussed in last article โ€“ PowerShell ISE โ€“ resolving issue โ€“ Get-SPWebApplication : The term โ€˜Get-SPWebApplicationโ€™ is… […]

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

%d bloggers like this: