Tue. May 17th, 2022


Copyright © 2015, September. Michael Pomfret

Creates the Visio Graphics Service

#This service allows users to share and view Visio web drawings using Visio Services.

#Read more: http://technet.microsoft.com/en-us/library/ee524059.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



$strInstallationFilesPath = (Split-Path ($PSCommandPath))

$ServiceApplicationName = “Visio Graphics Service”

$ServiceName = “Visio Graphics Service”

$spAppPoolName = “Visio Graphics Service Application Pool”

$spAppPoolAcc = $VisioAppPoolAcc

$CustomFilePath= $strInstallationFilesPath + “\Visio Graphics Service\”

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

#Get default SQL server

$DefaultDatabaseServer = (Get-SPDatabase | ? { $_.Type -eq “Configuration Database” }).NormalizedDataSource

#Get SQL server instance for the User Profile Application, Social,

$DatabaseServer = $VisioServerInstance

Write-Host “”

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

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

Write-Host “To SharePoint Servers” $MachinesToActivate

Write-Host “Application Pool Name -” $spAppPoolName

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

Write-Host “Database Server Instance” $DatabaseServer

Write-Host “Configuration DB” $ConfigDB

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

Write-Host “”

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

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 ” – 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


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

#Create Service Application Proxy

Write-Host ” – Creating ‘$ServiceApplicationName’ proxy”

New-SPVisioServiceApplicationProxy -Name “$ServiceApplicationName Proxy” -ServiceApplication $ServiceApplicationName | Out-Null

Add-Module($CustomFilePath + “Manage the Visio Graphics Service – Global Settings.ps1”)

#Start service instances

Write-Host ” – 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 ” – Starting” $service.ID “on $machine”

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



Write-Host ” – 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 ” – 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 ” – Removing ‘$ServiceApplicationName proxy’…”

Remove-SPServiceApplicationProxy $ExistingServiceAppProxy -Confirm:$false


write-host ” – 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.