powershell - Powershell脚本do-while循环中的哨兵突破值?
问题描述
我是实习生,这是一个 powershell 脚本,它继续循环询问用户的用户名并更改默认值,如果不正确,我可以输入 no,但它会继续运行,因为 while 循环以 Yes 结尾,我该如何添加这个循环的哨兵突破值?
$Default = "accountName"
Do{
$LoginName = //some script
$user = Get user //some script
$Default = "No"
$Write-Host " Display information " //some script
$confirmation = $( if($Target=(Read-Host "Is this the right account? [$Default]")){Target}else{$Default})
$default = $LoginName
}
while ($confirmation -ne "YES")
解决方案
推荐阅读
- angular - 来自 Observable 输出的 RxJS Observable 结果
- python - 无法使用熊猫解码 csv 文件
- android - 将 Flutter SDK 嵌入到现有的 Android 和 IOS 应用程序中
- android - 通过观察 ViewModel 在 RecyclerView 中搜索 PagedList 的 LiveData
- marklogic - QBE 查询未检索到预期结果
- swift - UISearchController 在具有自定义布局的 CollectionView 中的视图开始时可见
- reactjs - React SPA 路由问题
- javascript - ASP NET Core - 以编程方式清除 ResponseCache
- docker - 如果不在本地主机代理-> vpn 上,docker-compose 端口转发不起作用
- sql-server - SQL Server 中 WITH(NOLOCK) 的使用