Hello All,
New here.
I am trying to get a prompt so that the user can type $true or $flase if they wanted the account to enabled or disabled, i got it working as INT using number 0 or 1 but not as $true or $false, can you please help?
param( [switch]$enabled = $( Read-Host "input 0 or 1" ), [Parameter(Mandatory=$True, HelpMessage="Enter the name")] [ValidateNotNullOrEmpty()] [string]$name, [Parameter(Mandatory=$True, HelpMessage="Enter the Given name")] [ValidateNotNullOrEmpty()] [string]$GivenName, [Parameter(Mandatory=$True, HelpMessage="Enter the Surname")] [ValidateNotNullOrEmpty()] [string]$Surnmae, [Parameter(Mandatory=$True,HelpMessage="Enter the Account name")] [ValidateNotNullOrEmpty()] [string]$Accountname, [Parameter(Mandatory=$True, HelpMessage="Enter the User Principle name, has to be first initial[dot]lastname e.g 'M.test'")] [ValidatePattern("[a-z]*")] [string][ValidateLength(3,15)]$UPN = 02 ) #Imports AD Moudle Import-Module ActiveDirectory #This script lets you create AD user accounts New-ADUser -Name $name -GivenName $GivenName -Surname $Surname -SamAccountName $Accountname -UserPrincipalName $UPN -Path "OU=test,DC=test,DC=local" -AccountPassword(Read-Host -AsSecureString "Input Password") -Enabled $enabled