PowerShell 复制 Read-Host [[-Prompt] <Object>] [-AsSecureString] [<CommonParameters>]说明Read-Host cmdlet 从控制台 (stdin) 读取一行输入。 可使用它来提示用户输入数据。 因为可以将输入保存为安全字符串,所以可以使用此 cmdlet 来提示用户输入安全数据(例如密码)。
PowerShell 复制 Uninstall-ADDSDomainController -LocalAdministratorPassword (Read-Host -Prompt "Password:" -AsSecureString) 警告 由于前两个选项不确认密码,因此请务必谨慎小心:密码不可见。你还可以提供安全字符串作为转换的明文变量,尽管强烈不建议这样做。 例如:PowerShell 复制 ...
PowerShell 复制 Uninstall-ADDSDomainController -LocalAdministratorPassword (Read-Host -Prompt "Password:" -AsSecureString) 警告 由于前两个选项不确认密码,因此请务必谨慎小心:密码不可见。你还可以提供安全字符串作为转换的明文变量,尽管强烈不建议这样做。 例如:PowerShell 复制 ...
The objects to display on the host before collecting input. C++ 複製 public: property System::Object ^ Prompt { System::Object ^ get(); void set(System::Object ^ value); }; Property Value Object Applies to 產品版本 PowerShell SDK 7.2.0, 7.3.0, 7.4.0 Windows PowerShell ...
$number=Get-Random-Minimum1-Maximum10do{$guess=Read-Host-Prompt"What's your guess?"if($guess-lt$number) {Write-Output'Too low!'}elseif($guess-gt$number) {Write-Output'Too high!'} }while($guess-ne$number) Output What's your guess?: 1 Too low! What's your guess?: 2 Too low!
Prompt"Enter the Azure region to create resources in, such as 'Central US'"$defaultStorageAccountName=Read-Host-Prompt"Enter the default storage account name"New-AzResourceGroup-Name$resourceGroupName-Location$location# Create an Azure storage account and container# Note: Storage account kind Blob...
$Password=Read-Host-Prompt'Please enter your password'-AsSecureStringNew-AzMariaDbServer-Namemydemoserver-ResourceGroupNamemyresourcegroup-SkuGP_Gen5_2-GeoRedundantBackupEnabled-Locationwestus-AdministratorUsernamemyadmin-AdministratorLoginPassword$Password ...
第二个命令使用 Read-Host cmdlet 从用户输入创建安全字符串。 Prompt 参数请求用户输入,AsSecureString 参数会屏蔽输入并将其转换为安全字符串。第三个命令使用 New-Object cmdlet 从存储在$User变量中的$PWord值创建 PSCredential 对象。示例5PowerShell 复制 ...
$confirmation=Read-Host"Are you Sure You Want To Proceed?" if($confirmation-eq'y') { "GO!!!" } 执行: 我们执行的是PowerShell.exe,TEST.PS1作为其参数 那如果脚本中出现多次确认呢? $confirmation=Read-Host"Are you Sure You Want To Proceed?" ...
任务管理器杀进程大家都会,不过如果你的系统被卡到任务管理器都无法操作了,怎么办?直接在 PowerShell ...