Cmdlet Samples
This section includes some useful scenarios that can be automated through cmdlets.
Note
Some of these samples use
pipelining to send their output into other cmdlets. This is useful
especially for properties such as GUIDs or SPCmdletObjectId parameters
that are not easy to discover or type.
Pipelining is a concept
from PowerShell. With pipelining, the output of one command can be
directly sent to another command. Typically, this is seen when there is a
Get command that retrieves a particular object and pipes the object to a
Set command that sets a property on the object.
Creating a New Service Application
This cmdlet creates a new PPS
service application with the specified name and using an already
registered SharePoint managed account, such as the following:
New-SPPerformancePointServiceApplication -Name "MyServiceApplication"
-ApplicationPool (New-SPIisWebServiceApplicationPool "SharePoint Hosted Services"
-account "domain\SharePointManagedAccount")
Starting the Shared Service
This cmdlet starts the PPS
shared service. You can run this cmdlet on any application server in the
farm on which you would like to have this service started:
Get-SPServiceInstance | Where{$_.TypeName -eq "PerformancePoint Service"} |
Start-SPServiceInstance Creating a New Web Application
This cmdlet creates a new web application at port 81 with the specified name, such as the following:
New-SPWebApplication -Name "MyWebApplication" -Port 81
Create a New Site Collection
This cmdlet creates a new site collection at the root of the web application at port 81, such as the following:
New-SPSite http://localhost:81 -owneralias domain\user
Changing PPS Service Settings
The cmdlets in this
section change the Unattended Service Account. This proves especially
useful for updating the unattended service account password after it has
been changed.
This cmdlet displays a prompt for credentials and change the Unattended Service Account on the specified service application:
Set-SPPerformancePointSecureDataValues -ServiceApplication "MyServiceApplication"
-DataSourceUnattendedServiceAccount (Get-credential)
This cmdlet has the credentials for the Unattended Service Account stored in plain text in the command. By omitting the –name parameter from the Get-SPPerformancePointServiceApplication command, it executes on the default service application:
Get-SPPerformancePointServiceApplication | Set-SPPerformancePointSecureDataValues
-DataSourceUnattendedServiceAccount (new-object
System.Management.Automation.PSCredential -argumentlist ("domain\serviceaccount"),
(ConvertTo-SecureString "password" -asPlainText -force))
Adding a Trusted Data Source Location
This cmdlet switches the trusted data source locations from trusting all locations to trusting specific locations:
Get-SPerformancePointMonitoringServiceApplication |
Set-SPPerformancePointServiceApplication -TrustedDataSourceLocationsRestricted 1
Next, this cmdlet adds a single document library trusted location for data sources for the default service application:
Get-SPPerformancePointServiceApplication | New-
SPPerformancePointServiceApplicationTrustedLocation -url
http://SharePointServer/Data%20Source -Type DocumentLibrary -TrustedLocation Data
Source
Retrieving All Configured Trusted Locations
This cmdlet retrieves a collection of all configured trusted locations for the default service application:
Get-SPerformancePointMonitoringServiceApplication |
Get-SPPerformancePointServiceApplicationTrustedLocation