c# - 在没有用户交互的情况下运行“Connect-MsolService”并为 Powershell 进行 Windows 身份验证
问题描述
我想在 powershell 上运行命令“Connect-MsolService”但没有用户交互。它应该采用 Windows 身份验证。此外,我无法将密码保存在任何外部文本文件中以进行身份验证。
我希望通过当前登录的 Windows 服务器凭据对其进行身份验证并进行身份验证。有没有办法在 Powershell 中做到这一点?
解决方案
您可以尝试以下命令以非交互方式登录,确保用户帐户未启用 MFA。
$azureUsername="user@xxxx.onmicrosoft.com"
$azurePassword = ConvertTo-SecureString "<Password>" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($azureUsername , $azurePassword)
Connect-MsolService -Credential $psCred
推荐阅读
- android - 白屏来自在颤振中在另一台设备上调试
- mysql - 我如何为 4 个表中的特定结果进行连接并且没有一个相关?
- javascript - 为什么我在执行突变时收到“不能为不可为空的字段返回 null”错误?
- reactjs - 如何使用 Reactjs 获取 CSV 数据并存储到状态中?
- python - 我怎样才能漂亮地处理这个脏的多次尝试代码
- php - 从单词数组中查找唯一排列,将一组单词限制为 12 个字符
- java - 输入 3 位数字并打印最大的数字
- regex - 如何计算网站上的表格数量
- blender - 甜甜圈中出现的搅拌机甜甜圈洒
- php - 如何将特定的 json 数据加入到一个 txt 文件中