
Also try to avoid testing for a null variable as an error condition:
````
$user = Get-ADUser -Identity DonJ
if ($user) {
$user | Do-Something}
Else [
Write-Warning “Could not get user $user”
}````
There are times and technologies where that’s the only approach that will work, especially if the command you’re running won’t produce a terminating, trappable exception. But it’s a logically contorted approach, and it can make debugging trickier.
Describe what you're looking for in as much detail as you'd like.
Our AI reads your request and finds the best matching books for you.
Popular searches:
Join 2 million readers and get unlimited free ebooks