Administration, Events

Quick Starting Demos and Windows PowerShell

Preparing virtual machines for demonstrations can be a tedious process, compounding this is when virtual machines need to be started or shut down in a specific order.  For example, starting database servers prior to starting web servers, or starting the preferred active node before the passive node.  Starting those machines; however, is only a portion of the process, in most cases you will want them to be “available” before starting a subsequent machine.  For example, having an iSCSI Target available before the consuming iSCSI initiators are available.  Windows PowerShell, is perfect to support this scenario – it’s something I use almost everyday and have shared an example (below) of how you can accomplish all of these tasks…

So what does it do?

Provides parameters to Start/Shut Down one or more virtual machines.

Checks for process elevation, escapes if the script is not run elevated.

Starts the Hyper-V Virtual Machine Management Service if not running.

Iterates through an array of virtual machines stored in a .txt file.

Starts each virtual machine in the .txt file and waits for the heartbeat status to report ‘OK’ before starting the next virtual machine in the list.  Virtual machines are started in the order they appear in the source file, waiting ensures a clean start up – particularly where a defined start order with dependencies exists.

Shuts down virtual machines in the reverse order they were started by reading the source file bottom to top.  Waits for the virtual machine heartbeat status to report ‘’ before processing the next virtual machine.

Displays a progress bar to report on the status of the operation.

Script

[CmdletBinding(ConfirmImpact="Low")]

Param(
     [Parameter(Mandatory=$True,Position=0,ValueFromPipeline=$False,HelpMessage="Operation to perform on one or more virtual machines.")][ValidateSet("Start","Stop")]
     [String]$operation,
     [Parameter(Mandatory=$True,Position=1,ValueFromPipeline=$False,HelpMessage="Collection of virtual machines on which operation is to be performed.")][ValidateNotNullorEmpty()]
     [String]$source
)

$ErrorActionPreference = "Stop"

Process
{
     $identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
     $principal = New-Object System.Security.Principal.WindowsPrincipal($identity)
     $role = [System.Security.Principal.WindowsBuiltInRole]::Administrator
     $elevated = $principal.IsInRole($role)

     If ($operation -eq "Start")
     {
         $service = Get-Service -Name vmms

         If ($service.Status -ne "Running")
         {
             Try
             {
                 If ($elevated)
                 {
                     Start-Service $service

                     Write-Host "Starting the Hyper-V Virtual Machine Management Service."

                     Start-Sleep -s 10

                     Clear-Host
                 }
                 Else
                 {
                     Write-Host "Requires elevation."
                     break
                 }
             }
             Catch
             {
                 [System.Exception]
                 Write-Host "Could not start Virtual Machine Management Service."
                 break
             }
         }

         $exists = Test-Path "$(Get-Location)$source.txt" 

         If ($exists -eq $True)
         {
             Try
             {
                 $list = Get-Content "$(Get-Location)$source.txt"
             }
             Catch
             {
                 [System.Exception]
                 break
             }
         }
         Else
         {
             Write-Host "The file could not be found: $source.  The document name or path is not valid."
             break
         }

         For ( $count = 0; $count -lt $list.Count; $count++
         { 
             $guest = $list[$count]

             $progress = 100 / $list.Count * ($count + 1)

             Write-Progress -Activity "Starting virtual machine…" -CurrentOperation "Starting…" -Status $guest -PercentComplete $progress

             Try
             {
                 If ($elevated)
                 {
                     Start-VM -Name $guest
                 }
                 Else
                 {
                     Write-Host "Requires elevation."
                     break
                 }
             }
             Catch
             {
                 Write-Host "Could not start virtual machine(s)."
                 break
             }

             Write-Progress -Activity "Starting virtual machine…" -CurrentOperation "Waiting…" -Status $guest -PercentComplete $progress

             do {Start-Sleep -milliseconds 100
             until ((Get-VMIntegrationService $guest | ?{$_.name -eq "Heartbeat"}).PrimaryStatusDescription -eq "OK")
         }
     }

     ElseIf ($operation -eq "Stop")
     {
         $exists = Test-Path "$(Get-Location)$source.txt" 

         If ($exists -eq $True)
         {
             Try
             {
                 $list = Get-Content "$(Get-Location)$source.txt"
             }
             Catch
             {
                 [System.Exception]
                 break
             }
         }
         Else
         {
             Write-Host "The file could not be found: $source.  The document name or path is not valid."
             break
         }

         For ($count = $list.Length1; $count -ge 0 ; $count)
         { 
             $guest = $list[$count]

             $progress = 100 / $list.Count * ($count + 1)

             Write-Progress -Activity "Stopping virtual machine…" -CurrentOperation "Stopping…" -Status $guest -PercentComplete $progress
    
             Try
             {
                 Stop-VM -Name $guest
             }
             Catch
             {
                 Write-Host "Could not stop virtual machine."
                 break
             }

             Write-Progress -Activity "Stopping virtual machine…" -CurrentOperation "Waiting…" -Status $guest -PercentComplete $progress

             do {Start-Sleep -milliseconds 100
             until ((Get-VMIntegrationService $guest | ?{$_.name -eq "Heartbeat"}).PrimaryStatusDescription -ne "OK")
         }

         Start-Sleep -s 10

         If ($elevated)
         {
             Try
             {
                 Stop-Service vmms
                 Write-Host "Stopping the Hyper-V Virtual Machine Management Service…"
             }
             Catch
             {
                 [System.Exception]
                 Write-Host "Could not stop the Hyper-V Virtual Machine Management Service."
                 break
             }
         }
         Else
         {
             Write-Host "Requires elevation."
             break
         }

         Clear-Host
     }
}

Usage

Using the scripts requires 1) saving the attached script as <name>.ps1 2) creating source .txt file with virtual machines listed in the preferred start up order.  For example,

Machine1

Machine2

Machine3

3) Saving the script and source .txt file in the same location.

