【问题标题】:Azure Devops remove specific user from specific organization using PowershellAzure Devops 使用 Powershell 从特定组织中删除特定用户
【发布时间】:2022-01-11 08:05:36
【问题描述】:

例如,我想从 Azure 开发组织 BigZoo 中移除 Tiger(Tiger 有 3 个 Azure 组织,BigZoo、SmallZoo、middleZoo——我只想从 BigZoo 中移除 Tiger)

在 Azure Cloudshell Powershell 中使用此 Azure CLI 即可运行

az devops user remove --user tiger
                      [--org BigZoo]
                      [--yes]

但在 Azure 函数中不起作用-->Azure 函数使用 PowerShell 环境--> CloudPowerShell 可以读取 AzureCLi 但 AzureFunction 中的 Powershell 无法读取与 Az 相关的任何内容

所以,如果我只想在没有 Azure CLI 帮助的情况下使用 powershell,则有一些模块,但所有导入的模块都是从所有组织中删除用户--> 不从特定组织中删除用户

有什么建议吗?从特定 AzureDevops 组织中删除用户。使用 API 似乎太复杂了。有什么好主意吗? 谢谢

【问题讨论】:

    标签: powershell api azure-devops azure-functions azure-cli


    【解决方案1】:

    我没有尝试过,但是 PowerShell 库中有一个 VSTteam powershell 模块,它封装了 Azure Devops API。

    这有一个函数叫做:Remove-VSTeamUserEntitlement

    这里的文档: https://methodsandpractices.github.io/vsteam-docs/docs/modules/vsteam/commands/Remove-VSTeamUserEntitlement

    这里的模块: https://www.powershellgallery.com/packages/VSTeam/

    将模块添加到您的 azure 函数项目的 Requirements.psd1 文件中,您应该可以使用它。

    【讨论】:

    • 我对你的答案投了赞成票,因为它有帮助,但实际上它不是真正的答案。这个我很久以前就知道了,但是这个 Remove-VsTeamUserEntitlement 的弱点是我们没有组织参数.....就像 Cat 有 3 个组织..如果我使用这个,这个怎么知道哪个要删除的组织可能会删除所有组织谢谢
    • 您可以设置正在使用的帐户的上下文:methodsandpractices.github.io/vsteam-docs/docs/modules/vsteam/…,并且可以为每个接受 POST 请求并加载不同身份的组织设置不同的端点,以免混淆 Azure DevOps 组织起来。
    猜你喜欢
    • 2014-12-05
    • 2010-12-02
    • 1970-01-01
    • 1970-01-01
    • 2016-12-12
    • 2020-11-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多