#Check and add SharePoint PowerShell snap-in
if(-not(
Get-PSSnapin | Where { $_.Name -eq "Microsoft.SharePoint.PowerShell"})
) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
# Function to check if the timer job is complete
function WaitForJobToFinish()
{
$JobName = "*solution-deployment*$solutionName*"
$job = Get-SPTimerJob | ?{ $_.Name -like $JobName }
if ($job -eq $null)
{
Write-Output 'Timer job not found'
}
else
{
$JobFullName = $job.Name
Write-Output "Waiting to finish job $JobFullName"
while ((Get-SPTimerJob $JobFullName) -ne $null)
{
Write-Output .
Start-Sleep -Seconds 2
}
Write-Output "Finished waiting for job.."
}
}
$Url="http://sp2013:5959/"
$solutionPath="C:\Users\spadmin\Desktop\"
$solution="Test.wsp"
$path= $solutionPath + $solution
Add-SPSolution -LiteralPath $path
install-spsolution -Identity $solution -GACDeployment -Force
WaitForJobToFinish
Enable-spfeature -identity "Test_Job" -confirm:$false -url $Url
if(-not(
Get-PSSnapin | Where { $_.Name -eq "Microsoft.SharePoint.PowerShell"})
) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
# Function to check if the timer job is complete
function WaitForJobToFinish()
{
$JobName = "*solution-deployment*$solutionName*"
$job = Get-SPTimerJob | ?{ $_.Name -like $JobName }
if ($job -eq $null)
{
Write-Output 'Timer job not found'
}
else
{
$JobFullName = $job.Name
Write-Output "Waiting to finish job $JobFullName"
while ((Get-SPTimerJob $JobFullName) -ne $null)
{
Write-Output .
Start-Sleep -Seconds 2
}
Write-Output "Finished waiting for job.."
}
}
$Url="http://sp2013:5959/"
$solutionPath="C:\Users\spadmin\Desktop\"
$solution="Test.wsp"
$path= $solutionPath + $solution
Add-SPSolution -LiteralPath $path
install-spsolution -Identity $solution -GACDeployment -Force
WaitForJobToFinish
Enable-spfeature -identity "Test_Job" -confirm:$false -url $Url
No comments:
Post a Comment