Click here to Skip to main content
15,886,362 members
Articles / Productivity Apps and Services / Sharepoint / SharePoint 2013
Tip/Trick

Sharepoint Cmdlets using PowerShell ISE

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
22 Dec 2015CPOL2 min read 13.6K   1  
Use SharePoint Commandlets in Windows PowerShell ISE

Introduction

We all know PowerShell is a very powerful scripting tool and SharePoint administration jobs are completely dependent on this. Windows PowerShell has an ISE (Integrated Scripting Environment) which helps administrator or developer to perform lots of command liners or tasks through this and can debug.

Background

How to use SharePoint Commandlets in PowerShell ISE? We are already aware of SharePoint YYYY Management Shell and that works as a command liner for us. Most of us are from a development background and have a very pleasant feel of working with Visual Studio IDE and suddenly we are asked to work on the command liner which makes our life a little sad. So, here is the solution - PowerShell ISE. But, when you start PowerShell ISE, you cannot directly execute the SharePoint Commandlets. So, this tip is all about running SharePoint Commandlets on PowerShell ISE.

Using the Code

Here are the steps to make PowerShell ISE work for SharePoint Commandlets.

  1. Go to Start -> All Programs -> Accessories -> Windows PowerShell -> Windows PowerShell ISE

    1066453/1.png

  2. Execute the below command. After execution, shell will create the folder and inside that, it will create a new PowerShell file.

    1066453/2.png

  3. Go to Computer -> Libraries ->Documents

    1066453/3.png

  4. Open WindowsPowerShell folder and you will see Microsoft.PowerShellISE_profile.ps1. Open it in Windows PowerShell ISE.

    1066453/4.png

  5. Execute the below command and save it.

    1066453/5.png

  6. Restart the Windows PowerShell ISE.
  7. You are ready. Happy scripting.

Points of Interest

I know we are so lazy that we want to get everything as easy as Copy & Paste. So, all the scripts images above are in text format.

  1. Script snippet for Step 2.
    PowerShell
    if (!(test-path $profile )) 
    { 
        new-item -type file -path $profile -force 
    }
  2. Script Snippet for Step 5.
    PowerShell
    if((Get-PSSnapin | Where-Object {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) 
    { 
        Add-PSSnapIn "Microsoft.SharePoint.Powershell" 
    }
  3. If you receive any access issue while executing the above script snippet, refer to this link.

    Solution:

    PowerShell
    Set-ExecutionPolicy Unrestricted
  4. The above example will create a file for your logged in profile in Windows system. If you want to make it work for all users and you have administrator access, then you can use the below command. It will create a profile.ps1 file at "C:\Windows\System32\WindowsPowerShell\v1.0" folder. After executing the below script, follow Step 5 to Step 6.
    PowerShell
    if (!(test-path $profile.AllUsersAllHosts))
    {
         new-item -type file -path $profile.AllUsersAllHosts-force
    }

History

  • 22nd December, 2015: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Comments and Discussions

 
-- There are no messages in this forum --