4) Running the script as <name>.ps1 –Operation Start –Source <name>

Standard
Administration, Events

Quick Starting Demos with Windows PowerShell

Preparing virtual machines for demonstrations can be a tedious process, compounding this is when virtual machines need to be started or shut down in a specific order.  For example, starting database servers prior to starting web servers, or starting the preferred active node before the passive node.  Starting those machines; however, is only a portion of the process, in most cases you will want them to be “available” before starting a subsequent machine.  For example, having an iSCSI Target available before the consuming iSCSI initiators are available.  Windows PowerShell, is perfect to support this scenario – it’s something I use almost everyday and have shared an example (below) of how you can accomplish all of these tasks…

So what does it do?

Provides parameters to Start/Shut Down one or more virtual machines.

Checks for process elevation, escapes if the script is not run elevated.

Starts the Hyper-V Virtual Machine Management Service if not running.

Iterates through an array of virtual machines stored in a .txt file.

Starts each virtual machine in the .txt file and waits for the heartbeat status to report ‘OK’ before starting the next virtual machine in the list.  Virtual machines are started in the order they appear in the source file, waiting ensures a clean start up – particularly where a defined start order with dependencies exists.

Shuts down virtual machines in the reverse order they were started by reading the source file bottom to top.  Waits for the virtual machine heartbeat status to report ‘’ before processing the next virtual machine.

Displays a progress bar to report on the status of the operation.

Script

[CmdletBinding(ConfirmImpact="Low")]

Param(
     [Parameter(Mandatory=$True,Position=0,ValueFromPipeline=$False,HelpMessage="Operation to perform on one or more virtual machines.")][ValidateSet("Start","Stop")]
     [String]$operation,
     [Parameter(Mandatory=$True,Position=1,ValueFromPipeline=$False,HelpMessage="Collection of virtual machines on which operation is to be performed.")][ValidateNotNullorEmpty()]
     [String]$source
)

$ErrorActionPreference = "Stop"

Process
{
     $identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
     $principal = New-Object System.Security.Principal.WindowsPrincipal($identity)
     $role = [System.Security.Principal.WindowsBuiltInRole]::Administrator
     $elevated = $principal.IsInRole($role)

     If ($operation -eq "Start")
     {
         $service = Get-Service -Name vmms

         If ($service.Status -ne "Running")
         {
             Try
             {
                 If ($elevated)
                 {
                     Start-Service $service

                     Write-Host "Starting the Hyper-V Virtual Machine Management Service."

                     Start-Sleep -s 10

                     Clear-Host
                 }
                 Else
                 {
                     Write-Host "Requires elevation."
                     break
                 }
             }
             Catch
             {
                 [System.Exception]
                 Write-Host "Could not start Virtual Machine Management Service."
                 break
             }
         }

         $exists = Test-Path "$(Get-Location)$source.txt" 

         If ($exists -eq $True)
         {
             Try
             {
                 $list = Get-Content "$(Get-Location)$source.txt"
             }
             Catch
             {
                 [System.Exception]
                 break
             }
         }
         Else
         {
             Write-Host "The file could not be found: $source.  The document name or path is not valid."
             break
         }

         For ( $count = 0; $count -lt $list.Count; $count++
         { 
             $guest = $list[$count]

             $progress = 100 / $list.Count * ($count + 1)

             Write-Progress -Activity "Starting virtual machine…" -CurrentOperation "Starting…" -Status $guest -PercentComplete $progress

             Try
             {
                 If ($elevated)
                 {
                     Start-VM -Name $guest
                 }
                 Else
                 {
                     Write-Host "Requires elevation."
                     break
                 }
             }
             Catch
             {
                 Write-Host "Could not start virtual machine(s)."
                 break
             }

             Write-Progress -Activity "Starting virtual machine…" -CurrentOperation "Waiting…" -Status $guest -PercentComplete $progress

             do {Start-Sleep -milliseconds 100
             until ((Get-VMIntegrationService $guest | ?{$_.name -eq "Heartbeat"}).PrimaryStatusDescription -eq "OK")
         }
     }

     ElseIf ($operation -eq "Stop")
     {
         $exists = Test-Path "$(Get-Location)$source.txt" 

         If ($exists -eq $True)
         {
             Try
             {
                 $list = Get-Content "$(Get-Location)$source.txt"
             }
             Catch
             {
                 [System.Exception]
                 break
             }
         }
         Else
         {
             Write-Host "The file could not be found: $source.  The document name or path is not valid."
             break
         }

         For ($count = $list.Length1; $count -ge 0 ; $count)
         { 
             $guest = $list[$count]

             $progress = 100 / $list.Count * ($count + 1)

             Write-Progress -Activity "Stopping virtual machine…" -CurrentOperation "Stopping…" -Status $guest -PercentComplete $progress
    
             Try
             {
                 Stop-VM -Name $guest
             }
             Catch
             {
                 Write-Host "Could not stop virtual machine."
                 break
             }

             Write-Progress -Activity "Stopping virtual machine…" -CurrentOperation "Waiting…" -Status $guest -PercentComplete $progress

             do {Start-Sleep -milliseconds 100
             until ((Get-VMIntegrationService $guest | ?{$_.name -eq "Heartbeat"}).PrimaryStatusDescription -ne "OK")
         }

         Start-Sleep -s 10

         If ($elevated)
         {
             Try
             {
                 Stop-Service vmms
                 Write-Host "Stopping the Hyper-V Virtual Machine Management Service…"
             }
             Catch
             {
                 [System.Exception]
                 Write-Host "Could not stop the Hyper-V Virtual Machine Management Service."
                 break
             }
         }
         Else
         {
             Write-Host "Requires elevation."
             break
         }

         Clear-Host
     }
}

Usage

Using the scripts requires 1) saving the attached script as <name>.ps1 2) creating source .txt file with virtual machines listed in the preferred start up order.  For example,

Machine1

Machine2

Machine3

3) Saving the script and source .txt file in the same location.

