Greetings folks,
I always have to turn to you guys when I have tough questions.
With try and catch statements, can you test multiple statements?
For example, I want to test two statements.
try
{
$machine = Get-ADObject "CN=syssec-$servername,OU=servers,OU=NISNetgroups,OU=Applications,DC=company,DC=com"; $machine = Get-ADObject "CN=syssec-$servername,OU=WindowsServers,OU=Groups,DC=company,DC=com"
}
catch {$machine = $null; Write-Host "AD Object syssec-$servername not found"}
When I run this code, it will execute but it won't evaluate the second statement.
Your thoughts?
Thanks,
M