diff --git a/OneDrive for Business/Enable versioning for all lists in OneDrive sites/Capture204.PNG b/OneDrive for Business/Enable versioning for all lists in OneDrive sites/Capture204.PNG new file mode 100644 index 00000000..3b613cd6 Binary files /dev/null and b/OneDrive for Business/Enable versioning for all lists in OneDrive sites/Capture204.PNG differ diff --git a/OneDrive for Business/Enable versioning for all lists in OneDrive sites/Enable versioning in ODB lists.ps1 b/OneDrive for Business/Enable versioning for all lists in OneDrive sites/Enable versioning in ODB lists.ps1 new file mode 100644 index 00000000..eb9532c5 --- /dev/null +++ b/OneDrive for Business/Enable versioning for all lists in OneDrive sites/Enable versioning in ODB lists.ps1 @@ -0,0 +1,93 @@ +function Set-SPOListVersioning($EnableVersioning, $Urelek) +{ + $ctx=New-Object Microsoft.SharePoint.Client.ClientContext($urelek) + $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $Adminpassword) + $ctx.Load($ctx.Web.Lists) + $ctx.Load($ctx.Web) + $ctx.Load($ctx.Web.Webs) + $ctx.ExecuteQuery() + Write-Host + Write-Host $ctx.Url -BackgroundColor White -ForegroundColor DarkGreen + foreach( $ll in $ctx.Web.Lists) + { + $ll.EnableVersioning = $EnableVersioning + $ll.Update() + $csvvalue= new-object PSObject + $listurl=$null + if($ctx.Url.EndsWith("/")) {$listurl= $ctx.Url+$ll.Title} + else {$listurl=$ctx.Url+"/"+$ll.Title} + $csvvalue | Add-Member -MemberType NoteProperty -Name "Url" -Value ($listurl) + $csvvalue | Add-Member -MemberType NoteProperty -Name "Status" -Value "Failed" + try + { + $ErrorActionPreference="Stop" + $ctx.ExecuteQuery() + Write-Host $listurl -ForegroundColor DarkGreen + $csvvalue.Status="Success" + $Global:csv+= $csvvalue + } + + catch + { + $Global:csv+= $csvvalue + Write-Host $listurl -ForegroundColor Red + } + finally + {$ErrorActionPreference="Continue"} + + + } + + if($ctx.Web.Webs.Count -gt 0) + { + for($i=0; $i -lt $ctx.Web.Webs.Count ; $i++) + { + Set-SPOListVersioning -EnableVersioning $EnableVersioning -Urelek ($ctx.Web.Webs[$i].Url) + } + + } + + + +} + + + + + + + # Paths to SDK. Please verify location on your computer. +Add-Type -Path "c:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.Client\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.dll" +Add-Type -Path "c:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.Client.Runtime\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.Runtime.dll" + +# Insert the credentials and the name of the admin site +$Username="t@trial765.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +Connect-SPOService https://trial765-admin.sharepoint.com -Credential $Username +$myhost="https://trial765-my.sharepoint.com" + +# If you do not want to target all users, enter the target user names in the line below instead of Get-SPOUser cmdlet: +$users=get-SPOUser -Site $myhost +$EnableVersioning=$true +$Global:csv=@() + +foreach($user in $users) +{ + + + if($user.LoginName.Contains('@')) + { + $persweb=$user.LoginName.Replace(".","_").Replace("@","_") + $persweb=$myhost+"/personal/"+$persweb + Write-Host $persweb + + $AdminUrl=$persweb + + #Add the following line if you want to assign yourself, administrator or another user access to other users' personal sites + #Set-SPOUser -Site $AdminUrl -IsSiteCollectionAdmin $true -LoginName t@trial765.onmicrosoft.com + Set-SPOListVersioning -EnableVersioning $EnableVersioning -Urelek $AdminUrl + } +} + +# Specify the path where the log file will be published +$Global:csv | Export-Csv -Path C:\Users\Public\Versioning.csv \ No newline at end of file diff --git a/OneDrive for Business/Enable versioning for all lists in OneDrive sites/description.md b/OneDrive for Business/Enable versioning for all lists in OneDrive sites/description.md new file mode 100644 index 00000000..59cc0a80 --- /dev/null +++ b/OneDrive for Business/Enable versioning for all lists in OneDrive sites/description.md @@ -0,0 +1,26 @@ +Powershell script that enables versioning for all the libraries and lists in all personal sites (OneDrive for Business). + +It requires SharePoint Online Management Shell and SharePoint SDK installed: + +http://technet.microsoft.com/en-us/library/fp161372(v=office.15).aspx + +http://www.microsoft.com/en-us/download/details.aspx?id=30722 + + + +It uses recurrence to find all sites in all site collections and then goes through all the lists. + +For some lists, enabling version may not be possible and you will receive a notification of that. + +At the end, a csv file is generated with the lists' urls and the status whether enabling was successful or not. + + + +As the script runs you will see green lists' titles for which the enabling succeeded and red for those which failed (not all lists support versioning). + + + + +You can customize the script by using the commented out tips. + + diff --git a/Remove SPO subsite/Remove SPO subsite.ps1 b/Remove SPO subsite/Remove SPO subsite.ps1 deleted file mode 100644 index 6854e7d0..00000000 --- a/Remove SPO subsite/Remove SPO subsite.ps1 +++ /dev/null @@ -1,65 +0,0 @@ -function GetAllSubsitesAndDelete($urelek) -{ - $ctx2 = New-Object Microsoft.SharePoint.Client.ClientContext($urelek) -$ctx2.Credentials= New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) -$rootWeb2 = $ctx2.Web -$sites2 = $rootWeb2.Webs - -$ctx2.Load($rootWeb2) -$ctx2.Load($sites2) -$ctx2.ExecuteQuery() -if($sites2.Count -gt 0) - { - for($i=0;$i -lt $sites2.Count ;$i++) - { - GetAllSubsitesAndDelete($sites2[$i].Url) - } - try - { - $rootWeb2.DeleteObject() - $ctx2.ExecuteQuery() - Write-Host "Subsite " $rootWeb2.Url " has been removed" - } - catch [Net.WebException] - { - Write-Host $_.Exception.ToString() - } - } - else - { - try - { - $rootWeb2.DeleteObject() - $ctx2.ExecuteQuery() - Write-Host "Subsite " $rootWeb2.Url " has been removed" - } - catch [Net.WebException] - { - Write-Host $_.Exception.ToString() - } - } - - - -} - -#paths to SDK (copied from Victor's comment) -$programFiles = [environment]::getfolderpath("programfiles") -add-type -Path $programFiles'\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll' -add-type -Path $programFiles'\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll' - -# The following script will remove not only the subsite but all its content and sub-subsites -$siteUrl = Read-Host -Prompt "Enter the subsite url,e.g.`r`nhttps://tenant.sharepoint.com/sites/mysitecollection/subsite/subsubsite`r`n” -$username = Read-Host -Prompt "Enter admin@tenant.onmicrosoft.com" -$password = Read-Host -Prompt "Enter password" -AsSecureString -$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl) -$ctx.Credentials= New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) -$rootWeb = $ctx.Web -$sites = $rootWeb.Webs - -$ctx.Load($rootWeb) -$ctx.Load($sites) -$ctx.ExecuteQuery() -GetAllSubsitesAndDelete($rootWeb.Url) - - diff --git a/Remove SPO subsite/description.md b/Remove SPO subsite/description.md deleted file mode 100644 index f99d69d7..00000000 --- a/Remove SPO subsite/description.md +++ /dev/null @@ -1,15 +0,0 @@ -It requires SharePoint Online Management Shell and SharePoint SDK installed: - -http://technet.microsoft.com/en-us/library/fp161372(v=office.15).aspx - -http://www.microsoft.com/en-us/download/details.aspx?id=30722 - - - -The script removes a single subsite from a site collection. - -A prerequisite for removing a subsite is to remove all its subsites (sub-subsites), so before it deletes the actual subsite, it checks for all sub-subsites in a recurring function and deletes them all. It works on different levels so you can also delete sub-sub-sub-subsite of a sub-sub-subsite. - -I find it often works when the subsite "refuses" to be deleted from GUI. How often? - -Please let me know in Q and A! For which situation you used it, whether it worked as expected and how I can make it better! diff --git a/enablefeature.ps1 b/Site Management/Features/Enable feature/enablefeature.ps1 similarity index 100% rename from enablefeature.ps1 rename to Site Management/Features/Enable feature/enablefeature.ps1 diff --git a/Remove SPO subsite.ps1 b/Site Management/Remove SPO subsite/Remove SPO subsite.ps1 similarity index 100% rename from Remove SPO subsite.ps1 rename to Site Management/Remove SPO subsite/Remove SPO subsite.ps1 diff --git a/Versioning/Enable versioning for all lists in OneDrive sites/description.md b/Versioning/Enable versioning for all lists in OneDrive sites/description.md index efa5e103..59cc0a80 100644 --- a/Versioning/Enable versioning for all lists in OneDrive sites/description.md +++ b/Versioning/Enable versioning for all lists in OneDrive sites/description.md @@ -17,7 +17,7 @@ At the end, a csv file is generated with the lists' urls and the status whether As the script runs you will see green lists' titles for which the enabling succeeded and red for those which failed (not all lists support versioning). - + diff --git a/Versioning/PS Enable versioning for all SharePoint Online lists/description.md b/Versioning/PS Enable versioning for all SharePoint Online lists/description.md index 9c558e35..72534dac 100644 --- a/Versioning/PS Enable versioning for all SharePoint Online lists/description.md +++ b/Versioning/PS Enable versioning for all SharePoint Online lists/description.md @@ -1 +1,31 @@ -. +A short script that enables versioning for all the libraries and lists in the whole tenant. + +It requires SharePoint Online Management Shell and SharePoint SDK installed: + +http://technet.microsoft.com/en-us/library/fp161372(v=office.15).aspx + +http://www.microsoft.com/en-us/download/details.aspx?id=30722 + + + +It uses recurrence to find all sites in all site collections and then goes through all the lists. + +For some lists, enabling version may not be possible and you will receive a notification of that. + +At the end, a csv file is generated with the lists' urls and the status whether enabling was successful or not. + + + +As the script runs you will see green lists' titles for which the enabling succeeded and red for those which failed (not all lists support versioning). + + + + + + + + +You can customize the script by using the commented out tips. + +

