How to Use -confirm in PowerShell

后端 未结 10 1403
遥遥无期
遥遥无期 2020-12-07 20:10

I\'m trying to take user input and before proceeding I would like get a message on screen and than a confirmation, whether user wants to proceed or not. I\'m using the follo

10条回答
  •  攒了一身酷
    2020-12-07 20:40

    For when you want a 1-liner

    while( -not ( ($choice= (Read-Host "May I continue?")) -match "y|n")){ "Y or N ?"}
    

提交回复
热议问题