I am not sure if this is supported so looking for some help.
workflow movesites
{
Param
(
[Parameter (Mandatory=$true)] $sites,
[Parameter (Mandatory=$true)] $movedToContentDb
)
InlineScript
{
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
foreach -parallel ($site in $sites)
{
$exists = (Get-SPWeb $site.url) -eq $null
if($exists)
{
Write-host "Site doesn't exists"
}
else
{
Write-host "Moving site $($site.Url) to $contentDbName"
Get-SPSite $site.url | Move-SPSite -DestinationDatabase $movedToContentDb -Confirm:$false
}
}
}
Basically, I am trying to invoke few SharePoint cmdlets in Parallel using Powershell Workflows but it seems Powershell Add-in doesn't get loaded at all and function throws error that Get-SPWeb is not recognized which is part of SharePoint powershell snap in.
Another challenge is foreach -parallel cannot be added into inlinescript as its not allowed.