Tue. Jun 7th, 2022


Copyright © 2015, September. Michael Pomfret

Create the Access Services

Allows users to publish a Microsoft Access 2013 Web database to a SharePoint site.

Read more: http://technet.microsoft.com/en-us/library/ee748653.aspx


#Allows to use SharePoint cmdlets from inside the Windows PowerShell command window

If ((Get-PsSnapin |?{$_.Name -eq “Microsoft.SharePoint.PowerShell”})-eq $null)


Add-PsSnapin Microsoft.SharePoint.PowerShell | Out-Null



Get SharePoint variables



function Add-Module($strFileName){

Write-Host “Attempting to run ” $strFileName

If (Test-Path $strFileName){



Write-Host “Cannot locate” $strFileName



$ServiceApplicationName = “Access Services”

$ServiceName = “Access Services”

$spAppPoolName = “Access Services Application Pool”

$spAppPoolAcc = $AccessAppPoolAcc

$MachinesToActivate = $AccessMachinesToActivate.Split(“,”).trim()

Write-Host “”

Write-Host “========================================================”

Write-Host “SharePoint 2013 – Module ‘$ServiceName’…”

Write-Host “To SharePoint Servers” $MachinesToActivate

Write-Host “Application Pool Name -” $spAppPoolName

Write-Host “Application Pool Account – -” $spAppPoolAcc

Write-Host “========================================================”

Write-Host “”

Start-SPAssignment -Global | Out-Null



#Check for existing service application and proxy

$ExistingServiceApp = Get-SPServiceApplication | where-object {$_.Name -eq $ServiceApplicationName}

if ($ExistingServiceApp -eq $null)


Write-Host $strTest “- Creating ‘$ServiceApplicationName'”

#Check if managed account already exist, if not exit

$spManagedAccount = Get-SPManagedAccount -Identity $spAppPoolAcc -ErrorAction SilentlyContinue

if ($spManagedAccount -eq $null)


Write-Host -f Red $strTest “- ” $ServiceName ” Managed Account – Unable to retrieve managed account” $spAppPoolAcc

exit -1


#Check if application pool already exist, if not create it

$ApplicationPool = Get-SPServiceApplicationPool -Identity $spAppPoolName -ErrorAction SilentlyContinue

if ($ApplicationPool -eq $null)


New-SPServiceApplicationPool -Name $spAppPoolName -Account $spManagedAccount | Out-Null




Set-SPServiceApplicationPool $ApplicationPool -Account $spManagedAccount | Out-Null


#Note: Proxy is automatically created

New-SPAccessServicesApplication -Name $ServiceApplicationName -ApplicationPool $spAppPoolName | Out-Null

#Start service instances

Write-Host $strTest “- Starting service instance”

foreach ($machine in $MachinesToActivate)


#Gets the service to determine its status

$service = $(Get-SPServiceInstance | where {$_.TypeName -match $ServiceName} | where {$_.Server -match “SPServer Name=”+$machine})

If ($service.Status -eq “Disabled”)


Write-Host $strTest “- Starting” $service.ID “on $machine”

Start-SPServiceInstance -Identity $service.ID | Out-Null



Write-Host $strTest “- Done creating ‘$ServiceApplicationName’.`n”


Write-Host -f Red $strTest” – ServiceApplication ‘$ServiceApplicationName’ already exists.”

#Remove Application?

$RemoveApplication=read-host ‘Do you wish to remove Application? (Y/N)’

if ($RemoveApplication-eq”Y”)


write-host $strTest “- Removing ‘$ServiceApplicationName’…”

Remove-SPServiceApplication $ExistingServiceApp -removedata -Confirm:$false

#Proxy is NOT automatically deleted

$ExistingServiceAppProxy = Get-SPServiceApplicationProxy | where-object {$_.Name -eq “$ServiceApplicationName Proxy”}

if ($ExistingServiceAppProxy -ne $null)


write-host $strTest “- Removing ‘$ServiceApplicationName proxy’…”

Remove-SPServiceApplicationProxy $ExistingServiceAppProxy -Confirm:$false


write-host $strTest “- Stopping service instance…”

Get-SPServiceInstance | where-object {$_.TypeName -eq $ServiceName} | Stop-SPServiceInstance -Confirm:$false | Out-Null




catch { write-Output $_ }

Stop-SPAssignment -Global | Out-Null

This website uses cookies. By continuing to use this site, you accept our use of cookies.