Skip to main content

Blogging about SharePoint

Go Search
Home
Blogging about SharePoint
Public Speaking
  

Michael Blumenthal's BlumenthalIT.NET > Blogging about SharePoint > Posts > Another PowerShell sample - Did my WSP deployment succeed?
Another PowerShell sample - Did my WSP deployment succeed?

$wspfile = "mysolution.wsp"

$sollist = stsadm -o enumsolutions

$xmldoc = [xml]$sollist

$xmlnode = [System.Xml.XmlNode]$xmldoc

#$xmlnode.SelectSingleNode("Solutions/Solution[File='$wspfile']")

$resultElement = $xmlnode.SelectSingleNode("Solutions/Solution[File='$wspfile']/LastOperationResult")

$result = $resultElement.get_InnerXml()

"Deployment Result: " + $result

if ("DeploymentSucceeded" -ne $result) {exit 1}

This script will extract the deployment result string from the XML returned by stsadm for the wsp of interest.  The last line is useful if you are using this in a build script.  If you are using this interactively, you probably want to change the then clause to something other than an exit statement.

Michael

Comments

Easier than this

[xml]$sols=stsadm -o enumsolutions;$sols.solutions.solution|?{$_.Deployed -eq "FALSE"}

You don't have to use DOM stuff with PS...it is way cooler

Kirk
http://kirkhofer.spaces.live.com/
at 5/30/2008 2:31 PM

Re: Kirk's one line solution

Won't that show all solutions that did not deploy correctly, not just the one you just tried to deploy? 
I don't know my PS syntax well enough yet to know the right way to do this without testing it on the command line, but my guess would be
[xml]$sols=stsadm -o enumsolutions;$sols.solutions.solution|?{$_.File-eq "mysolution.wsp"} |?{$_.Deployed -eq "FALSE"}
Michael Blumenthal at 6/2/2008 6:34 AM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


Please put your name at the end of your comment as the Name field doesn't display in the main view of the comments.

Name: *


Your name.  If you first name is Michael, please provide initials or the like to clearly distinguish your name from Michael Blumenthal's.
Also, this field does not appear in the main view of the comments.

Need Paid Consulting Services?

Are you interested in engaging a SharePoint consultant for fee-based consulting services?  If so, I can have an Account Executive from my employer contact you.  Other site visitors will not see this column.

Additional Contact Information

Please provide additional contact information if you need a direct response.  Other site visitors will not see this column.

What is tomorrow's date? *

This is a weak CAPTCHA based on advice from a tweet from @ToddKlindt.
Attachments