Created
May 30, 2014 20:08
-
-
Save vgrem/9763560fc9a5fd273ea0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
$AdminUrl = "https://tenant-admin.sharepoint.com/" | |
$UserName = "username@tenant.onmicrosoft.com" | |
$Password = "password" | |
$SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force | |
$Credentials = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $SecurePassword | |
$SPOCredentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword) | |
function Get-SPOWebs(){ | |
param( | |
$Url = $(throw "Please provide a Site Collection Url"), | |
$Credential = $(throw "Please provide a Credentials") | |
) | |
$context = New-Object Microsoft.SharePoint.Client.ClientContext($Url) | |
$context.Credentials = $Credential | |
$web = $context.Web | |
$context.Load($web) | |
$context.Load($web.Webs) | |
$context.ExecuteQuery() | |
foreach($web in $web.Webs) | |
{ | |
Get-SPOWebs -Url $web.Url -Credential $Credential | |
$web | |
} | |
} | |
#Retrieve all site collection infos | |
Connect-SPOService -Url $AdminUrl -Credential $Credentials | |
$sites = Get-SPOSite | |
#Retrieve and print all sites | |
foreach ($site in $sites) | |
{ | |
Write-Host 'Site collection:' $site.Url | |
$AllWebs = Get-SPOWebs -Url $site.Url -Credential $SPOCredentials | |
$AllWebs | %{ Write-Host $_.Title } | |
Write-Host '-----------------------------' | |
} | |
$AllWebs = Get-SPOWebs -Url 'https://tenant.sharepoint.com' -Credential $SPOCredentials | |
$AllWebs | %{ Write-Host $_.Title } |
Thanks :)
Do you perhaps know how to include $web.WorkflowAssociations ?
I can only assume I'm going to spend some time to load the context of the workflow?
An error occurred while enumerating through a collection: The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested..
At line:1 char:1
- $web.WorkflowAssociations
- CategoryInfo : InvalidOperation: (Microsoft.Share...lowAssociation]:<GetEnumerator>d__0) [], RuntimeException - FullyQualifiedErrorId : BadEnumeration
Getting this error , any Idea what needs to be changed (line 33 is - Connect-SPOService -Url $AdminUrl -Credential $Credentials)
Connect-SPOService : Could not connect to SharePoint Online.
At C:\Users\user1\Desktop\SPO scripts\Print-SPOSites.ps1:33 char:1
- Connect-SPOService -Url $AdminUrl -Credential $Credentials
-
+ CategoryInfo : NotSpecified: (:) [Connect-SPOService], InvalidOperationException + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.Online.SharePoint.PowerShell.ConnectSPOService
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great stuff!