# Prompt for Password - New User

**URL:** <https://forums.powershell.org/t/prompt-for-password-new-user/4884>\
**Category:** PowerShell Help\
**Created:** [September 15, 2015, 7:14pm UTC](https://forums.powershell.org/t/prompt-for-password-new-user/4884 "2015-09-15T19:14:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![roger-ohlsson](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@roger-ohlsson](https://forums.powershell.org/u/roger-ohlsson)\
**Post date:** [September 15, 2015, 7:14pm UTC](https://forums.powershell.org/t/prompt-for-password-new-user/4884/1 "2015-09-15T19:14:04Z")

</div>

Hi.

im really new at PS and trying to create a command/script that prompt me ech time for user account password when i run below command.  
Running PS 5 on Windows 2012 R2

Like  
New-ADUser -Name sccmadmin -GivenName sccm -surname admin -DisplayName configadmin -Path “ou=Users,ou=cgmt,DC=cgmt,dc=int” | Set-ADAccountPassword SCCMAdmin | -AccountPassword (Read-Host -AsSecureString “AccountPassword”)

Get error

-AccountPassword : The term ‘-AccountPassword’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name,  
or if a path was included, verify that the path is correct and try again.  
At line:1 char:160

- … ,dc=int" | Set-ADAccountPassword SCCMAdmin | -AccountPassword (Read-H …
- 

```
                                             ~~~~~~~~~~~~~~~~

```

  - CategoryInfo : ObjectNotFound: (-AccountPassword:String) , CommandNotFoundException
  - FullyQualifiedErrorId : CommandNotFoundException

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [September 15, 2015, 7:17pm UTC](https://forums.powershell.org/t/prompt-for-password-new-user/4884/2 "2015-09-15T19:17:32Z")

</div>

Well, Read-Host will work, as you’ve got it, right?

---

<div class="post-metadata">

**Author:** ![roger-ohlsson](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@roger-ohlsson](https://forums.powershell.org/u/roger-ohlsson)\
**Post date:** [September 15, 2015, 7:26pm UTC](https://forums.powershell.org/t/prompt-for-password-new-user/4884/3 "2015-09-15T19:26:47Z")

</div>

Please see my added error message

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [September 15, 2015, 7:42pm UTC](https://forums.powershell.org/t/prompt-for-password-new-user/4884/4 "2015-09-15T19:42:09Z")

</div>

That’s a syntax error.

```
Set-ADAccountPassword SCCMAdmin | -AccountPassword (Read-Host -AsSecureString "AccountPassword")
```

You’ve put a pipe character in the middle of the command, which cases the shell to try and treat -AccountPassword as a new command, which it isn’t. Remove the pipe character.

---

<div class="post-metadata">

**Author:** ![roger-ohlsson](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@roger-ohlsson](https://forums.powershell.org/u/roger-ohlsson)\
**Post date:** [September 15, 2015, 8:35pm UTC](https://forums.powershell.org/t/prompt-for-password-new-user/4884/5 "2015-09-15T20:35:57Z")

</div>

Run it  
New-ADUser -Name sccmadmin -GivenName sccm -surname admin -DisplayName configadmin -Path “ou=Users,ou=cgmt,DC=cgmt,dc=int” | Set-ADAccountPassword SCCMAdmin -AccountPassword (Read-Host -AsSecureString “AccountPassword”)

Get error

Set-ADAccountPassword : A parameter cannot be found that matches parameter name ‘AccountPassword’.  
At line:1 char:158

- … mt,dc=int" | Set-ADAccountPassword SCCMAdmin -AccountPassword (Read-H …
- 

```
                                             ~~~~~~~~~~~~~~~~

```

  - CategoryInfo : InvalidArgument: (🙂 [Set-ADAccountPassword], ParameterBindingException
  - FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.SetADAccountPassword

---

<div class="post-metadata">

**Author:** ![max-kozlov](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@max-kozlov](https://forums.powershell.org/u/max-kozlov)\
**Post date:** [September 15, 2015, 8:47pm UTC](https://forums.powershell.org/t/prompt-for-password-new-user/4884/6 "2015-09-15T20:47:57Z")

</div>

Set-ADAccountPassword doesn’t have -AccountPassword parameter  
[http://go.microsoft.com/fwlink/?LinkID=144999](http://go.microsoft.com/fwlink/?LinkID=144999)

it have -NewPassword (and [hint] -Reset switch)

---

<div class="post-metadata">

**Author:** ![roger-ohlsson](https://avatars.discourse-cdn.com/v4/letter/r/34f0e0/32.png) [@roger-ohlsson](https://forums.powershell.org/u/roger-ohlsson)\
**Post date:** [September 15, 2015, 8:56pm UTC](https://forums.powershell.org/t/prompt-for-password-new-user/4884/7 "2015-09-15T20:56:43Z")

</div>

i solve it with a set-variabel -name

New-ADUser -Name sccmadmin -GivenName sccm -surname admin -DisplayName configadmin -Path “ou=Users,ou=cgmt,DC=cgmt,dc=int” | Set-ADAccountPassword SCCMAdmin | Set-Variable -Name AccountPassword (Read-Host -AsSecureString “AccountPassword”)

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:44pm UTC](https://forums.powershell.org/t/prompt-for-password-new-user/4884/8 "2024-05-16T20:44:47Z")

</div>


