Deployment settings script
$solutionDir="C:\avd.BuyingPortal.Prototype.TFS_Lukas_Sevcik\dev\src\Scripts"
$webAppUrl="https://td_sp_ui"
$port=80
$siteUrl="https://td_sp_ui/sites/test"
$Admin="avd-corp\l.sevcik"
write-host "********** Current deployment parameters ************"
write-host ""
write-host Solution Directory : $solutionDir
write-host Web Application Port : $port
write-host Web Application Url : $webAppUrl
write-host Site collection Url : $siteUrl
write-host Site collection Administrator : $Admin
write-host ""
$input=read-host "Do you want to change parameters? Y/N"
write-host ""
if($input -eq "y")
{
do
{
write-host ""
write-host "********** Changed parameters ***********"
write-host ""
$solutionDir=read-host "Enter your solution directory path "
#checking if path exists
do {
$solutionDir=read-host "Path "$solutionDir " doesn't exist. Try again or press 'Q' to quit."
}
while ((!(Test-Path $solutionDir)) -and ($solutionDir -ne "q") )
if($solutionDir -eq "q")
{
write-host "You decided to quit. Bye bye."
exit
}
#write-host Solution Directory : $solutionDir
$port=read-host "Enter port number of web application "
#write-host Web Application Port : $port
$webAppUrl=read-host "Enter url of your web application "
#write-host Web Application Url : $webAppUrl
$siteUrl=read-host "Enter site url of site collection "
#write-host Site collection Url : $siteUrl
$Admin=read-host "Enter your admin account "
#write-host Site collection Administrator : $Admin
write-host ""
$input=read-host "Do you want to use this setting? Y/N. Use 'Q' to quit this menu"
write-host ""
}
while($input -eq "n" -and $input -ne "q")
}
if($input -eq "q")
{
write-host "Script stopped."
}
else
{
if($input -eq "y")
{
write-host "Running script with changed parameters...."
}
else
{
write-host "Running script with original parameters...."
}
#Continuing with running script together...
# check to ensure Microsoft.SharePoint.PowerShell is loaded
$snapin=Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
if ($snapin -eq $null)
{
Write-Host "Loading SharePoint Powershell Snapin"
Add-PSSnapin "Microsoft.SharePoint.Powershell"
}
#go to TFS folder with script - solution Directory
set-location "\"
$answer=read-host "Do you want me to re-collect scripts and .wsp files? Y/N"
if($answer -eq "y")
{
set-location $solutionDir
write-host "Collecting scripts and packages...."
#.\deploy.ps1 -collect -port $port
}
#go to the C:\GBP.Install folder with scripts and packages.
set-location "\"
set-location "C:\GBP.Install"
#check, if sitecollection exists. If exists, remove it
$needInstall=$true
$sc=get-spsite|where-object {$_.Url -eq $siteUrl}
if($sc -ne $null)
{
write-host ""
write-host "Site collection already exists on " $siteUrl
write-host "****** Select the choice *******"
write-host "Press 1 to remove ONLY site collection"
write-host "Press 2 to remove site collection and ALL installed solutions."
$choice=read-host
switch($choice)
{
1
{
Write-Host ''
$needInstall=$false
Write-Host 'Deleting SiteCollection', $siteUrl, '...'
Remove-SPSite –Identity $SiteUrl –GradualDelete -Confirm:$false
Write-Host ''
Write-Host 'SiteCollection deleted successfully. Press any key to continue...'
read-host;
break
}
2
{
$needInstall=$true
#--------------------------- . #.\deploy.ps1 -Remove $WebApp -SiteUrl $siteUrl
#.\extern
#.\deploy -Remove -SiteUrl $siteUrl
read-host
}
}
}
#----------------------. #.\deploy.ps1 -Install -WebAppUrl $WebApp -SiteUrl $siteUrl -SolutionDir $solutionDir -port $port -Admin $Admin
if($needInstall)
{
#.\deploy -Install -WebAppUrl $webAppUrl -SiteUrl $siteUrl -Admin $Admin -SolutionDir $solutionDir -Port $port
#.\extern
write-host "Packages were succesfully installed. Press any key to continue..."
read-host
}
#stay in C:\GBP.Install folder and run activating script
#------------------------------- . #.\deploy.ps1 -Activate -WebAppUrl $WebApp -SiteUrl $siteUrl -Admin $Admin
.\deploy -Activate -WebAppUrl $webAppUrl -SiteUrl $siteUrl -Admin $Admin
#.\extern
write-host "Solutions were succesfuly activated. Press any key to continue..."
read-host
#Add users to new site collection
#---------------------------- . #.\deploy.ps1 -AddUsers -WebAppUrl $WebApp -SiteUrl $siteUrl
.\deploy -AddUsers -WebAppUrl $webAppUrl -SiteUrl $siteUrl
#.\extern
write-host "Users were succesfuly added to site collection."
write-host "Deployment script finished."
}