none
Find Sharepoint 2010 and 2013 workflows with in the site collections RRS feed

  • Question

  • I am having some difficulty trying to use this code below.
    I keep getting a PowerShell Error message saying Get-Site
    Get-SPSite: The term 'Get-SPSite' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
    if a path was included, verify that the path is correct and try again.

    I have tried the code from my desktop and the server, using PowerShell ISE(Where do i run the Code at?) .
    and the code returns an empty CSV when I know there are three OOB SP Workflows in the site.

    Any assistance would be great as to how to get this code to work properly. As I need to Find all SPS 2013 and SPS 2010 workflows.

    Code:

    if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)  
    {  
      
        Add-PSSnapin "Microsoft.SharePoint.PowerShell"  
    }  
      
    $results = @()  
    $siteColl =  "<your site collection here>"  
       
    $site = Get-SPSite -Identity $siteColl -Limit All  
    try  
    {   
        foreach ($myWeb in $site.AllWebs)  
        {  
            Write-Host "Looking in Web: " $myWeb.Url -ForegroundColor Red  
            foreach($list in $myWeb.Lists)  
            {  
                
                {  
                    Write-Host $list.Title -ForegroundColor Blue  
                    foreach ($wflowAssociation in $list.WorkflowAssociations)  
                    {  
                        $RowDetails =  @{            
                          "List Name"         = $wflowAssociation.ParentList.Title  
                          "Workflow Name"     = $wflowAssociation.InternalName  
                          "Running Instances" = $wflowAssociation.RunningInstances  
                          "Created On"        = $wflowAssociation.Created  
                          "Modified On"       = $wflowAssociation.Modified  
                          "Parent Web"        = $wflowAssociation.ParentWeb  
                          "Task List"         = $wflowAssociation.TaskListTitle  
                          "History List"      = $wflowAssociation.HistoryListTitle                   
                        }  
      
                        $results += New-Object PSObject -Property $RowDetails  
                    }            
                }  
      
            }  
        }  
      
        $myFileName = [Environment]::GetFolderPath("Desktop") + "\workflowList.csv"  
        $results | Select-Object "List Name", "Workflow Name", "Running Instances", "Created On","Modified On","Parent Web", "Task List","History List"    | export-csv -Path $myFileName -NoTypeInformation  
      
    }  
      
    catch   
    {   
        $e = $_.Exception   
        $line = $_.InvocationInfo.ScriptLineNumber   
        $msg = $e.Message   
        Write-Host –ForegroundColor Red "Caught Exception: $e at $line"   
        Write-Host $msg   
        Write-Host "Something went wrong"  
    }   
      
    Write-Host " === === === === === Completed! === === === === === === == "  


    • Edited by cowboy2066 Tuesday, September 29, 2020 10:05 PM
    Tuesday, September 29, 2020 10:00 PM

All replies