如何在 PowerShell 中使用 -AsSecureString 参数向已创建的本地用户添加密码

How do I add a password to an already created localuser using -AsSecureString parameter in PowerShell

我对 powershell 有点陌生,我正在接受 class 要求我创建本地用户,然后在创建本地用户后使用 -assecurestring 参数添加密码。尽管我不断收到错误,但从文档中添加密码时创建本地用户没有问题看起来很简单。我的所有 google 搜索都让我陷入无休止的循环,但同样的信息无效。请帮忙

这些都在 PowerShell 帮助文件和示例中。

Find-Module -Name '*localuser*' | 
Format-Table -AutoSize

Version Name                Repository Description                                                   
------- ----                ---------- -----------                                                   
3.0     LocalUserManagement PSGallery  a module that performs various local user management functions

# Get specifics for a module, cmdlet, or function
(Get-Command -Name Set-LocalUser).Parameters
(Get-Command -Name Set-LocalUser).Parameters.Keys
Get-help -Name Set-LocalUser -Examples
# Results
<#
Set-LocalUser -Name "Admin07" -Description "Description of this account."
$Password = Read-Host -AsSecureString
$UserAccount = Get-LocalUser -Name "User02"
$UserAccount | Set-LocalUser -Password $Password
#>
Get-help -Name Set-LocalUser -Full
Get-help -Name Set-LocalUser -Online