0
powershellを使用してsharepointオンラインでsitecollection内のすべてのサイトを一覧表示します。私は、現時点で次のスクリプトを使用しています:Sharepoint Online - powershellを使用してsitecollection内のsharepointサイトを一覧表示する
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"
$siteUrl = “https://mytenant.sharepoint.com/sites/mysitecollection”
$username = "myusername"
$password = Read-Host -Prompt "Enter password" -AsSecureString
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password)
$ctx.Credentials = $credentials
$rootWeb = $ctx.Web
$sites = $rootWeb.Webs
$ctx.Load($rootWeb)
$ctx.Load($sites)
$ctx.ExecuteQuery()
foreach($site in $sites)
{
$ctx.Load($site)
$ctx.ExecuteQuery()
Write-Host $site.Title "-" $site.Url
}
エラーは次のようになります。
Exception calling " executeQuery " with 0 Argument (s) : " The remote server returned an error : (401) Unauthorized . "
Line : 16 Char: 1
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.
In Zeile:18 Zeichen:9
+ foreach($site in $sites)
は、誰かが私を助けてくださいことはできますか?