powershell - 循环访问多个 SharePoint 网站集

标签 powershell sharepoint

目前我有这个脚本:

$SiteURL="https://contoso.sharepoint.com/sites/contoso"
$UserID="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4822662c272d082b27263c273b27662624" rel="noreferrer noopener nofollow">[email protected]</a>"

#Get Credentials to connect
$Cred = Get-Credential

#Connect to SharePoint Online Admin Site
Connect-SPOService -Url $AdminSiteURL -Credential $cred

#sharepoint online powershell remove user permissions from site collection
Get-SPOUser -Site $SiteURL -LoginName $UserID

但我有多个网站集,需要在其中找到该用户:

https://contoso.sharepoint.com/sites/Projecten
https://contoso.sharepoint.com/sites/PFO

如何使用 for 循环执行此操作,以便在每个网站集中找到用户?

最佳答案

已经弄清楚了:

$UserID="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6c06420803092c0f030218031f03420200" rel="noreferrer noopener nofollow">[email protected]</a>"

$sitecollectios = @("https://contoso.sharepoint.com/sites/Extranet","https://contoso.sharepoint.com/sites/contoso","https://contoso.sharepoint.com/sites/Projecten","https://contoso.sharepoint.com/sites/PFO","https://contoso.sharepoint.com/sites/beheer","https://contoso.sharepoint.com/sites/Intranet")

#Get Credentials to connect
$Cred = Get-Credential

#Connect to SharePoint Online Admin Site

Connect-SPOService -Url $AdminSiteURL -Credential $cred

foreach ($collectie in $sitecollectios)
{ 
    Get-SPOUser -Site $collectie -LoginName $UserID
}

关于powershell - 循环访问多个 SharePoint 网站集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60967552/

相关文章:

Powershell 脚本无法删除目录

javascript - SharePoint JavaScript : find all <a> in a div

powershell - 如何在用户 session 中运行Powershell ScheduledJob(-AtLogOn)?

shell - 如何在 Powershell 中获取断开连接的网络驱动器?

file - Powershell,大规模移动某种类型的文件

html - 图像 slider 在 Chrome 中工作正常但在 IE11 中不工作

Sharepoint 设计器 - 布局文件夹?

javascript - 修复顶部栏 SharePoint 2013

javascript - 如何使用 JavaScript 访问 SharePoint 外部的 SharePoint 数据?

powershell - 将输入哈希表中的键添加到输出哈希表