4) Running the script as <name>.ps1 –Operation Start –Source <name>

Standard
Administration, SharePoint

Introduction to System Status Notifications in SharePoint 2013

SharePoint 2013 implements new System Status Notifications designed to provide site users information about lifecycle events to include availability of upgrade, maintenance, and read-only states.

System Status Notifications present important information about a SharePoint deployment and its availability, whether during upgrades, routine maintenance,  or conversion to read-only. Users are kept “in the know” as they receive a prominent banner on their sites that provides insight into the activity being performed—helping reduce calls to the help desk and subsequent burden on IT.

Farm administrators and developers can configure System Status Notifications to provide additional information to users and adjust upgrade delays.

SPWebApplication Properties

UpgradeReminderDelay

The UpgradeReminderDelay property is used to enable users to suppress the upgrade availability System Status Notification for a specified period of time.  Farm administrators can configure the UpgradeReminderDelay to allow users to suppress the UpgradeAvailable reminder for a period of time or alternatively set the value to 0 which shows users an UpgradeRequired reminder.  The default value is 30 (days).

image

Figure 1 above illustrates the System Status Notification when the UpgradeReminderDelay is set to a value greater than 0.

image

Figure 2 above illustrates the System Status Notification when the UpgradeReminderDelay is set to 0.

Configuring the UpgradeReminderDelay SPWebApplication property:

C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace Sample_Maintenance_Link_Code
{
    class Program
    {
        static void Main(string[] args)
        {
            SPWebApplication webApp = SPWebApplication.Lookup(new Uri("http://sharepoint.contoso.com"));
            webApp.UpgradeReminderDelay = 90;
            webApp.Update();
        }
    }
}

Windows PowerShell

$webApp = Get-SPWebApplication http://sharepoint.contoso.com

$webApp.UpgradeReminderDelay = 90

$weApp.Update()

UpgradeMaintenanceLink

The UpgradeMaintenanceLink property is used to provide users additional information during the site collection upgrade process.  Farm administrators can use the UpgradeMaintenanceLink property to enable a More Information link in the System Status Notification during the upgrade process directing users to a location where more information is available related to the upgrade process.  The default value for the UpgradeMaintenanceLink property is null therefore no More Information link is displayed to users.

image

Figure 3 Illustrates the System Status Notification when the UpgradeMaintenanceLink is not null.

Configuring the UpgradeMaintenanceLink SPWebApplication property:

C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace Sample_Maintenance_Link_Code
{
     class Program
     {
         static void Main(string[] args)
         {
             SPWebApplication webApp = SPWebApplication.Lookup(new Uri("http://sharepoint.contoso.com"));
             webApp.UpgradeMaintenanceLink = "http://office.microsoft.com/en-us/sharepoint-help/training-courses-for-sharepoint-2013-HA104030990.aspx&quot;;
             webApp.Update();
         }
     }
}

Windows PowerShell

$webApp = Get-SPWebApplication http://sharepoint.contoso.com

$webApp.UpgradeMaintenanceLink =  “http://office.microsoft.com/en-us/sharepoint-help/training-courses-for-sharepoint-2013-HA104030990.aspx”

$webApp.Update()

ReadOnlyMaintenanceLink

