Deploy menu script
$solutionDir="C:\avd.portal.Prototype.TFS_Lukas_Sevcik\dev\src"
$webAppUrl="https://td_sp_ui:1111"
$port=1111
$siteUrl="https://td_sp_ui:1111/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-ItemProperty C:\InstallFolder\* -name IsReadOnly -value $false
Remove-Item "c:\InstallFolder\*"
write-host "Deleting files from C:\InstallFolder...."
$scriptUrl= $solutionDir + "\Scripts"
set-location $scriptUrl
write-host "Collecting scripts and packages...."
try{
.\deploy.ps1 -collect -port $port
}
catch
{$_}
}
#go to the C:\InstallFolder folder with scripts and packages.
set-location "\"
#read-host
set-location "C:\InstallFolder"
$needInstall=$true
#check, if sitecollection exists. If exists, remove it
# 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"
}
$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)
{
try {
.\deploy -Install -WebAppUrl $webAppUrl -SiteUrl $siteUrl -Admin $Admin -SolutionDir $solutionDir -Port $port
#write-host "Packages were succesfully installed. Press any key to continue..."
}
catch
{
write-error $_
}
#.\extern
#read-host
}
#stay in C:\InstallFolder folder and run activating script
#------------------------------- . #.\deploy.ps1 -Activate -WebAppUrl $WebApp -SiteUrl $siteUrl -Admin $Admin
try {
.\deploy -Activate -WebAppUrl $webAppUrl -SiteUrl $siteUrl -Admin $Admin
}
catch
{
write-error $_
}
#.\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."
}