2

I have created a PowerShell script for downloading .XOML file for SharePoint Designer 2010 Workflows. (Below is the snippet for downloading .XOML file)

Can I use PowerShell to import .XOML file for SharePoint Designer 2010 Workflows?

 Add-PSSnapin "Microsoft.SharePoint.PowerShell"
 try {
 Function GetXOMLFromWorkflowInstance($wfa)
 {
[xml]$xmldocument =  $wfa.SoapXml
$name = $xmldocument.FirstChild.GetAttribute("Name")
$wfName = $name.Replace(" ", "%20")
$webRelativeFolder = "Workflows/" + $wfName
$xomlFileName = $wfName + ".xoml"
$wfFolder = $wfa.ParentWeb.GetFolder($webRelativeFolder)
$xomlFile = $wfFolder.Files[$xomlFileName]
if ($xomlFile.Exists)
{
    $xomlStream = $xomlFile.OpenBinaryStream()
    $xmldocument.Load($xomlStream)
    $xomlStream.Close()

    $filepath = '<filepath>'
    $gotxoml = $xmldocument.OuterXml
    $gotxoml | Out-File $filepath -Append
}
return $xomlFileName
}
Function LoadAllWFXoml ($webUrl, $listName)
{
$site = Get-SPSite($webUrl)
$web = $site.OpenWeb()    
$wfaColl = $web.Lists[$listName].WorkflowAssociations
Foreach ($i in $wfaColl)
{
    $xml = GetXOMLFromWorkflowInstance $i
    Write-Host $xml
    Write-Host "=============================="
}
}
LoadAllWFXoml "<siteurl>" "<listname>"
}
catch {
"Exception occurred."
}

Your Answer

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

Browse other questions tagged or ask your own question.