gpt4 book ai didi

powershell - 获取AD域的全名\缩写powershell

转载 作者:行者123 更新时间:2023-12-02 23:44:02 26 4
gpt4 key购买 nike

我有一些powershell脚本,它可以使某些文件的拥有者像这样:

$CreationOwner =Get-Acl $path | Select-Object Owner

但是现在我有了AD名称,因此 domain\ar仍然可以将其转换为该人的名字

最佳答案

您可以使用ADSI(Active Directory Service Interfaces)检索域用户的全名:

([adsi]"WinNT://$domain/$user,user").fullname

在您的情况下:

$domainUser = (Get-Acl $path | select -expand Owner) -replace '\\', '/'
$fullUserName = ([adsi]"WinNT://$domainUser,user").fullname

关于powershell - 获取AD域的全名\缩写powershell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30798587/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com