gpt4 book ai didi

powershell - 如何在 Windows Powershell 中获取 Azure Active Directory 用户名?

转载 作者:行者123 更新时间:2023-12-02 22:34:20 34 4
gpt4 key购买 nike

我正在尝试从加入 Windows 10 Azure Active Directory (AAD) 的计算机上的 Powershell 获取当前的 Windows 用户名和域。

我已尝试过 this question 中的提示,但它们似乎都不适用于加入 Azure Active Directory 的计算机。

例如对于用户:Jonathan Doe, <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="244e4b4c4a64415c45495448410a474b49" rel="noreferrer noopener nofollow">[email protected]</a>您只会得到用户的正确名称 & AzureAD (不是他们的用户名或“真实”域):

$env:UserName --> JonathanDoe
$env:UserDomain --> AzureAD
[System.Security.Principal.WindowsIdentity]::GetCurrent().Name --> AzureAD\JonathanDoe

有谁知道如何获取用户实际凭据或特定 Azure AAD 域的任何部分? (例如 johnexample.com 或理想情况下 <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1c767374725c79647d716c7079327f7371" rel="noreferrer noopener nofollow">[email protected]</a> )

最佳答案

您可以在PowerShell中运行以下命令,输出将以UPN格式显示用户名。您可以从中获取用户名和域名。

whoami.exe /UPN

此外,程序“whoami.exe”还提供了许多其他参数来获取有关当前用户的附加信息。您可以键入以下命令以获取有关“whoami.exe”的更多详细信息。

whoami.exe /?

关于powershell - 如何在 Windows Powershell 中获取 Azure Active Directory 用户名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43443349/

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