#Variables Definition
#######################################################
#Project Server Key
$ProjectServerKey
=
"Y2WC2-K7NFX-KWCVC-T4Q8P-4RG9W"
#Set the Project Server Key ("Y2WC2-K7NFX-KWCVC-T4Q8P-4RG9W" is a trail )
#Service Accounts variables
$PSWebAppPoolAccount
"MQassas\PSWebAppPool"
#A domain user that used to run the application pool of the web application that will host the PWA site collection.
$PSWebAppPoolPassWord
"P@ssw0rd"
# provide PSWebAppPool password
$PSSrvAppPoolAccount
"MQassas\PSSrvAppPool"
#A domain user that used to run the associated application pool of Project server service application.
$PSSrvAppPoolPassWord
# provide PSSrvAppPool password
#Project Server Application Service variables
$PWAAppServiceAppPool
"PWA_AppPool"
# Project Server Application Service application pool name.
$PWAAppServiceApp
"PWA_APP_SVC"
# Project Server Application Service
#Web Application variables
$WebApplicationName
"MQassas EPM 2016"
$WebApplicationAppPool
"EPMAppPoool"
$WebApplicationUrl
"http://mqassas"
$WebApplicationPort
"8080"
$WebAppURL
+
":"
$WebAppContentDataBaseName
"WSS_Content_8080"
# web application content database
$TopLevelSiteTitle
$TopLevelSiteOwnerAccount
"mqassas\spfarm"
$TopLevelSiteTemplate
"STS#0"
# the site template of root site collection, Note:
for
publishing site template set BLANKINTERNET#
0
#PWA Instance variables
$PWAURL
$WebAppUrl
"/sites/PWA"
$PWAOwnerAccount
# the owner of PWA site
$PWAContentDataBaseName
"PWA_Content_DB_8080"
#Database server
$DBServer
"MQassas\EPM"
#SQL Server Instance.
#1 - Register Managed Accounts. #2 - Enable Project Server 2016 License. #3 - Create Project Server Application Service Application Pool. #4 - Create a Project Server 2016 service application. #5 - Create a web Application. #6 - Create Top Level site Collection. #7 - Lock Down web application Content Database. #8 - Create a PWA Content Database. #9 - Lock Down PWA Content Database. #10 - Provision the PWA Site Collection. #11 - Enable PWA FeatureStart PWA Instance. #12 - Start PWA Instance. You might also like to read Install and Configure Project Server 2016 step by step
#Add service accounts to managed account
function Add
-
ManagedAccount()
{
param ([string]$ServiceAccount,[string]$AccountPassword)
Try
Write
Host
"Adding the service Account"
$ServiceAccount
"to Managed Account"
ForegroundColor Green
$srvacount
Get
SPManagedAccount | ? {$_.UserName
eq $ServiceAccount}
if
($srvacount
eq $null)
$
pass
convertto
securestring $AccountPassword
asplaintext
force
$cred
new
object management.automation.pscredential $ServiceAccount ,$
$res
New
SPManagedAccount
Credential $cred
($res
ne $null)
"The"
"has been added successfully to Managed Account"
ForegroundColor Cyan
}
else
"is already added to Managed Account"
ForegroundColor Yellow
Catch
Host $_.Exception.Message
ForegroundColor Red
#Register Managed Account.
#Add PSWebAppPoolAccount Account
Add
ManagedAccount
ServiceAccount $PSWebAppPoolAccount
AccountPassword $PSWebAppPoolPassWord
#Add PSSrvAppPool Account
ServiceAccount $PSSrvAppPoolAccount
AccountPassword $PSSrvAppPoolPassWord
#Enable ProjectServer License.
function Activate
PSLicense()
param ([string]$PSKey)
"Enable ProjectServer License"
Enable
ProjectServerLicense
Key $PSKey
"The Project Server License has been enabled successfully"
Activate
PSLicense
PSKey $ProjectServerKey
#Create Project Server Application Service Application Pool.
function Create
PWASvcAppPool()
param ([string]$PWASvcAppPool,[string]$PWASvcAppPoolAccount)
"Create Project Server Application Service Application Pool"
SPServiceApplicationPool
Name $PWASvcAppPool
Account $PWASvcAppPoolAccount
"Project Server Application Service Application Pool "
$PWASvcAppPool
" has been created successfully"
Create
PWASvcAppPool
PWASvcAppPool $PWAAppServiceAppPool
PWASvcAppPoolAccount $PSSrvAppPoolAccount
#Create Project Server Application Service.
PWASvc()
param ([string]$PWASvcName,[string]$PWASvcAppPool)
"Create Project Server Application Service"
SPProjectServiceApplication –Name $PWASvcName –ApplicationPool $PWASvcAppPool –Proxy
"Project Server Application Service "
$PWASvcName
PWASvc
PWASvcName $PWAAppServiceApp
#Create a Web Application.
WebApplication()
param ([string]$WebAppName,[int]$port,[string]$WebAppURL,[string]$WebAppContentDB,[string]$DBServer,[string]$WebAppPool,[string]$WebAppPoolAccount)
"Create A web Application"
SPWebApplication
Name $WebAppName
port $port
URL $WebAppURL
DatabaseName $WebAppContentDB
DatabaseServer $DBServer
AuthenticationMethod NTLM
ApplicationPool $WebAppPool
ApplicationPoolAccount $WebAppPoolAccount
"A new web application "
$WebAppName
WebApplication
WebAppName $WebApplicationName
port $WebApplicationPort
WebAppURL $WebApplicationUrl
WebAppContentDB $WebAppContentDataBaseName
DBServer $DBServer
WebAppPool $WebApplicationAppPool
WebAppPoolAccount $PSWebAppPoolAccount
#Create Top Level Site Collection
TopLevelSiteCollection()
param ([string]$webURL,[string]$siteOwner,[string]$siteName,[string]$siteTemplate)
"Create Top Level Site Collection"
SPSite $WebAppURL
OwnerAlias $siteOwner
Name $siteName
Template $siteTemplate
"Top Level Site Collection "
$siteName
START $WebAppURL
#Create Top Level site Collection.
TopLevelSiteCollection
webURL $WebURL
siteOwner $TopLevelSiteOwnerAccount
siteName $TopLevelSiteTitle
siteTemplate $TopLevelSiteTemplate
#Lock Down web application Content Database.
function LockDown
ContentDatabase()
param ([string]$ContentDataBaseName,[int]$MaxSiteCount,[int]$WarningSiteCount)
#Get-SPContentDatabase | ? {$_.Name -eq $ContentDataBaseName}
"Lock Down web application Content Database"
Set
SPContentDatabase
Identity $ContentDataBaseName
MaxSiteCount $MaxSiteCount
WarningSiteCount $WarningSiteCount
"The Content Database "
$ContentDataBaseName
" has been locked successfully"
LockDown
ContentDatabase
ContentDataBaseName $WebAppContentDataBaseName
MaxSiteCount
1
WarningSiteCount
#Create A new PWA Content Database.
param ([string]$PWAContentDataBaseName,[string]$DBServer,[string]$WebAppUrl)
"Create A new PWA Content Database"
SPContentDatabase $PWAContentDataBaseName
WebApplication $WebAppUrl
"The PWA Content Database "
PWAContentDataBaseName $PWAContentDataBaseName
WebAppUrl $WebAppURL
#Lock Down PWA Content Database.
"Lock Down Content Database"
ContentDataBaseName $PWAContentDataBaseName
#Provision PWA Instance.
function Provision
PWAInstance()
param ([string]$PWAContentDataBaseName,[string]$siteOwner,[string]$PWAURL)
"Provision PWA Instance"
SPSite
ContentDatabase $PWAContentDataBaseName
URL $PWAURL
Template pwa
#0 -OwnerAlias $siteOwner
"The PWA Instance "
Provision
PWAInstance
PWAURL $PWAURL
siteOwner $PWAOwnerAccount
#Enable PWA Feature.
function Enable
PWAFeature()
param ([string]$PWAURL)
"Enable PWA Feature"
SPFeature pwasite
"The PWA feature "
" has been enabled successfully"
PWAFeature
#Browse PWA Instance.
function Browse
PWA()
"Start"
START $PWAURL
Browse
PWA $PWAURL