Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.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
.net 通过powershell获得Azure Aduser_.net_Powershell_Active Directory_Azure Active Directory_Azure Powershell - Fatal编程技术网

.net 通过powershell获得Azure Aduser

.net 通过powershell获得Azure Aduser,.net,powershell,active-directory,azure-active-directory,azure-powershell,.net,Powershell,Active Directory,Azure Active Directory,Azure Powershell,我可以在C#控制台应用程序中获取广告用户,但我无法使用powershell获取广告用户。 以下是C#代码: string responseString=null; 使用(var client=new HttpClient()) { var数据=新字典 { {“授权类型”,“密码”}, {“客户id”,“客户id”}, {“客户秘密”,“客户秘密”}, {“范围”https://graph.microsoft.com/.default" }, {“userName”,这里是您的用户名}, {“pa

我可以在C#控制台应用程序中获取广告用户,但我无法使用powershell获取广告用户。 以下是C#代码:

string responseString=null;
使用(var client=new HttpClient())
{
var数据=新字典
{
{“授权类型”,“密码”},
{“客户id”,“客户id”},
{“客户秘密”,“客户秘密”},
{“范围”https://graph.microsoft.com/.default" },
{“userName”,这里是您的用户名},
{“password”,这里是您的密码}
};
var内容=新的FormUrlEncodedContent(数据);
var response=wait client.PostAsync(“https://login.microsoftonline.com/id/oauth2/v2.0/token“,内容);
responseString=wait response.Content.ReadAsStringAsync();
}
var token=JsonSerializer.Deserialize(responseString);
变量graphapistring=”https://graph.microsoft.com/v1.0/users/";
使用(var client1=new HttpClient())
{
client1.DefaultRequestHeaders.Authorization=新的AuthenticationHeaderValue(“承载者”,token.access\u token);
var response=await client1.GetAsync(graphapistring);
responseString=wait response.Content.ReadAsStringAsync();
}
var user=JsonSerializer.Deserialize(responseString);

我需要帮助将上述代码转换为powershell。

根据您的要求,您只需在powershell中使用AzureAD模块即可

通过在powershell中运行以下命令安装AzureAD模块:
Install module AzureAD
。你可以参考这个

安装模块后,我们需要先连接到azure ad。运行
connectazuread
命令进行连接


然后你可以通过运行命令来获取广告用户,这个命令可以只响应每个用户的几个字段。如果您想要每个用户的更多字段,您可以运行
Get AzureADUser | fl

Hi,请参阅下面我提供的解决方案。如果这有助于解决您的问题,请将其作为答案(单击“我的答案”旁边的复选标记,将其从灰色变为填充)。提前谢谢~如果还有什么问题,请告诉我。