当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 在 PowerShell 中按 GUID 查找广告对象

作者:精品下载站 日期:2024-12-14 22:03:47 浏览:13 分类:玩电脑

在 PowerShell 中按 GUID 查找广告对象


使用 PowerShell 中的 Get-AdObject cmdlet 按 GUID 查找广告对象。它具有包含活动目录对象 GUID 的 ObjectGuid 属性。

请参阅以下命令通过 GUID 检索 Active Directory 对象。

Get-ADObject -Filter {objectGUID -eq 'f1586188-ad09-4054-a3a2-dff90e5f608a'}

在本文中,我们将讨论如何使用 Get-AdObject cmdlet 在 PowerShell 中通过 guid 获取广告对象。

在 PowerShell 中通过 GUID 查找 Active Directory 对象

PowerShell 中的 Get-AdObject cmdlet 从活动目录中检索对象。它使用 ObjectGuid 属性来比较提供的 guid 并检索广告对象。

Get-ADObject -Filter {objectGUID -eq 'f1586188-ad09-4054-a3a2-dff90e5f608a'}

在上面的 PowerShell 脚本中,Get-AdObject 命令使用 Filter 参数来检查广告对象的 ObjectGuid 属性是否等于提供的 guid 。如果符合条件,它将获取一个活动目录对象。

上述通过 guid 查找广告对象的 PowerShell 脚本的输出是:

[玩转系统] 在 PowerShell 中按 GUID 查找广告对象

酷提示:如何在 PowerShell 中将 guid 转换为字符串!

在 PowerShell 中通过 GUID 检索广告对象

PowerShell 中的 Get-AdObjct cmdlet 根据其 Identity 参数检索 Active Directory 对象。 Identity 参数指定要检索的广告对象的唯一标识,它接受 GUID、SID 或 SAMAccount 以在 PowerShell 中获取广告对象。

$userGuid = 'f1586188-ad09-4054-a3a2-dff90e5f608a'
$user = Get-ADObject -Identity $userGuid -Properties *
Write-Host $user

在上面的 PowerShell 脚本中,$userGuid 变量存储对象的标识,即 GUID。

Get-AdObject 使用 Identity 参数指定 GUID,并在 PowerShell 中通过 GUID 检索广告用户 GUID。

上述在 PowerShell 中按 guid 查找广告用户的 PowerShell 脚本的输出是:

PS C:\> $userGuid = 'f1586188-ad09-4054-a3a2-dff90e5f608a'
PS C:\> $user = Get-ADObject -Identity $userGuid -Properties *
PS C:\> $user


accountExpires                  : 0
adminCount                      : 1
badPasswordTime                 : 133046969540825393
badPwdCount                     : 2
CanonicalName                   : SHELLPRO.LOCAL/Users/adam
CN                              : adam
codePage                        : 0

结论

我希望上面有关如何在 PowerShell 中使用 Get-AdObject cmdlet 通过 GUID 查找广告对象的文章对您有用。

Get-AdObject 的 ObjectGuid 属性可用于检查指定的 Guid 并在 PowerShell 中检索广告对象。

Get-AdObject 的 Identity 参数可用于检查指定的 Guid 并在 PowerShell 中查找广告对象。

您可以在 ShellGeek 主页上找到有关 PowerShell Active Directory 命令和 PowerShell 基础知识的更多主题。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