这个标题真的很流畅。
在设置用于 Azure Active Directory 的计算机时,我们会让 IT 进行初始设置和配置。这包括首次登录和加入 Azure Active Directory。登录时,它会强制您选择验证方法。为了方便起见,我们会使用我们的桌面电话或手机。
现在是我们更新第二个因素电话号码的时候了。我知道一种通过 Azure AD Web UI 手动执行此操作的方法,但我正在寻找一种在 PowerShell 中设置该数字的脚本方法。
这是我通过 PowerShell 检索号码的方法。
Get-msoluser -UserPrincipalName "email@emailaddress.com" | Select-Object -ExpandProperty StrongAuthenticationUserDetails
Run Code Online (Sandbox Code Playgroud)
该代码返回此信息:
ExtensionData : System.Runtime.Serialization.ExtensionDataObject
AlternativePhoneNumber :
Email :
OldPin :
PhoneNumber : +1 5554445555
Pin :
Run Code Online (Sandbox Code Playgroud)
但是,似乎没有用于设置 StrongAuthenticationUserDetails 的类似选项。
我所有的搜索都显示了如何批量启用 2 因素身份验证,这不是我想要做的。我想保持 StrongAuthentication 不变,同时只更新电话号码。
正如我在评论中所说,似乎 powershell 具有只读访问权限。
\n\nAzure 反馈上甚至还开有相关票证。
\n\n有计划这样做,但没有预计到达时间。我的猜测是,如果您只想使用 powershell,则必须等待。
\n\n作为解决方法,您可以使用powershell和watir for .NET或Watin与Watin 记录器通过 Internet Explorer 将其自动化。因为我没有测试 Azure;我无法为您创建可行的代码。
\n\n使用Watin和 powershell - 您可以检查:https://cmille19.wordpress.com/2009/09/01/internet-explorer-automation-with-watin/
\n\n我想在这里备份以下文本和代码,取自上面的页面(所有内容均归作者所有):
\n\n\n\n\n接下来单击“录制”按钮并单击要自动化的 HTML 元素。然后停止 WatIN 记录器并单击“将代码复制到剪贴板”图标。这将生成一些只需转换为 PowerShell 的 C# 代码:
\n
// Windows\nWatiN.Core.IE window = new WatiN.Core.IE();\n\n// Frames\nFrame frame_sd_scoreboard = window.Frame(Find.ByName("sd") && Find.ByName("scoreboard"));\n\n// Model\nElement __imgBtn0_button = frame_sd_scoreboard.Element(Find.ByName("imgBtn0_button"));\n\n// Code\n__imgBtn0_button.Click();\nwindow.Dispose();\nRun Code Online (Sandbox Code Playgroud)\n\n\n\n\n所以,我现在知道按钮的名称以及它的深度为 3 帧。后来对 WatIN 对象进行了一些探索,我想出了下面的脚本,该脚本每 50 分钟单击一个按钮。
\n
#Requires -version 2.0\n#powershell.exe -STA\n\n[Reflection.Assembly]::LoadFrom( "$ProfileDirLibrariesWatiN.Core.dll" ) | out-null\n$ie = new-object WatiN.Core.IE("https://sd.acme.com/CAisd/pdmweb.exe")\n$scoreboard = $ie.frames | foreach {$_.frames } | where {$_.name \xe2\x80\x93eq \xe2\x80\x98sd\xe2\x80\x99} | foreach {$_.frames } | where {$_.name \xe2\x80\x93eq \xe2\x80\x98scoreboard\xe2\x80\x99}\n$button = $scoreboard.Element("imgBtn0_button")\n\nwhile ($true)\n{\n $button.Click()\n #Sleep for 50 minutes\n [System.Threading.Thread]::Sleep(3000000)\n}\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
5883 次 |
| 最近记录: |