+Enjoy and please share feedback! diff --git a/Versioning/PS Enable versioning for all SharePoint Online lists/description.txt b/Versioning/PS Enable versioning for all SharePoint Online lists/description.txt deleted file mode 100644 index fe17d31e..00000000 --- a/Versioning/PS Enable versioning for all SharePoint Online lists/description.txt +++ /dev/null @@ -1,52 +0,0 @@ -A short script that enables versioning for all the libraries and lists in the whole tenant. - -It requires SharePoint Online Management Shell and SharePoint SDK installed: - -http://technet.microsoft.com/en-us/library/fp161372(v=office.15).aspx - -http://www.microsoft.com/en-us/download/details.aspx?id=30722 - - - -It uses recurrence to find all sites in all site collections and then goes through all the lists. - -For some lists, enabling version may not be possible and you will receive a notification of that. - -At the end, a csv file is generated with the lists' urls and the status whether enabling was successful or not. - - - -As the script runs you will see green lists' titles for which the enabling succeeded and red for those which failed (not all lists support versioning). - -Versioning will always fail for public site. - - -You can customize the script by using the commented out tips: - - - -PowerShell -# Paths to SDK. Please verify location on your computer. -Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" -Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" - -# Versioning will be enabled. If you prefer to disable it for the whole tenant, change to $false -$versioning = $true - -# You can also enter credentials directly: $siteUrl="https://tenant-admin.sharepoint.com" -$siteUrl = Read-Host -Prompt "Enter https://tenant-admin.sharepoint.com” -$username = Read-Host -Prompt "Enter admin's login, e.g. admin@domain.onmicrosoft.com" -$password = Read-Host -Prompt "Enter password" -AsSecureString -$credy= New-Object System.Management.Automation.PSCredential($username,$password) -Connect-SPOService -Credential $credy -Url $siteUrl - -$sitecollections=get-SPOSite -$Global:csv=@() - -foreach($sitecoll in $sitecollections) -{ - getall($sitecoll.Url) -} - -# Specify the path where the log file will be published -$Global:csv | Export-Csv -Path C:\Users\Public\Versioning.csv diff --git a/Versioning/PS Enable versioning for all SharePoint Online lists/enableversioning.ps1 b/Versioning/PS Enable versioning for all SharePoint Online lists/enableversioning.ps1 index f889535b..c744e415 100644 --- a/Versioning/PS Enable versioning for all SharePoint Online lists/enableversioning.ps1 +++ b/Versioning/PS Enable versioning for all SharePoint Online lists/enableversioning.ps1 @@ -60,7 +60,7 @@ $versioning = $true # You can also enter credentials directly: $siteUrl="https://tenant-admin.sharepoint.com" $siteUrl = Read-Host -Prompt "Enter https://tenant-admin.sharepoint.com” -$username = Read-Host -Prompt "Enter admin's login, e.g. admin@domain.onmicrosoft.com" +$username = Read-Host -Prompt "Enter admin login, e.g. admin@domain.onmicrosoft.com" $password = Read-Host -Prompt "Enter password" -AsSecureString $credy= New-Object System.Management.Automation.PSCredential($username,$password) Connect-SPOService -Credential $credy -Url $siteUrl diff --git a/Versioning/PS Restore previous versions in the entire library/Restore previous versions.ps1 b/Versioning/PS Restore previous versions in the entire library/Restore previous versions.ps1 index dc33fd55..b4efa5b5 100644 --- a/Versioning/PS Restore previous versions in the entire library/Restore previous versions.ps1 +++ b/Versioning/PS Restore previous versions in the entire library/Restore previous versions.ps1 @@ -2,8 +2,8 @@ { param ( [Parameter(Mandatory=$true,Position=1)] - [string]$Username, - [Parameter(Mandatory=$true,Position=2)] + [string]$Username, + [Parameter(Mandatory=$true,Position=2)] [string]$Url, [Parameter(Mandatory=$true,Position=3)] $password, @@ -20,9 +20,9 @@ param ( $ctx.Load($ll) $ctx.ExecuteQuery() $spqQuery = New-Object Microsoft.SharePoint.Client.CamlQuery - $spqQuery.ViewXml =""; - $itemki=$ll.GetItems($spqQuery) - $ctx.Load($itemki) + $spqQuery.ViewXml =""; + $itemki=$ll.GetItems($spqQuery) + $ctx.Load($itemki) $ctx.ExecuteQuery() foreach($item in $itemki) @@ -61,13 +61,14 @@ param ( } if($file.Versions[($file.Versions.Count-1)].IsCurrentVersion) { - $vLabel=$file.Versions[($file.Versions.Count-2)].VersionLabel - Write-Host "Version to be restored: " $vLabel + $vLabel=$file.Versions[($file.Versions.Count-2)].VersionLabel + Write-Host "Version to be restored: " $vLabel } - else{ $vLabel=$file.Versions[($file.Versions.Count-1)].VersionLabel - Write-Host "Version to be restored: " $vLabel } - $file.Versions.RestoreByLabel($vLabel) - $ctx.ExecuteQuery() + else{ + $vLabel=$file.Versions[($file.Versions.Count-1)].VersionLabel + Write-Host "Version to be restored: " $vLabel } + $file.Versions.RestoreByLabel($vLabel) + $ctx.ExecuteQuery() } else diff --git a/Workflows/Get workflow report for a site collection/workflows in one site coll.ps1 b/Workflows/Get workflow report for a site collection/workflows in one site coll.ps1 index f150886e..3bc49c3d 100644 --- a/Workflows/Get workflow report for a site collection/workflows in one site coll.ps1 +++ b/Workflows/Get workflow report for a site collection/workflows in one site coll.ps1 @@ -5,9 +5,9 @@ param ( [string]$Username, [Parameter(Mandatory=$true,Position=2)] $AdminPassword, - [Parameter(Mandatory=$true,Position=3)] + [Parameter(Mandatory=$true,Position=3)] [string]$Url, - [Parameter(Mandatory=$true,Position=4)] + [Parameter(Mandatory=$true,Position=4)] [string]$CSVPath ) @@ -23,12 +23,13 @@ param ( foreach ( $ll in $Lists) { - $workflo = $ll.WorkflowAssociations; - $ctx.Load($workflo); + $WorkflowCollection = $ll.WorkflowAssociations; + $ctx.Load($WorkflowCollection); + try { $ctx.ExecuteQuery(); - Write-host $ll.Title $workflo.Count -ForegroundColor Green + Write-host $ll.Title $WorkflowCollection.Count -ForegroundColor Green } catch [Net.WebException] @@ -37,15 +38,15 @@ param ( } - foreach ($workfloek in $workflo) - { - $workfloek | Add-Member NoteProperty "SiteUrl"($ctx.Web.Url) - $workfloek | Add-Member NoteProperty "ListTitle"($ll.Title) - Write-Output $workfloek + foreach ($SingleWorkflow in $WorkflowCollection) + { + $SingleWorkflow | Add-Member NoteProperty "SiteUrl"($ctx.Web.Url) + $SingleWorkflow | Add-Member NoteProperty "ListTitle"($ll.Title) + Write-Output $SingleWorkflow - $workfloek | export-csv -Path $CSVPath -Append - - } + $SingleWorkflow | export-csv -Path $CSVPath -Append + + } } diff --git a/Workflows/Get workflow report for all site collections/description.md b/Workflows/Get workflow report for all site collections/description.md index e9cf8bc6..fddac1e8 100644 --- a/Workflows/Get workflow report for all site collections/description.md +++ b/Workflows/Get workflow report for all site collections/description.md @@ -10,7 +10,7 @@ Before you run the script, open .ps1 file and edit all necessary information: -PowerShell +```PowerShell # Paths to SDK. Please verify location on your computer. Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll" @@ -20,7 +20,7 @@ $Username="user@tenant.onmicrosoft.com" $AdminPassword=Read-Host -Prompt "Password" -AsSecureString $AdminUrl="https://tenant-admin.sharepoint.com" $CSVPath="C:\Users\ivo\Desktop\SomePath.csv" - +``` @@ -41,24 +41,16 @@ As the script runs you will see how many workflows each list has: + - - - - - - - - - -Sample report +### Sample report #TYPE Microsoft.SharePoint.Client.Workflow.WorkflowAssociation @@ -74,7 +66,7 @@ https://tenant.sharepoint.com/TeamsitewithLists Generic List With GeolocationCol -Related scripts +### Related scripts Get workflow report for one site diff --git a/Workflows/Get workflow report for one site/description.md b/Workflows/Get workflow report for one site/description.md index a04f9c7a..6fc8ec37 100644 --- a/Workflows/Get workflow report for one site/description.md +++ b/Workflows/Get workflow report for one site/description.md @@ -1,43 +1,39 @@ -rogram Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" -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 site and the path where the report should be saved. -$Username="2190@tenant.onmicrosoft.com" -$AdminPassword=Read-Host -Prompt "Password" -AsSecureString -$Url="https://tenant.sharepoint.com" -$CSVpath="C:\testpath2.csv" - -As the script runs you will see how many workflows each list has: +Powershell script. Creates a .csv file with a report on all workflows in a site collection. - - - +Before you run the script, open .ps1 file and edit all necessary information: +```PowerShell - - - +# Paths to SDK. Please verify location on your computer. +Add-Type -Path "c:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll" +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 site and the path where the report should be saved. +$Username="2190@tenant.onmicrosoft.com" +$AdminPassword=Read-Host -Prompt "Password" -AsSecureString +$Url="https://tenant.sharepoint.com" +$CSVpath="C:\testpath2.csv" +``` +As the script runs you will see how many workflows each list has: + - - -Sample report +### Sample report #TYPE Microsoft.SharePoint.Client.Workflow.WorkflowAssociation