【问题标题】:Export ObjectSID & Samaccountname导出 ObjectSID 和 Samaccountname
【发布时间】:2016-06-29 19:00:31
【问题描述】:

目前没有收到文本文件中 ObjectSID 的导出,需要调整什么?当前只有每行以“;”开头然后是 samaccountname

$ADObjects = Get-ADObject -LDAPFilter "(msexchextensionattribute23=*)" -Properties samaccountname,objectsid -Server myserver1.com
Out-File -FilePath C:\temp\AD001CountReport.txt -Append -InputObject ($ADObjects.Count + " Objects with msexchextensionattribute23 set found") 

foreach($ADObject in $ADObjects)
{
    $Export = $ADObject.objectsid + ";" + $ADObject.samaccountname
    $Export | Out-file ("C:\temp\AD001ObjectReport" + ".txt") -Append
    $Export = $null
}

【问题讨论】:

  • 听起来 objectid 是空白的。您是否确认这是正确的属性名称?
  • $adobject.SID(例如:S-1-5-21-2889043008-4136710315-2444824263-3544)或$adobject.ObjectGUID(例如:e1418d64-096c-4cb0-b903-ebb66562d9d)跨度>
  • @briantist 执行直接拉动时,我得到了与 sodawillow 类似的结果:Get-ADUser user1 -server myserver1.com -Properties *
  • 但是,当从Get-ADObject 进行类似的拉取时,它无法识别域内的对象
  • @sodawillow 在执行$adobject.sid 时也没有给出结果

标签: powershell active-directory export


【解决方案1】:

您的字符串连接失败,因为objectSid 属性是System.Security.Principal.SecurityIdentifier 类型的对象,您不能向其中添加/附加字符串。使用对象的 Value 属性获取可以使用的 SID 字符串:

$Export = $ADObject.objectsid.Value + ";" + $ADObject.samaccountname

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-07-27
    • 2019-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-23
    • 1970-01-01
    • 2020-07-30
    相关资源
    最近更新 更多