0

New to PS and need some help with $null values, I want to ask the user to set a OU path but if the user enters nothing then it will revert to the default which is in the if statement.

$OU = Read-Host -Prompt "Enter the new users OU path"

if($null -eq $OU)
{
$OU="CN=Users,DC=de,DC=ing,DC=kus,DC=tb"
}
else
{
}
Harry
  • 33
  • 4

1 Answers1

0

Replaced the $null with "" as I was detecting a string.

$OU = Read-Host "Enter the new users OU path"

if ($OU -eq "")
{

    $OU = "CN=Users,DC=**,DC=***,DC=***,DC=**"

}

else
{

}
SCouto
  • 7,808
  • 5
  • 32
  • 49
Harry
  • 33
  • 4