Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 50 additions & 50 deletions Workflows/Get workflow report for all site collections/Workflows.ps1
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
function Get-Workflows{
param (
[Parameter(Mandatory=$true,Position=1)]
[string]$Username,
[Parameter(Mandatory=$true,Position=2)]
$AdminPassword,
[Parameter(Mandatory=$true,Position=3)]
[string]$Url,
[Parameter(Mandatory=$true,Position=3)]
[string]$CSVPath
)
#$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force
$ctx=New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword)
$ctx.ExecuteQuery()
function Get-Workflows {
param (
[Parameter(Mandatory = $true, Position = 1)]
[string]$Username,
[Parameter(Mandatory = $true, Position = 2)]
$AdminPassword,
[Parameter(Mandatory = $true, Position = 3)]
[string]$Url,
[Parameter(Mandatory = $true, Position = 3)]
[string]$CSVPath
)
#$password = ConvertTo-SecureString -string $AdminPassword -AsPlainText -Force
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($Url)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username, $AdminPassword)
$ctx.ExecuteQuery()

$Lists=$ctx.Web.Lists
$ctx.Load($ctx.Web)
$ctx.Load($ctx.Web.Webs)
$ctx.Load($Lists)
$ctx.ExecuteQuery()
$Lists = $ctx.Web.Lists
$ctx.Load($ctx.Web)
$ctx.Load($ctx.Web.Webs)
$ctx.Load($Lists)
$ctx.ExecuteQuery()

foreach ( $ll in $Lists){
$workflo = $ll.WorkflowAssociations;
$ctx.Load($workflo);
foreach ( $ll in $Lists) {
$workflo = $ll.WorkflowAssociations;
$ctx.Load($workflo);

try{
$ctx.ExecuteQuery();
Write-host $ll.Title $workflo.Count -ForegroundColor Green
}
catch [Net.WebException] {
Write-Host "Failed for " $ll.Title -ForegroundColor Red
}
try {
$ctx.ExecuteQuery();
Write-host $ll.Title $workflo.Count -ForegroundColor Green
}
catch [Net.WebException] {
Write-Host "Failed for " $ll.Title -ForegroundColor Red
}

foreach ($workfloek in $workflo){
$workfloek | Add-Member NoteProperty "SiteUrl"($ctx.Web.Url)
$workfloek | Add-Member NoteProperty "ListTitle"($ll.Title)
Write-Output $workfloek
foreach ($workfloek in $workflo) {
$workfloek | Add-Member NoteProperty "SiteUrl"($ctx.Web.Url)
$workfloek | Add-Member NoteProperty "ListTitle"($ll.Title)
Write-Output $workfloek

$workfloek | export-csv $CSVPath -Append
}
}
$workfloek | export-csv $CSVPath -Append
}
}

if($ctx.Web.Webs.Count -gt 0){
Write-Host "--"-ForegroundColor DarkGreen
if ($ctx.Web.Webs.Count -gt 0) {
Write-Host "--"-ForegroundColor DarkGreen

for($i=0;$i -lt $ctx.Web.Webs.Count ;$i++){
Get-Workflows -Username $Username -AdminPassword $AdminPassword -Url $ctx.Web.Webs[$i].Url -CSVPath $CSVPath
}
}
for ($i = 0; $i -lt $ctx.Web.Webs.Count ; $i++) {
Get-Workflows -Username $Username -AdminPassword $AdminPassword -Url $ctx.Web.Webs[$i].Url -CSVPath $CSVPath
}
}
}


Expand All @@ -58,13 +58,13 @@ Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extens
Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

# Insert the credentials and the name of the admin site
$Username="user@tenant.onmicrosoft.com"
$AdminPassword=Read-Host -Prompt "Password" -AsSecureString
$AdminUrl="https://tenant-admin.sharepoint.com"
$CSVPath="C:\Users\ivo\Desktop\SomePath.csv"
$Username = "user@tenant.onmicrosoft.com"
$AdminPassword = Read-Host -Prompt "Password" -AsSecureString
$AdminUrl = "https://tenant-admin.sharepoint.com"
$CSVPath = "C:\Users\ivo\Desktop\SomePath.csv"

Connect-SPOService -Url $AdminUrl
$sites=get-spoSite
foreach ($site in $sites){
Get-Workflows -Username $Username -AdminPassword $AdminPassword -Url $site.Url -CSVPath $CSVPath
$sites = get-spoSite
foreach ($site in $sites) {
Get-Workflows -Username $Username -AdminPassword $AdminPassword -Url $site.Url -CSVPath $CSVPath
}