Thanks Michael!
Wish ms had a publicly available bug searching tool, life would be so much 
easier...
jlc

-----Original Message-----
From: Michael B. Smith [mailto:[email protected]] 
Sent: Tuesday, September 06, 2011 6:59 AM
To: NT System Admin Issues
Subject: RE: Powershell help

It is indeed an error, and has been bugged. The work around:

        $saveEAP = $ErrorActionPreference
        $ErrorActionPreference = 'SilentlyContinue'
        Get-ADOrganizationalUnit .......
        $cmdResult = $?
        $ErrorActionPreference = $saveEAP

        ## now test $cmdResult as you may have tested $? In the past.

Regards,

Michael B. Smith
Consultant and Exchange MVP
http://TheEssentialExchange.com


-----Original Message-----
From: Joseph L. Casale [mailto:[email protected]]
Sent: Tuesday, September 06, 2011 6:57 AM
To: NT System Admin Issues
Subject: RE: Powershell help

Probably more to do with my inexperience; Get-Content acts like the parameters 
suggest for -ea 0|3.
Get-ADOrganizationalUnit bails out in a display of glorious red no matter how 
you attempt to deal with it if the OU doesn't exist.

jlc

-----Original Message-----
From: Michael B. Smith [mailto:[email protected]]
Sent: Monday, September 05, 2011 6:13 AM
To: NT System Admin Issues
Subject: RE: Powershell help

I'd like to know which cmdlets (from Microsoft) don't work as expected with EA. 
<CommonParameters> are implemented by PowerShell itself, not the individual 
cmdlet.

Now, whether something works with try/catch/finally or not gets quite weird, 
and has to do with the difference between terminating and non-terminating 
errors.

Regardless, I'm glad you got it to work. :-)

Regards,

Michael B. Smith
Consultant and Exchange MVP
http://TheEssentialExchange.com


-----Original Message-----
From: Joseph L. Casale [mailto:[email protected]]
Sent: Sunday, September 04, 2011 7:13 PM
To: NT System Admin Issues
Subject: RE: Powershell help

Unfortunately, not all cmdlets work as expected with ea. Some ignore the stop 
or inquire params.
I simply rethought how the should be done and the script works as expected.
Thanks,
jlc

-----Original Message-----
From: Webster [mailto:[email protected]]
Sent: Saturday, September 03, 2011 8:17 PM
To: NT System Admin Issues
Subject: RE: Powershell help

Try adding -ea 0  to the end of your stmt.  ea means ErrorAction.  Google that.

Carl Webster

Consultant and Citrix Technology Professional

http://www.CarlWebster.com

________________________________________
From: Joseph L. Casale [[email protected]]
Sent: Saturday, September 03, 2011 8:45 PM
To: NT System Admin Issues
Subject: Powershell help

Guys,
I am sure the answer here is simple, but what's an elegant way to handle the 
case where I need to test if an OU exists:
Get-ADOrganizationalUnit -Identity "ou=$someOU,$root"
and mask the error and simply bail or proceed on with my script.

Using try/catch and if/! I am not crafting an elegant way to simply halt 
without producing error...

Thanks!
jlc

~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ 
<http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to 
[email protected]<mailto:[email protected]>
with the body: unsubscribe ntsysadmin



~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ 
<http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin


~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ 
<http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin


~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ 
<http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin


~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ 
<http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin


~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ 
<http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin


~ Finally, powerful endpoint security that ISN'T a resource hog! ~
~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/>  ~

---
To manage subscriptions click here: 
http://lyris.sunbelt-software.com/read/my_forums/
or send an email to [email protected]
with the body: unsubscribe ntsysadmin

Reply via email to