The ReadOnlyMaintenanceLink property is used to provide users additional information when a site collection is set to read-only or a content database is configured to read-only in Microsoft SQL Server.  Farm administrators can use the ReadOnlyMaintenanceLink property to enable a More information link in the System Status Notification while a site collection or content database is in a read-only state.  The default value for the ReadOnlyMaintenanceLink is null therefore no More Information link is displayed to users.  For example, if a farm administrator would like to provide additional information on the read-only experience for users, the ReadOnlyMaintenanceLink can be configured with a More information link that directs users to http://technet.microsoft.com/en-us/library/dd793608.aspx#proc1.

image

Figure 4 Illustrates the System Status Notification when the ReadOnly property for a SPSite is set to $true.

image

Figure 5 Illustrates the System Status Notification when the content database for a SPSite is set to read-only.

Configuring the ReadOnlyMaintenanceLink SPWebApplication property:

C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace Sample_Maintenance_Link_Code
{
    class Program
     {
         static void Main(string[] args)
         {
             SPWebApplication webApp = SPWebApplication.Lookup(new Uri("http://sharepoint.contoso.com"));
             webApp.ReadOnlyMaintenanceLink = "http://technet.microsoft.com/en-us/library/dd793608.aspx#proc1&quot;;
             webApp.Update();
         }
     }
}

Windows PowerShell

$webApp = Get-SPWebApplication http://sharepoint.contoso.com

$webApp.ReadOnlyMaintenanceLink = “http://technet.microsoft.com/en-us/library/dd793608.aspx#proc1”;

$webApp.Update()

NOTE

If a site collection or content database is set to read-only, the read-only message is displayed, upgrade status notifications are not displayed.  If ReadOnlyMaintenanceLink is not empty, a More Information link will be displayed.

If a site collection or content database is not read-only, and an upgrade is processing, “the site is currently being upgraded” is displayed.  If UpgradeMaintenanceLink is not empty, a More Information link will be displayed.

If a site collection or content database is not read-only, not upgrading, and the site is in 2010 mode, and current user is site collection admin:

  • If SPWebApplication.UpgradeReminderDelay is greater than 0, “upgrade is available” notification will be displayed. Clicking on the “remind me later” will update the SPSite.UpgradeReminderDate to be in n days, and dismiss the notification.
  • When SPWebApplication.UpgradeReminderDelay is 0, site admin will see “upgrade is required” notification. There will be no “remind me later” option. The notification will be displayed on every browse, and have to be manually dismissed each time.

 

UpgradeEvalSitesRetentionDays

The UpgradeEvalSitesRetentionDays SPWebApplication property is used to specify the default number days after which upgrade evaluation sites will be deleted. The expiration date for upgrade evaluation sites is set based on their creation date plus this value in days.  For example, in the event a site collection administrator requests an evaluation site collection, and that site collection is created on 4/16/2013, the evaluation site collection will be deleted on 5/16/2013 (the default value is 30 days).

image

Figure 6 Illustrates the System Status Notification when the UpgradeEvalSitesRetentionDays is set.

Configuring the UpgradeEvalSitesRetentionDays SPWebApplication property:

C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace Sample_Maintenance_Link_Code
{
    class Program
     {
         static void Main(string[] args)
         {
             SPWebApplication webApp = SPWebApplication.Lookup(new Uri("http://sharepoint.contoso.com"));
             webApp.UpgradeEvalSitesRetentionDays = 90;
             webApp.Update();
         }
     }
}

Windows PowerShell

$webApp = Get-SPWebApplication http://sharepoint.contoso.com

$webApp.UpgradeEvalSitesRetentionDays = 90;

$webApp.Update()

SPSiteUpgradeThrottleSettings

This class stores the throttle settings for large site upgrade, for example, a farm administrator can throttle the upgrade of site collections with a specified number of sites.

