Update Secure Store Service Application using PowerShell

This post describes how you can update the Secure Store Service Application using PowerShell.

You can use the following script to update information for one of your Secure Store Applications.
I want to change the Contact E-mail property for this Secure Store Application to “NewEmail@xxx.com”

Used Configuration
For this part, I have set up the following:

– 1 Web Application (My intranet)
– 1 Secure Store Service Application
– Created 1 Application: “TestID”:

Secure Store Service Application

Pre-requisites
I found that before this works, you need the following:
– Site Collection Administrator for the root of the web application (my intranet)
– Full Control on the Secure Store Service Application. You can set this by going to:
Central Administration -> Application Management -> Manage Service Application -> Highlight the Secure Store Service Application -> Select “Administrators” from the ribbon.

Secure Store administrators

Changing the desired property

#Add the PowerShell Snapin
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue #Retrieve the Service context
$site = new-object Microsoft.SharePoint.SPSite("https://demo.contoso.com");
$ServiceContext = [Microsoft.SharePoint.SPServiceContext]::GetContext($site);

#Get the Secure Store Application and save the new information into a variable
$Application = Get-SPSecureStoreApplication -Name "TestID" -ServiceContext $ServiceContext
$TargetApplication = $Application.TargetApplication
$TargetApplication.ContactEmail = "NewEmail@xxx.com"

#Set the saved information to the Target Application
Set-SPSecureStoreApplication -Identity $Application -TargetApplication $TargetApplication

Result

Target Application ID

Leave a Reply

Your email address will not be published. Required fields are marked *