首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我希望创建一个PowerShell脚本来撤销用户的Azure刷新令牌并禁用用户的设备

我希望创建一个PowerShell脚本来撤销用户的Azure刷新令牌并禁用用户的设备
EN

Stack Overflow用户
提问于 2022-06-24 20:47:00
回答 1查看 126关注 0票数 0

我正在寻找一些关于组合组合以下脚本的PowerShell脚本的指导:

Connect-AzureAD

Revoke-AzureADUserAllRefreshToken -ObjectId johndoe@contoso.com

Get-AzureADUserRegisteredDevice -ObjectId johndoe@contoso.com | Set-AzureADDevice -AccountEnabled $false

我希望实现的是将所有三个cmdlet合并到我的工作人员可以运行的单个脚本中,它将提示我们希望运行脚本的用户名。假设我需要在这个脚本中的某个地方添加$ObjectID = Read-Host -Prompt

事先感谢您对如何做到这一点的任何建议或指导。

EN

Stack Overflow用户

发布于 2022-06-24 21:07:47

假设我理解你的问题,而你只是想要一种方法,把所有这些按照正确的顺序组合在一起,就在这里。

代码语言:javascript
运行
复制
# Use one or the other depending on if you want to use the username or objectID
$Username = Read-Host -Prompt
#$ObjectId = Read-Host -Prompt

Connect-AzureAD

# Use one or the other depending on if you want to use the username or objectID
$User = Get-AzureADUser -SearchString $Username
#$User = Get-AzureADUser -ObjectId $ObjectId

if ($null -ne $User) {
  Revoke-AzureADUserAllRefreshToken -ObjectId $User.ObjectId
  Get-AzureADUserRegisteredDevice -ObjectId $User.ObjectId | Set-AzureADDevice -AccountEnabled $false 
} else {
  Write-Warning "No user found with the specified criteria"
}
票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72749246

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档