生成主要和辅助网站集管理员报告 [英] Generate primary and secondary site collection administrators Report

查看:50
本文介绍了生成主要和辅助网站集管理员报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我是P.S的新手,并试图生成一个报告,该报告应:

-读取包含用户列表的文件.

-解析服务器场中的所有网站集,并检查列表中的用户是主要还是次要网站集管理员.

-生成网站集网址,ID(无域信息),用户名,IsprimaryAdmin,IsSecondaryAdmin的报告(CSV)

以下脚本可以正常工作,但是生成报告要花费很长时间,有关如何更有效地执行此操作的任何建议?

#########################

$ results = @()
$ users =获取内容"d:\ Users.txt"
foreach($ users中的$ user)
{
    $ SiteCollections = Get-SPSite -Limit All 
    #浏览所有网站集  
    foreach($ SiteCollections中的$ Site) 
      {    
        foreach($ Site.RootWeb.SiteAdministrators中的$ SiteCollAdmin) 
        {
          if($ SiteCollAdmin -ne $ null)
            {
              #单独的域和用户ID.
              $ u =($ SiteCollAdmin.LoginName.Split(" \")))
            if($ u -ne $ null)
            { 
            if($ u -eq $ user) 
            {
    #创建变量以写入CSV
              $ line =&"; |选择"SiteUrl","ID","UserName". ,"IsPrimaryAdmin", " IsSecondaryAdmin" 
              $ line.SiteUrl = $ Site.RootWeb.Url 
     #检查主要所有者,如果不是NULL,则设置为YES.          
              $ PO = $ Site.Owner.UserLogin
                  if($ PO -ne $ null)
                    {
                        if($ PO.Split("\")[1] -eq $ u [1])
                        {
                        $ line.ID = $ u [1]
                        $ line.UserName = $ site.Owner.Name
                        $ line.IsPrimaryAdmin =是" 
                        $ line.IsSecondAdmin =否"
                         }
                      }
#检查是否为次要所有者,如果不是NULL,则设置为YES
                    $ SO = $ Site.SecondaryContact.UserLogin
                    if($ SO -ne $ null)
                      {
                        if($ SO.Split("\")[1] -eq $ u [1])
                        {
                        $ line.ID = $ u [1]
                        $ line.UserName = $ site.SecondaryContact.Name
                        $ line.IsSecondAdmin =是"
                        $ line.IsPrimaryAdmin =否"
                        } 
                      }
              $ results + = $ line
              $ line = $ null
            }
          }
         }
        }                             
       }
      } $ results | Export-Csv -NoTypeInformation-路径d:\ Owners.csv 

################################################ #


解决方案

无需循环站点中的所有用户.请尝试以下脚本,该脚本将生成文本文件,该文件将提供主要&内容"列表.每个Web应用程序的辅助网站集管理员.

 


outputFile ="C:\\ SCAdminsReport.txt" 写主机此脚本将在Web应用程序中循环浏览所有网站集,并列出该集的URL,主要所有者和次要所有者".


webapp ="http://sp" ;


Hi All,

I am new to P.S and trying to generate a report that should:

- Read a file that has list of users.

- parse through all site collections in the farm and check if user in the list is either a primary or secondary site collection admin.

- Generate report (CSV) of Site collection url, ID (no domain info), Username, IsprimaryAdmin , IsSecondaryAdmin

The below script works fine but it's taking long time to generate a report, any suggestions on how to do this more efficiently?

###########################

$results= @()
$users = Get-Content "d:\Users.txt"
foreach($user in $users)
{
   $SiteCollections = Get-SPSite -Limit All 
    #Loop through all site collections  
    foreach($Site in $SiteCollections) 
     {    
        foreach($SiteCollAdmin in $Site.RootWeb.SiteAdministrators) 
        {
          if($SiteCollAdmin -ne $null)
           {
              # separate domain and user ID.
              $u = ($SiteCollAdmin.LoginName.Split("\"))
            if($u -ne $null)
            { 
            if($u -eq $user)  
            {
    #Create variable to write to CSV
             $line = "" | Select "SiteUrl", "ID", "UserName" ,"IsPrimaryAdmin",  "IsSecondaryAdmin" 
             $line.SiteUrl = $Site.RootWeb.Url 
     #check if primary owner and set to YES if NOT NULL           
             $PO = $Site.Owner.UserLogin
                 if($PO -ne $null)
                    {
                       if ($PO.Split("\")[1] -eq $u[1])
                        {
                        $line.ID = $u[1]
                        $line.UserName = $site.Owner.Name
                        $line.IsPrimaryAdmin = "Yes" 
                        $line.IsSecondAdmin = "No"
                         }
                      }
#check if Secondary owner and set to YES if NOT NULL 
                    $SO = $Site.SecondaryContact.UserLogin
                    if($SO -ne $null)
                      {
                        if($SO.Split("\")[1] -eq $u[1])
                        {
                        $line.ID = $u[1]
                        $line.UserName = $site.SecondaryContact.Name
                        $line.IsSecondAdmin = "Yes"
                        $line.IsPrimaryAdmin = "No"
                        } 
                      }
             $results += $line
             $line = $null
            }
          }
         }
        }                             
       }
      }$results | Export-Csv -NoTypeInformation -Path d:\Owners.csv  

###################################################


解决方案

Hi,

It’s no need to loop all users in site. Please try the following script, which generates the text file which will give the list of Primary & Secondary Site collection Administrators for each web application.:


outputFile = "C:\\SCAdminsReport.txt" Write-Host "This script will loop through all site collections in a web application and list the collection's URL, Primary Owner, and Secondary Owner"


webapp = "http://sp"


这篇关于生成主要和辅助网站集管理员报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