Freigeben über


Setting up your App domain for SharePoint 2013 via PowerShell

There is an excellent article on MSDN called “How to: Set up an on-premises development environment for apps for SharePoint.”

I’ve created a PowerShell script that runs all the required commands for you, please be sure that you run it as administrator.
The Disable of the loopback check in the registry is included.

 

 

 # Check if the execution policy is set to Unrestricted
 $policy = Get-ExecutionPolicy
 if($policy -ne "Unrestricted"){
 Set-ExecutionPolicy "Unrestricted"
 }
 
 # Check if current script is running under administrator credentials
 $currentPrincipal = New-Object Security.Principal.WindowsPrincipal( [Security.Principal.WindowsIdentity]::GetCurrent() )
 if ($currentPrincipal.IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator ) -eq $false) { 
 (get-host).UI.RawUI.Backgroundcolor="DarkRed" 
 clear-host 
 write-host "Warning: PowerShell is not running as an Administrator.`n" 
 exit
 }
 
 # Load SharePoint powershell commands
 Add-PSSnapin "microsoft.sharepoint.powershell" -ErrorAction SilentlyContinue
 
 cls
 
 # Ensure that the spadmin and sptimer services are running
 Write-Host
 Write-Host "Ensure that the spadmin and sptimer services are running" -ForegroundColor Yellow
 net start spadminv4
 net start sptimerv4
 
 # Create your isolated app domain by running the SharePoint Management Shell as an administrator and typing the following command.
 Write-Host
 Write-Host "Create your isolated app domain by running the SharePoint Management Shell as an administrator and typing the following command." -ForegroundColor Yellow
 $appdomain = Read-Host "Your App Domain Name"
 Set-SPAppDomain $appdomain
 
 # Ensure that the SPSubscriptionSettingsService and AppManagementServiceInstance services are running 
 Write-Host
 Write-Host "Ensure that the SPSubscriptionSettingsService and AppManagementServiceInstance services are running." -ForegroundColor Yellow
 Get-SPServiceInstance | where{$_.GetType().Name -eq "AppManagementServiceInstance" -or $_.GetType().Name -eq "SPSubscriptionSettingsServiceInstance"} | Start-SPServiceInstance
 
 # Verify that the SPSubscriptionSettingsService and AppManagementServiceInstance services are running 
 Write-Host
 Write-Host "Verify that the SPSubscriptionSettingsService and AppManagementServiceInstance services are running." -ForegroundColor Yellow
 Get-SPServiceInstance | where{$_.GetType().Name -eq "AppManagementServiceInstance" -or $_.GetType().Name -eq "SPSubscriptionSettingsServiceInstance"}
 
 # Specify an account, application pool, and database settings for the SPSubscriptionService and AppManagementServiceInstance services 
 Write-Host
 Write-Host "Specify an account, application pool, and database settings for the SPSubscriptionService and AppManagementServiceInstance services." -ForegroundColor Yellow
 $login = Read-Host "The login of a managed account"
 $account = Get-SPManagedAccount $login 
 $appPoolSubSvc = New-SPServiceApplicationPool -Name SettingsServiceAppPool -Account $account
 Write-Host "SettingsServiceAppPool created (1/6)" -ForegroundColor Green
 $appPoolAppSvc = New-SPServiceApplicationPool -Name AppServiceAppPool -Account $account
 Write-Host "AppServiceAppPool created (2/6)" -ForegroundColor Green
 $appSubSvc = New-SPSubscriptionSettingsServiceApplication –ApplicationPool $appPoolSubSvc –Name SettingsServiceApp –DatabaseName SettingsServiceDB 
 Write-Host "SubscriptionSettingsServiceApplication created (3/6)" -ForegroundColor Green
 $proxySubSvc = New-SPSubscriptionSettingsServiceApplicationProxy –ServiceApplication $appSubSvc
 Write-Host "SubscriptionSettingsServiceApplicationProxy created (4/6)" -ForegroundColor Green
 $appAppSvc = New-SPAppManagementServiceApplication -ApplicationPool $appPoolAppSvc -Name AppServiceApp -DatabaseName AppServiceDB
 Write-Host "AppManagementServiceApplication created (5/6)" -ForegroundColor Green
 $proxyAppSvc = New-SPAppManagementServiceApplicationProxy -ServiceApplication $appAppSvc
 Write-Host "AppManagementServiceApplicationProxy created (6/6)" -ForegroundColor Green
 
 # Specify your tenant name 
 write-host
 Write-Host "Set AppSiteSubscriptionName to 'app'" -ForegroundColor Yellow
 Set-SPAppSiteSubscriptionName -Name "app" -Confirm:$false
 Write-Host "AppSiteSubscriptionName set" -ForegroundColor Green
 
 # Disable the loopbackcheck in the registry
 Write-Host "Disable the loopbackcheck in the registry" -ForegroundColor Yellow
 New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\" -Name "DisableLoopbackCheck" -PropertyType DWord -Value 1
 
 Write-Host "Completed"

create an isolated app domain.ps1

Comments

  • Anonymous
    January 14, 2013
    I did all the other settings like the other article that you mentioned. But you have got the disable loop back. When I applied that, it works like charm. Thanks a lot for nice and neat script.

  • Anonymous
    January 15, 2014
    Interesting and helpful post. Thanks Tom!

  • Anonymous
    September 10, 2014
    This script is not working for me. When I try to set the subscription service application, I keep getting an error that the parameter is null. And I get errors that the database already exists. Been at this for days. Any help would be appreciated.

  • Anonymous
    April 05, 2015
    Dears, I don't have application domain. What shall do. What you mean by App Domain, Is it a purchased domain? Confused. Please help me. Thanks in Advance.

  • Anonymous
    May 08, 2015
    It need not be purchased domain. on your development server use domain like "companyname.com" or indeed any name of your interest. @som

  • Anonymous
    May 08, 2015
    Thanks Tom for your efforts to write PS script. I too have used the same link that you mentioned for setting up my environment a couple of days back. I am planning to automate the steps and your write up saves my time.

  • Anonymous
    June 25, 2015
    Before you run this script you need to ensure a managed account is created in the SharePoint configuration. I followed the answer described here sharepoint.stackexchange.com/.../how-to-get-all-managed-accounts-and-create-a-new-one-using-powershell-in-sharepo