如何查找 SharePoint 中网站的创建者?
曾经想知道谁创建了 SharePoint 网站吗?对不起!无法从 SharePoint 用户界面获取网站的创建者!您无法在任何地方获取“创建者”或“创建于”值。但 PowerShell 是我们的救星!让我们看看谁使用 PowerShell 创建了 SharePoint 网站:
找出谁创建了 SharePoint 网站
只需运行以下 PowerShell 脚本即可查找谁创建了 SharePoint 网站:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Get the Web
$web = Get-SPWeb "https://portal.crescent.com/sites/Sales"
#Get Site Creator and Created Date
write-host "Site Created by:"$web.Author
Write-host "Created on:" $web.Created
此 PowerShell 可获取网站集或子网站的创建者。
SharePoint Online:使用 PowerShell 获取网站创建者
同样,要查找谁在 SharePoint Online 中创建了网站,请使用以下 PowerShell 脚本:
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Set Parameters
$SiteURL="https://Crescent.sharepoint.com/sites/marketing"
#Setup Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials
#Get the web
$Web=$Ctx.Web
$Ctx.Load($Web)
$Ctx.Load($Web.Author)
$Ctx.ExecuteQuery()
#Find who created a site
$Web.Author | Select LoginName, Email, Title
您还可以获取网站的创建日期和时间,如下所示:
$Web.Created.DateTime
用于获取网站创建者的 PnP PowerShell
要查明谁在 SharePoint Online 中创建了网站,请使用此 PnP PowerShell:
$SiteURL = "https://crescent.sharepoint.com/sites/HR"
#Connect to Site
Connect-PnPOnline $SiteURL -Interactive
#Get the Web
$Web = Get-PnPWeb
#Get the author - who has created the site
Get-PnPProperty -ClientObject $Web -Property Author
相关文章:确定谁在 SharePoint 中创建了列表视图
