Tuesday, February 21, 2017

Powershell in Sharepoint

PowerShell in SharePoint

What is PowerShell?

  • Built on the .NET Framework
  • Windows PowerShell is a task-based command-line shell and scripting language
  • Engine or Environment which improves management
  • It is designed specifically for system administrators and power-users
  • To rapidly automate the administration of multiple operating systems (Linux, OSX, Unix, and Windows) and the processes related to the applications that run on those operating systems.

 Why PowerShell?

  •  No need to retype code across servers
  •  It’s not going away any time soon
  •  Most Microsoft Products will eventually use it
  •   It can make your life easier
  •   Automate
  •   Do things which cannot be done using Central Administration
  •   You can’t do everything from the GUI anymore
  •   You can use PowerShell commands to manage your domains
  •    PowerShell ISE (Intellisense, copy/paste, test partial code)
  •    It enables interactivity between products
  •    Security

What’s new with PowerShell?

        Windows PowerShell 5.0 includes significant new features
  • Extend its use
  • Improve its usability
  • Allow you to control and manage Windows-based environments more easily and comprehensively
  • Major improvements in the areas of Desired state configuration, security, performance, remoting and language enhancements
  • Backward Compatible

 Fundamental Concepts

-  Windows PowerShell Basics
Some basic tools and concepts that can be used to learn Windows PowerShell quickly

  • Using Get-Command
  • Using Cmd.exe and UNIX commands
  • Using External Commands
  • Using Tab-Completion
  • Using Get-Help 

- Getting Detailed Help Information  
Windows PowerShell includes detailed Help topics that explain Windows PowerShell concepts and the Windows PowerShell language. There are also Help topics for each cmdlet and provider and Help topics for many functions and scripts.

To get Help about Windows PowerShell cmdlets
                      get-help get-childitem

To get Help about the Get-Help cmdlet
                      get-help get-help

To display only the examples in a Help topic
                      get-help get-childitem -examples

- Getting Information about commands
Windows PowerShell Get-Command cmdlet gets all commands that are available in your current session.
                      Get-Command

The Get-Command command does not list every command that is available in Windows PowerShell. Instead, the Get-Command command lists only the cmdlets in the current session.
              To get all the commands in the session

                      Get-Command *
             
SharePoint Powershell Snapin
When using the “SharePoint 2013 Management Shell” it automatically loads a “snapin” which is basically a PowerShell extension that gives you a series of commands for working with SharePoint objects. When you use the Windows PowerShell ISE it has no idea of SharePoint, so you need to load the SharePoint snapin manually.

                     Add-PSSnapin “Microsoft.SharePoint.PowerShell”

Windows PowerShell Integrated Scripting Environment (ISE)
The Windows PowerShell Integrated Scripting Environment (ISE) is one of two hosts for the Windows PowerShell engine and language. With it you can write, run, and test scripts in ways that are not available in the Windows PowerShell Console. The ISE adds syntax-coloring, tab completion, IntelliSense, visual debugging, and context sensitive Help.
The ISE lets you run commands in a console pane, but it also supports panes that you can use to simultaneously view the source code of your script and other tools that can plug into the ISE. You can even open up multiple script windows at the same time, which is especially helpful when you are debugging a script that uses functions defined in other scripts or modules.

Here are some of the features that have been added to the ISE in the most recent releases of PowerShell.Added in PowerShell 3.0(Windows Server 2012, Windows 8)

  •  Intellisense
  •  Snippets
  •  Add-on tools
  •  Restart Manager and Auto-save
  •  Most recently used list
  •  Merged Console Pane
  •  Command-line Switches
New editor features

  • XML syntax coloring
  • Brace Matching
  • Outline view
  • Drag and drop text editing
  • Parse error display
  •  Zoom
  •  Rich text copy and paste
  •  Block selection






 New PowerShell cmdlets List - SharePoint 2016

Cmdlet Name
Description

Add-DatabaseToAvailabilityGroup
Adds one or more databases from a SharePoint farm into an availability group in SQL Server

Copy-SPAccessServicesDatabaseCredentials  

Copies credentials of an application from one logical server to another

Copy-SPSideBySideFiles
Copy side by side files

Enable-SPWebtemplateForSiteMaster
Creates a template for a site master

Export-SPAccessServicesDatabase
Exports the access database in to a bacpac package

Export-SPTagsAndNotesData
Exports the sharepoint newsfeed tags and notes

Get-AvailabilityGroupStatus
Returns one or more objects representing the availability groups

Get-SPAppStoreWebServiceConfiguration
Returns properties of a SharePoint Store app

Get-SPConnectedServiceApplicationInformation
Returns the health of the service application proxy

Get-SPInsightsConfig  

Returns the uploader.xml and Microsoft.Office.BigData.DataLoader.exe.config files from the Configuration database.

Get-SPMicrofeedOptions  

Returns the feed cache settings for the current user profile application.
Get-SPService  

Gets a service in the farm.

Get-SPSiteMaster  

Returns site master information.

Get-SPWebTemplatesEnabledForSiteMaster  

Returns a list of site master web templates.

Import-SPAccessServicesDatabase  

Imports the Access Database from a Bacpac package.

Move-SPSocialComment

Moves social comments.

New-SPSiteMaster  

Creates a site master.
Remove-SPActivityItems  

Removes activity events from the published and consolidated tables.

Remove-SPCentralAdministration  

Removes the SharePoint Central Administration web site from the local server.

Remove-SPSiteMaster  

Removes a site master.

Reset-SPSites  

Synchronizes the content database with the configuration database of the farm.

Set-SPAppStoreWebServiceConfiguration  

Sets properties of a SharePoint Store app.

Set-SPServer  

Changes the role of the server.

Start-SPService  

Enables a service in the farm.

Stop-SPService  

Disables a service in the farm.

Update-SPMicrofeedOptions  

Updates the feed cache settings for the current user profile application.


No comments:

Post a Comment