The simplest way would be to use the CMDLET in a single line, because it treats them as if they were foreign commands, and the second way if you want to leave it curious, would be to add the symbol ` so that the cmdlet detects that it continues in the next line
The first way:
$secPassword = Read-Host "Password" -AsSecureString
New-ADUser -Name "XYZ ABC" -SamAccountName xyz.a -UserPrincipalName "[email protected]" -AccountPassword $secPassword -Path "cn=Users,dc=ntsh,dc=local" -Enabled:$true -PasswordNeverExpires:$true -CannotChangePassword:$true -PasswordNotRequired:$false -ChangePasswordAtLogon:$false
The second way:
$secPassword = Read-Host "Password" -AsSecureString
New-ADUser -Name "XYZ ABC" `
-SamAccountName xyz.a `
-UserPrincipalName "[email protected]" `
-AccountPassword $secPassword `
-Path "cn=Users,dc=ntsh,dc=local" `
-Enabled:$true `
-PasswordNeverExpires:$true `
-CannotChangePassword:$true `
-PasswordNotRequired:$false `
-ChangePasswordAtLogon:$false
-SamAccountName xyz.a. You need to quote the value, so-SamAccountName 'xyz.a'. Anyway, zett42 is correct. You should always use splatting on cmdlets that take a lot of parameters IMO.New-ADUser `