Download XML file (config file) used for this powershell script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | Param([Parameter(Mandatory=$True)] [string]$Environment ) $snapinName = "Microsoft.SharePoint.PowerShell" if ((Get-PSSnapin | Where-Object {$_.Name -eq $snapinName }) -eq $NULL) { write-host "SharePoint SnapIn not loaded. Loading..." Add-PSSnapin $snapinName -ErrorAction SilentlyContinue } ##################################################################### $Envpath=(Get-Location -PSProvider FileSystem).ProviderPath write-host "Envpath" $Envpath #Select the Environment to setup and deploy GRR Write-Host 'Select Current Environment' Write-Host 'DEV' Write-Host 'INT' Write-Host 'QA' Write-Host 'STAGE' Write-Host 'PROD' $Env= $Environment Write-Host 'Current environment selected' + $Env if($Env -eq 'DEV') { $EnvName='Dev' } elseif($Env -eq 'INT') { $EnvName='DevInt' } elseif($Env -eq 'QA') { $EnvName='QA' } elseif($Env -eq 'STAGE') { $EnvName='Stage' } elseif($Env -eq 'PROD') { $EnvName='Prod' } $Envpath=(Get-Location -PSProvider FileSystem).ProviderPath write-host "Envpath" $Envpath #get the WSP file path $solutionName = "Declaration_Email.wsp" $WSPFilepath = $Envpath + "\Declaration_Email.wsp" #get the Config.xml file from te deployment package $configpath = $Envpath + "\config.xml" [xml] $configXml = Get-Content $configpath -ErrorAction SilentlyContinue ##################################################################### #method to read cofig values from config.xml file -start ##################################################################### function Get-ConfigValue { Param( [string] $key ) Process { $xpath = "Configuration/$EnvName/param[@key='" + $key + "']" + "/text()" $configXml.SelectSingleNode($xpath).Value } } Write-Host "Applying changes to DEV config file" $SiteCollectionURL=Get-ConfigValue "SiteCollectionUrl" Write-Host "SiteCollection url:" $SiteCollectionURL Write-Host "Adding solution.." -foregroundcolor Yellow # LogInfoMessage "Adding solution in Dev started" Write-Host "Install solution.." -foregroundcolor Yellow $solution = Add-SPSolution $WSPFilepath #LogInfoMessage "Solution added" Write-Host "Solution added.." -foregroundcolor Yellow if ( $solution.ContainsWebApplicationResource ) { Write-Host -ForegroundColor Green "Deploying $solutionName to $url" Install-SPSolution -Identity $solutionName -Webapplication $SiteCollectionURL -FullTrustBinDeployment -GACDeployment -Force } else { Write-Host -ForegroundColor Green "Deploying $solutionName" Install-SPSolution -Identity $solutionName -GacDeployment -Force } $solution = Get-SPSolution $solutionName if ($solution.Deployed -eq $false ) { $counter = 1 $maximum = 50 $sleeptime = 2 while( ($solution.JobExists -eq $true ) -and ( $counter -lt $maximum ) ) { write-host -ForegroundColor yellow "Please wait..." sleep $sleeptime $counter++ } } Write-Host "" Write-Host -ForegroundColor Green "$solutionName is deployed" |
No comments:
Post a Comment