Thursday, May 28, 2015

Set App Permission using Powershell

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$spw = Get-SPSite "http://server.domain.com"
$clientID = "86e47e56-f289-4f68-b832-58b0542e0c96"
$authRealm = Get-SPAuthenticationRealm -ServiceContext $spw
$spAppId = $clientID + "@" + $authRealm
$spAppPrincipal = Get-SPAppPrincipal -Site $spw.RootWeb -NameIdentifier $spAppId
Set-SPAppPrincipalPermission -Site $spw.RootWeb -AppPrincipal $spAppPrincipal -Scope SiteSubscription -Right FullControl