Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sharepoint 将广告用户属性导出到CSV_Sharepoint_Powershell_Active Directory - Fatal编程技术网

Sharepoint 将广告用户属性导出到CSV

Sharepoint 将广告用户属性导出到CSV,sharepoint,powershell,active-directory,Sharepoint,Powershell,Active Directory,我想询问客户的广告,看看哪些用户在SharePoint 2013中的用户配置文件同步之前缺少属性值,如电话号码,脚本可以工作,但现在我需要添加一点“魔力”,以便创建我的csv文件。。。我在下面添加了一条评论,以表明我认为这种“魔力”应该走向何方 # get Users and groups #Get the User from AD $domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain(

我想询问客户的广告,看看哪些用户在SharePoint 2013中的用户配置文件同步之前缺少属性值,如电话号码,脚本可以工作,但现在我需要添加一点“魔力”,以便创建我的csv文件。。。我在下面添加了一条评论,以表明我认为这种“魔力”应该走向何方

 # get Users and groups

 #Get the User from AD
 $domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
 $root = $domain.GetDirectoryEntry()
 $search = [System.DirectoryServices.DirectorySearcher]$root
 #$search.Filter = "(&(objectCategory=User)(samAccountName=$userName))"

 # get a list of the users but not the sp_ service accounts.
 $search.Filter = "(&(objectCategory=User) (!(name=SP_*)) )"
 $search.SearchScope ="subtree"

 # determine the properties we want back

 $colPropList = "name", "jobTitle", "telephoneNumber","mail", "department"   ,  "thumbnailPhoto"
 foreach ($i in $colPropList){$search.PropertiesToLoad.Add($i)}


 $result = $search.FindAll()




 if ($result -ne $null)
 {

    foreach ( $entry in $result )
    {

       # this works though I might have incorrect names for some of the properties
       $user = $entry.Properties;
       $user.name
       $user.department
       $user.jobTitle
       $user.telephoneNumber
       $user.mail
       $user.thumbnailPhoto


       *# !!!!!!This is where I need help!!!!!             
       # as my $user is effectively an object then I should be able to to use it to create a an object with Add-Member 
       # Do I breaker down the $user properties and create another object with name values ???* 

       foreach ($o in $user) 
       {
          Add-Member -InputObject $psObject -MemberType NoteProperty -Name $o -Value $o
       } 

} 


$psObject | Export-Csv c:\dev\aduserList.csv -NoTypeInformation

}

我不熟悉directorysearcher/
adsi
,但如果您要迁移到SharePoint 2013,我猜您也有一台带有PowerShell的计算机。 在这种情况下,如果您有带Active Directory Web服务的2008 DC或2003,您应该使用Microsofts ActiveDirectory模块(安装在服务器上并通过RSAT为客户端安装)

你也可以使用

PowerShell cmdlet更易于用于广告管理。然后可以将脚本缩短为一行(这是Microsoft的ActiveDirectory模块):


我不确定
thumbnailphoto
部分是否可以工作,因为我以前没有使用过该属性。

类似这样的功能应该可以工作:

$search.FindAll() | select -Expand Properties |
  select @{n='name';e={$_.name}},
         @{n='department';e={$_.department}},
         @{n='jobTitle';e={$_.jobtitle}},
         @{n='telephoneNumber';e={$_.telephonenumber}},
         @{n='mail';e={$_.mail}},
         @{n='thumbnailPhoto';e={$_.thumbnailphoto}} |
  Export-Csv c:\dev\aduserList.csv -NoTypeInformation
请注意,计算属性(
@{n='name';e={expression}}
)的
表达式
部分中使用的属性必须是小写的:

@{n='thumbnailPhoto';e={$_.thumbnailphoto}}
@{n='thumbnailPhoto';e={$\ thumbnailPhoto}

按照建议从
ActiveDirectory
模块中使用
Get-ADUser
cmdlet是获取所需信息的更方便的方法,但它要求在使用AD PowerShell模块的计算机上安装AD PowerShell模块,广告Web服务安装并运行在DC上。

然后添加WindowsFeature RSAT AD PowerShell、RSAT AD AdminCenter。看起来都不错。再次感谢你的语法。。为每个用户构建一个对象,并通过管道导出CSVNp。当涉及到数据的管理和导出/导入时,PuthSeultCdDeLe是这样的方法:如果您认为这是正确的答案,请使用答案旁边的复选标记将其标记为:谢谢,以前我在广告机上运行过这个命令。幸运的是,我能够按照@FrodeF的建议在客户端的SharePoint开发机器上添加Windows功能。为什么我需要@{n='thumbnailPhoto';e={$\u0.thumbnailPhoto},这是定义propertyname的第一位,下一位是值?@westerdaled是的。您需要绕道而行,因为
select thumbnailphoto
(或者
select thumbnailphoto
)不起作用。
@{n='thumbnailPhoto';e={$_.thumbnailphoto}}