Implement automatic deployment through Windows task.
Add-pssnapin Microsoft.sharepoint.powershell$today = Get-date$targetdir = $today. ToString ("YyyyMMdd") $executeDir = "folder path" $executeDir + = $targetDir + "\" $webURL = "http://server" $subject = "Automa Tic Deployment finished. " $tos = "[email protected]" $body = "Solutions Deploy successfully.<br/>" $ERRORMSG = "" $sendingEmail = $trueif ( (Test-path $executeDir)-eq $true) {$ps 1s = get-childitem-path ($executeDir + "*.ps1") if ($ps 1s. Count-gt 0) {foreach ($ps 1 in $ps 1s) {invoke-expression ($executeDir + $ps 1). Name)} $deployingWSPs = Get-spsolution | Where-object {$_. Jobexists-eq $true} while ($deployingWSPs-ne $null-and $deployingWSPs. count-gt 0) {Start-slee P-seconds $deployingWSPs = Get-spsolution | Where-object {$_. Jobexists-eq $true}} $deployingWSPs = Get-spsolution | Where-object {$_. Deployed-eq $true-and ($_. Lastoperationendtime-$today). Days-eq 0-and $_. Lastoperationresult.tostring ()-like "*failed*"} if ($deployingWSPs-ne $null-and $deployingWSPs. count-gt 0) {$ERRORMSG + = "Exception occur during deployment, please check in ca.<br/>"} I F ($error. Count-gt 0) {$errorMsg + = "Exception occure during parse command.<br/>" $ERRORMSG + = $error [$ Error. COUNT-1]. Exception.Message} if ($sendingEmail-eq $true) {$web = Get-spweb $webURL if ($ Errormsg.length-gt 0) {$body = $ERRORMSG} [Microsoft.SharePoint.Utilities.SPUtility ]::sendemail ($web, $true, $false, $tos, $subject, $body) $web. Dispose ()}}}exit
[SharePoint 2013] Automatic deployment Script