See also SPSiteUpgradeThrottleSettings members (Microsoft.SharePoint.

SPSite Properties

UpgradeReminderDate

The UpgradeReminderDate SPSite property is used to specify a date after which site collection administrators will be reminded to upgrade the site collection.

Configuring the UpgradeReminderDate SPSite property:

C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace Sample_Maintenance_Link_Code
{
    class Program
    {
        static void Main(string[] args)
        {
            SPSite site = new SPSite("http://sharepoint.contoso.com");

            System.DateTime today = System.DateTime.Now;
            System.TimeSpan duration = new System.TimeSpan(30, 0, 0, 0);

            site.UpgradeReminderDate.Add(duration);
        }
    }
}

Windows PowerShell

$site = Get-SPSite http://sharepoint.contoso.com

$today = Get-Date

$duration = $today.AddDays(30)

$site.UpgradeReminderDate.Add($duration)

ExtendUpgradeReminderDate

The ExtendUpgradeReminderDate SPSite property is used to extend the upgrade reminder date for a site collection by the days specified at UpgradeReminderDate.  When called, it adds SPWebApplication.UpgradeReminderDelay to the current time, stores it in SPSite.UpgradeReminderDelay.

Configuring the ExtendUpgradeReminderDate SPSite property:

C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace Sample_Maintenance_Link_Code
{
    class Program
    {
        static void Main(string[] args)
        {
            SPSite site = new SPSite("http://sharepoint.contoso.com");
            site.ExtendUpgradeReminderDate();
        }
    }
}

Windows PowerShell

$site = Get-SPSite http://sharepoint.contoso.com

$site.ExtendUpgradeReminderDate()

More Information  

System Status Notifications are rendered through sending JavaScript to the page head and do not implement server-side controls.  The ExtendUpgradeReminderDate is implemented as an xmlHttp object that sends a REST call to web.Url/_api/Site/ExtendUpgradeReminderDate.

AllowSelfServiceUpgrade

The AllowSelfServiceUpgrade SPSite property is used to specify whether version to version upgrade is allowed on a site collection.  If the AllowSelfServiceUpgrade property is set to false site collection administrators will not be able to upgrade their site collection, if set to true, site collection administrators can perform a self-service (Deferred Site Collection Upgrade).  Farm administrators can control the upgrade process either en masse or selectively by disabling self-service upgrade.

image

Figure 7 illustrates configuring the AllowSelfServiceUpgrade SPSite property to $false.

Configuring the AllowSelfServiceUpgrade SPSite property:

C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;

namespace Sample_Maintenance_Link_Code
{
    class Program
    {
        static void Main(string[] args)
        {
            SPSite site = new SPSite("http://sharepoint.contoso.com");
            site.AllowSelfServiceUpgrade = false;
        }
    }
}

Windows PowerShell

$site = Get-SPSite http://sharepoint.contoso.com

$site.AllowSelfServiceUpgrade = $false;

Summary

A completely revised, backward-compatible upgrade experience is designed to balance the needs of users with those of IT. Because changing software is often difficult, SharePoint Server 2013 enables IT to upgrade SharePoint Server 2010 without having to upgrade users’ sites and content. These upgrades are deferred to the users, allowing them to choose when the time is right.

New evaluation site collections allow users to request an evaluation of the upgrade prior to upgrading production content; if satisfied with the experience, site collection administrators then can upgrade their content. It’s important to note that whether you have deployed SharePoint Server 2010 on-premises or subscribe to SharePoint Online in Office 365, the full upgrade capability is available.

Standard
SharePoint

Windows PowerShell Command Builder 2.0

A new updated version of the Windows PowerShell Command Builder is now available.

The Windows PowerShell Command Builder for Microsoft SharePoint 2010, Microsoft SharePoint 2013, SharePoint Online, and Microsoft Office 365 is an HTML 5 application that is designed to help IT professionals and power users learn how to use Windows PowerShell for administrative tasks.  The Windows PowerShell Command Builder enables IT professionals and power users to visually assemble commands related to SharePoint 2010, SharePoint 2013, SharePoint Online, and Office 365 in the browser and take those commands to their respective products. 

The new HTML5-based Windows PowerShell Command Builder can be accessed at http://technet.microsoft.com/en-us/sharepoint/jj672838.aspx and provides many of the same capabilities as the previous Silverlight version such as offline access.  In addition to providing support for SharePoint Server 2010, SharePoint Foundation 2010, and Office 365, this version also introduces support for SharePoint Server 2013, SharePoint Foundation 2013, and SharePoint Online.

To learn more about the Windows PowerShell Command Builder read the Windows PowerShell Command Builder Getting Started Guide.  To begin using the Windows PowerShell Command Builder see SharePoint Server 2010 – Windows PowerShell TechNet.

NOTE

The Windows PowerShell Command Builder constructs commands that can be used with SharePoint Foundation 2010, SharePoint Server 2010, SharePoint Foundation 2013, SharePoint Server 2013, SharePoint Online, and Office 365.

SharePoint 2010 System Requirements

SharePoint 2013 System Requirements

Office 365 System Requirements

About Windows PowerShell

Windows PowerShell is a task-based command-line shell and scripting language that is designed especially for system administration. Built on the .NET Framework, Windows PowerShell helps IT professionals and power users control and automate the administration of the Windows operating system and applications that run on Windows, such as SharePoint.

Windows PowerShell Names

Windows PowerShell uses a "verb-noun" naming system, where each cmdlet name consists of a standard verb that is hyphenated with a specific noun.

Verbs

Windows PowerShell uses the term verb to describe a word that implies an action even if that word is not a standard verb in the English language. For example, the term New is a valid Windows PowerShell verb name because it implies an action even though it is not a verb in the English language.

Common verbs that are used within the Windows PowerShell profile for SharePoint 2010, SharePoint 2013, SharePoint Online, and Office 365 include:

  • Get
  • Set
  • Add
  • Remove
  • New
Nouns

Nouns are very much like nouns in any language. They describe specific types of objects that are important in system administration. Nouns generally describe what a command acts upon. It is easy to demonstrate how these two-part names make it easy to learn how to use Windows PowerShell by looking at a few examples of verbs and nouns.

Verb

Noun

Cmdlet

Get

SPSite

Get-SPSite

Add

SPUser

Add-SPUser

The Windows PowerShell Command Builder provides access to some of the most commonly used routine verb-noun combinations with SharePoint 2010, SharePoint 2013, SharePoint Online, and Office 365. Additional verbs and nouns are added periodically when the application is refreshed.

Using the Windows PowerShell Command Builder

To begin using the Windows PowerShell Command Builder, click the Windows PowerShell Command Builder link in the Windows PowerShell for SharePoint Server 2013 Resource Center. The Windows PowerShell Command Builder will open in the browser and default to the SharePoint Server 2013 product – meaning only those cmdlets available to SharePoint Server 2013 will be presented in the user interface.

The Windows PowerShell Command Builder User Interface

The Products dropdown includes SharePoint Foundation 2010, SharePoint Server 2010, SharePoint Foundation 2013, SharePoint Server 2013, SharePoint Online, and Office 365.

The Windows PowerShell Command Builder user interface distributes the necessary objects across the following three (3) dimensions: 1. Verbs, 2. Nouns, 3. Design Surface. The Verbs dimension contains verbs that are associated with the product that is selected in the Products dropdown. The Nouns dimension contains nouns that are associated with the product that is selected in the Products dropdown. The Design Surface is where verbs and nouns are combined to begin generating a Windows PowerShell command associated with the selected product.

Builder1

Figure 1 Windows PowerShell Command Builder Environment

NOTE

All verb-noun combinations that are available to SharePoint Foundation 2010 are included in SharePoint Server 2010 in addition all verb-noun combinations that are available to SharePoint Foundation 2013 are included in SharePoint Server 2013.

Getting Started

The Windows PowerShell Command Builder provides an intelligent user experience. After you drag a verb or noun object on the Design Surface, the interface will hide either the verbs or nouns that are not associated with the verb or noun placed on the Design Surface.

To begin using the Windows PowerShell Command Builder, select a desired noun and drag it to the Design Surface. The noun will “snap” to the appropriate location in the Design Surface. Next select one of the available verbs and drag it to the Design Surface.

NOTE

On touch-enabled devices a single click on either a verb or noun will display a “Send” prompt that can be used in place of drag and drop where desired.

image

Figure 2 Send Prompt

As elements are placed on the Design Surface, the corresponding Windows PowerShell command will be constructed at the bottom of the Design Surface to include a hyperlink to the related online content. If the constructed command includes required or optional parameters, prompts on the Design Surface indicate where the information can be supplied.

The Windows PowerShell Command Builder minimizes the need to memorize complex cmdlet parameters and noun references by presenting a friendly description of those parameters or nouns. For example, to create a new site collection in SharePoint Foundation 2010 or 2013, the verb-noun combination and required parameters are constructed as follows:

New-SPSite -Identity http://www.contoso.com/

To simplify this construction, Windows PowerShell Command Builder provides a “user friendly” representation of both nouns and in many cases the parameters required to complete a command. For example, in the above example, the Windows PowerShell Command Builder represents the SPSite noun as Site and the -Identity parameter as Url in order to present this information in a user friendly, visual, and structured way.

The Windows PowerShell Command Builder provides access to the most common cmdlets and routine scenarios that are associated with the administration of SharePoint 2010, SharePoint 2013, SharePoint Online, and Office 365. However, Windows PowerShell Command Builder does not provide access to all cmdlets that are associated with these products. The Windows PowerShell Command Builder also provides access to a number of parameters that are associated with each cmdlet. However, Windows PowerShell Command Builder excludes those less commonly used with the respective cmdlet.

NOTE

The Windows PowerShell Command Builder supports both traditional and touch interactions. You can interact with elements in the Windows PowerShell Command Builder by using a mouse and pointer or optionally through natural touch on supported devices.

Using the Clipboard

The Windows PowerShell Command Builder supports copying constructed cmdlets to the Clipboard. To copy a constructed cmdlet, select the Copy to Clipboard button on the Design Surface. The copied cmdlet can then be pasted into a Windows PowerShell script, the SharePoint 2010 Management Shell, or other desired location to be saved or executed.

Clearing the Design Surface

The Windows PowerShell Command Builder Design Surface can be cleared in one of two ways:

  • Drag verbs and nouns back on their respective dimensions.
  • Select the Clear Design Surface button on the Design Surface.

The Clear Design Surface button is not displayed until elements are placed on the Design Surface.

Frequently Asked Questions

Q: I don’t see the verb-noun combination I’m looking for?

A: The initial release of the Windows PowerShell Command Builder provides access to the most common and routine cmdlets available to SharePoint 2010, SharePoint 2013, SharePoint Online, and Office 365. Later releases will introduce additional verb-noun constructs.

Q: Does the Windows PowerShell Command Builder support complex scripting, for example Piping and the Pipeline?

A: No. Windows PowerShell provides access to and supports complex tasks to multiple degrees of variety and preference of the individual constructing the command which cannot be accounted for programmatically. For advanced scripting support with Windows PowerShell see the Windows PowerShell Owner’s Manual.

Q: Can I customize the Windows PowerShell Command Builder?

A: No. The Windows PowerShell Command Builder does not support customization.

Additional Resources

To learn more about SharePoint 2010 Products cmdlets and concepts, see the Windows PowerShell for SharePoint Server 2010 Resource Center.

To learn more about SharePoint 2013 Products cmdlets and concepts, see the Windows PowerShell for SharePoint 2013 Resource Center.

To learn more about Windows PowerShell, see Windows PowerShell in the Scripting library on TechNet.

To learn more about Windows PowerShell in the SharePoint Management Shell, see Windows PowerShell in the SharePoint Management Shell.

To access Windows PowerShell training for SharePoint Server 2010 Administrators, see the Windows PowerShell for SharePoint Server 2010 Administrators video.

To learn more about SharePoint 2010 Products administration using Windows PowerShell, see SharePoint 2010 Products administration by using Windows PowerShell.

Standard
Administration, SharePoint

Windows PowerShell 3.0 and SharePoint Server 2013

SharePoint 2013 includes Windows Management Framework 3.0 the as one of the new prerequisites to installation and configuration.  Included in the Windows Management Framework 3.0 is Windows PowerShell 3.0.

Windows PowerShell 3.0 extends upon the usability of Windows PowerShell 2.0 while maintaining backward compatibility with Windows PowerShell 2.0. Windows PowerShell 3.0 includes a number of new capabilities that can help administrators of a SharePoint farm including new session management, Web access, and scheduling capabilities.

Session Management / Disconnected Sessions

New in Windows PowerShell 3.0 is the ability to manage PSSessions on remote machine. In Windows PowerShell 3.0 PSSessions are persisted on the remote machine created using New-PSSession as opposed to being dependent on the session where they were created. You can use the ComputerName parameter with Get-PSSession to return all of the user’s session on the machine to include those started within a different session or from a different machine. Connecting to sessions allows you to get the results of commands, start new ones, and disconnect sessions.

You can also disconnect from a session without disrupting the commands running in the session. For example, when executing a command such as Get-SPSite | Get-SPWeb, the session can be closed, the initiating machine powered down and the session reconnected to from another machine. While Windows PowerShell 3.0 maintains backward compatibility with Windows PowerShell 2.0, disconnected sessions are supported when the source and destination machines are both running Windows PowerShell 3.0.

Windows PowerShell Web Access

Windows PowerShell 3.0 also includes new Windows PowerShell Web Access with Windows Server 2012 that enables users to run Windows PowerShell cmdlets and scripts in a Web console on devices even where Windows PowerShell is not installed without the need for remote management software or browser plug-ins. All that is required is a properly-configured Windows PowerShell Web Access gateway and a client device browser that supports JavaScript and accepts cookies.

Scheduled Jobs

Job scheduling allows the scheduling and management of background jobs. Scheduled jobs can be viewed and managed through both Windows PowerShell and Task Scheduler.

Like Windows PowerShell background jobs, scheduled jobs run asynchronously in the background. Instances of scheduled jobs that have completed can be managed by using the job cmdlets, such as Start-Job and Get-Job.

Like Task Scheduler tasks, you can run scheduled jobs on a one-time or recurrent schedule or in response to an action or event. You can view and manage scheduled jobs in Task Scheduler, enable and disable them as needed, run them or use them as templates, and set conditions under which the jobs start.

In addition, scheduled jobs come with a customized set of cmdlets for managing them. The cmdlets let you create, edit, manage, disable, and re-enable scheduled jobs, create scheduled job triggers and set scheduled job options.

For example to execute the SharePoint Translation Services Timer Job Definition on a defined schedule:

Create a new Windows PowerShell Script using the following sample:

$tj = Get-SPTimerJob "SharePoint Translation Services"

$tj.Runnow()

Open the Management Shell and enter the following:

$jobTrigger = New-JobTrigger -Daily -At 3AM

$jobOption = New-ScheduledJobOption -HideInTaskScheduler

Register-ScheduledJob -Name "<name>" -FilePath "<drive>:<file>.ps1" -Trigger $jobTrigger -ScheduledJobOption $jobOption

Register-ScheduledJob -Name "<name>" -FilePath "<drive>:<file>.ps1" -Trigger $jobTrigger -ScheduledJobOption $jobOption

This will schedule a new job that will run daily at 3:00 A.M. with the option that it does not appear in the Task Scheduler.

Resources

Learn more about SharePoint Server 2013

Learn more about SharePoint 2013 Hardware and Software Requirements

Learn more about Windows PowerShell and SharePoint 2013

Learn more about Windows PowerShell

Start working with Windows PowerShell and SharePoint with the new Windows PowerShell Command Builder for SharePoint

Standard
Administration, SharePoint

Microsoft SharePoint 2010 Administration Toolkit v1.0 Released

We’ve recently released the first administration toolkit for SharePoint Foundation and SharePoint Server 2010.  The toolkit includes a new User Profile Replication Engine, a new Security Configuration Manifest, a new Content Management Interoperability Services (CMIS) Connector, and the Load Testing Kit (LTK).

User Profile Replication Engine

The User Profile Replication Engine was first introduced as a standalone application in later adminisration toolkits for Office SharePoint Server 2007 to replicate profiles between Shared Services Providers (SSP).  The User Profile Replication Engine for SharePoint Server 2010 was built on Windows PowerShell and now enables the replication of Profile and Social data between the User Profile Service Application in SharePoint Server 2010, in addition to backwards compatibility with Office SharePoint Server 2007 SSPs.  These improvements enable replication between SSP’s or User Profile Service Application services, as well as across versions.  Note Replication is limited to Profile data, SSP’s in Office SharePoint Server 2007 contains no Social activity tracking.

Security Configuration Manifest

The Security Configuration Manifest is an attack surface reduction feature in Windows Server products.   The manifest inlcuded in the administration toolkit adds roles for SharePoint 2010 to Windows Server 2008 with SP2 or Windows Server 2008 R2.

Content Management Interoperability Services Connector

The Content Management Interoperability Services (CMIS) Connector enables consumers of SharePoint to interact with content stored in any repository that has implemented the CMIS standard and in additional enables SharePoint 2010 content to be available to any application that has implemented the CMIS standard.

Load Testing Kit

The Load Testing Kit (LTK) generates a Visual Studio Team System 2008 (VSTS) load test based on Windows SharePoint Services 3.0 Internet Information Services logs.  Load test can be used to generate synthetic load against SharePoint 2010 as part of a capacity planning exercise or a pre-upgrade stress test.

The Microsoft SharePoint 2010 Administration Toolkit v1.0 can be downloaded from http://www.microsoft.com/downloads/details.aspx?FamilyId=718447d8-0814-427a-81c3-c9c3d84c456e&displaylang=en

Microsoft SharePoint 2010 Administration Toolkit v1.0 documentation for SharePoint Foundation 2010 can be downloaded from http://technet.microsoft.com/en-us/library/cc508986.aspx and for SharePoint Server 2010 from http://technet.microsoft.com/en-us/library/cc508851.aspx.

Standard
Uncategorized

Welcome to the Developer Dashboard

About the Developer Dashboard

The Developer Dashboard is an instrumentation framework  new to Microsoft SharePoint Foundation and Server 2010 that can help diagnose particularly, classes of bugs that are easy to introduce through custom code, but often difficult to isolate by providing information about the request execution time, the number and callstack of each SPRequest allocation, the number, callstack, and query text of WCF calls and more.

The Developer Dashboard appears in a frame on the bottom of each page and can exist in one of three (3) possible modes – On, Off, OnDemand.  When the Developer Dashboard is in the ‘On’ mode, it is always displayed in a frame on the bottom of the page for each request, conversely, when the Developer Dashboard is in the ‘Off’ mode, it is not displayed, and finally when the Developer Dashboard is in the ‘OnDemand’ mode, it can be displayed or hidden by selecting an icon on the upper right corner of a page.  (see illustrations).

Developer Dashboard

DeveloperDashboard

OnDemand Mode Icon

ShowHideMe 

Using the Developer Dashboard

The Developer Dashboard makes it easy for IT professionals and developers to identify common issues, for example, if a value exceeds acceptable ranges it will be displayed in red and by hovering your mouse over any value you can receive additional information about that value or how common methods to resolve it depending on the situation.

For developers you can monitor any piece of code by wrapping it in the SPMonitoredScope or even create custom monitors for your own resources through implementing  ISPScopedPerformanceMonitor and adding the monitor to the SPMonitoredScope.

Enabling the Developer Dashboard

The Developer Dashboard can be enabled and disabled through the SharePoint Administration Tool (STSADM) or through Windows PowerShell.  The following examples illustrate each method:

STSADM

‘On’ Mode

STSADM –o setproperty –pn developer-dashboard –pv On

‘Off’ Mode

STSADM –o setproperty –pn developer-dashboard –pv Off

‘OnDemand’ Mode

STSADM –o setproperty –pn developer-dashboard –pv OnDemand

But wait there’s more…

Suppose you’d like to only display the developer dashboard if one or more counters (acceptable values) are exceeded, there’s a way to do that too by running:

STSADM –o setproperty –pn developer-dashboard –pv expensiveoperationsonly

Windows PowerShell

See below.

Scripted (Windows PowerShell)

Optionally you can script the configuration of the Developer Dashboard – to do so copy the following script and save it to somefile.ps1.

Param ([String]$mode)

function Main()
{
  $dashboard = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.DeveloperDashboardSettings;
  $dashboard.DisplayLevel = $mode;
  $dashboard.RequiredPermissions =’EmptyMask’;
  $dashboard.TraceEnabled = $true;
  $dashboard.Update()

  Write-Host "Configured Developer Dashboard with mode $mode."
}

Open the Microsoft SharePoint 2010 Shell and change directories to where you saved somefile.ps1 and run ./somefile.ps1 OnDemand (or optionally On or Off).

Standard