Skip to main content

Access Junkie - MVP Alumnus

Home
Access Inside Out Books
Access 2010 FAQ
Access 2007 Training
Access 2007 FAQ
Access 2007 KB Articles
Technical Articles
Links
MSDN Articles
Blogs
Forums
Contact Us
About Us
Member Login
Access 2010 FAQ

 

Can you upload, activate, and instantiate your own custom ACCDT on the server with PowerShell?

 

Yes, this is certainly possible.

 

You'll first need appropriate permissions on your SharePoint server to create new sites. Talk to your SharePoint server administrator if you do not currently have sufficient rights to create new sites.

 

Open your SharePoint PowerShell command window by clicking:

 

Start -> Program Files -> Microsoft SharePoint 2010 Products -> Sharepoint 2010 Management Shell

 

If you want to do all of these steps from PowerShell, you essentially have to perform three steps:

1. Upload the custom ACCDT to the Solutions Gallery

2. Activate the custom solution

3. Instantiate the custom solution to create an Access Services site

 

The first and second steps each only take one line of PowerShell commands. For the third, you have to programmatically get the server name, locate the custom template, and then instantiate the template. There are lots of optional parameters you can provide, but I'll just give the example I use. Note that you can do this all in one batch command.

 

After the command window opens, enter the following command and then press enter.

(Substitute your server name, site name, ACCDT name, and other information in the appropriate places in the command.)

 

Add-SPUserSolution -LiteralPath "C:\Users\Jeff\Desktop\MyTemplate.accdt" -Site "http://YourServerName"

Install-SPUserSolution -ID "MyTemplate" -Site "http://YourServerName"

$site=Get-SPSite -ID "http://YourServerName"

$sol=$site.GetWebTemplates(1033)|where {$_.Title -eq "MyTemplate"}

$site.AllWebs.Add("TestSite","MyTitle","MyDescription",1033,$sol,$False,$False)

 

Here's an explanation of each line in detail.

 

This line uploads the ACCDT to the Solutions Gallery:

Add-SPUserSolution -LiteralPath "C:\Users\Jeff\Desktop\MyTemplate.accdt" -Site http://YourServerName

 

This line activates the solution:

Install-SPUserSolution -ID "MyTemplate" -Site http://YourServerName

 

This line gets the site:

$site=Get-SPSite -ID http://YourServerName

 

This line locates the specific custom template based on the title (this also assumes English templates with LCID 1033):

$sol=$site.GetWebTemplates(1033)|where {$_.Title -eq "MyTemplate"}

 

This line creates the site using the instantiation process with the given information (again, this assumes English site):

$site.AllWebs.Add("TestSite","MyTitle","MyDescription",1033,$sol,$False,$False)

 

After your site is ready, PowerShell returns control back to you in the command window. Your Access Services application is now ready for use.

 

See more tips and tricks like this in my book: Microsoft Access 2010 Inside Out

 

 

Back to FAQ main page