This blog post was written about the Preview of SharePoint 2013. This behavior may be different in the RTM version of the product.
One of the biggest additions to SharePoint 2013 is the introduction of the App model. I’m not going to go into a lot of detail on it here. It’s essentially a framework for publishing code that extends the functionality of SharePoint. As with anything, it needs to be installed and configured to work correctly. Mirjam van Olst (Blog | Twitter) has a great blog post on how to do this. This post is not designed to replace her post, only augment it. Mirjim’s post walks you through how to configure it all. My blog post will show how to do the same SharePoint tasks in PowerShell.
The first thing you need to do is read Mirjam’s blog post to understand what you’re doing. Then go back and do all the steps she outlines in DNS. Create all the zones and records. You can make the DNS changes in native PowerShell, but it’s ugly. It requires some gnarly WMI. Alternatively you can use the DnsShell Codplex project. (thanks, Jonathan)
That should take you to the “Configuring SharePoint” section. Here is the PowerShell I used to create those service applications, start their service instances, and configuring the paths you defined in DNS.
# Assumes you have a Service App Pool named "Default SharePoint Service App Pool"
$apppool = Get-SPServiceApplicationPool "Default SharePoint Service App Pool"
$appname = "App Management Service"
$dbname = "AppManagement_DB"
# Create the App Management service and start its service instance
$sa = New-SPAppManagementServiceApplication -ApplicationPool $apppool -Name $appname -DatabaseName $dbname
New-SPAppManagementServiceApplicationProxy -ServiceApplication $sa -Name "$appname Proxy"
Get-SPServiceInstance | Where-Object { $_.typename -eq "App Management Service" } | Start-SPServiceInstance
# Create the Subscription Settings service and start its service instance
$sa = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPool -Name "Subscription Settings Service" -DatabaseName "Subscription_Settings_Service_DB"
New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $sa
Get-SPServiceInstance | where{$_.TypeName -eq "Microsoft SharePoint Foundation Subscription Settings Service"} | Start-SPServiceInstance
# Configure your app domain and location
# assumes path of app.contoso-apps.com
Set-spappdomain -appdomain "contoso-apps.com"
Set-spappSiteSubscriptionName -Name "app"
That should do it. That should get you the same service applications and settings and Mirjam’s post.
tk
ShortURL: http://www.toddklindt.com/SP2013AppDomainPosh
Updated 8/14/2012 with better PowerShell for the App Management service (thanks, Spence) and a link to the DNSShell Codeplex project.