5

I have published a solution and deployed it.

 Add-SPSolution “C:\Users\Admin\Documents\LeaveManagementPortal.wsp"

 Install-SPSolution –identity "LeaveManagementPortal.wsp" -GACDeployment

This deployed the wsp file and there was a list in it as a feature.

when I try to rollback, the lines below work fine when i execute them one after the other.

stsadm -o retractsolution -name leavemanagementportal.wsp -immediate
stsadm -o execadmsvcjobs
stsadm -o deletesolution -name leavemanagementportal.wsp

But when I save this as a ps1 file and run it, it throws error

"the solution cannot be removed when a job is scheduled or running"

The first two line run successfully though. Is the third line trying to execute before the timer job is getting completed? how can i solve this?

5
stsadm -o retractsolution -name leavemanagementportal.wsp -immediate  
stsadm -o execadmsvcjobs  
stsadm -o deletesolution -name leavemanagementportal.wsp

The above mentioned code is a stsadm command line tool and you can try it as a .bat save file instead of .ps1 file. Also you need to write the code for stop and start [ restart ] the SP Admin Services and SP Timer Services and you must provide few seconds as an interval[tell the function to sleep for 5 or 8 seconds until the timer services restarted] to restart the services.

For the purpose of rollback and other operations related to WSP files, its better you to take the ISE PowerShell approach and save this as a .ps1 file and deploy. This has a waitfortimer function and sleep to perform rollback/deploy WSP

Refer this link and this

4

I always use the below PowerShell script to Uninstall and delete SpSolutions:

add-pssnapin "microsoft.sharepoint.powershell"
Set-ExecutionPolicy unrestricted
echo " "
echo "Uninstalling YourSolutionName"
$sln = get-spsolution -identity YourSolutionName.wsp 
uninstall-spsolution -identity YourSolutionName.wsp -confirm:$false
echo "Started solution retraction..." 
while($sln.JobExists) { 
echo " > Uninstall in progress..."
start-sleep -s 10 
}
remove-spsolution -identity YourSolutionName.wsp -confirm:$false
echo "Removed YourSolutionName"
echo "  "

Run this PS1 and you are set.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.