Thanks guys! ________________________________________ From: Brian Desmond [br...@briandesmond.com] Sent: Tuesday, April 03, 2012 4:13 PM To: NT System Admin Issues Subject: RE: Powershell question
How about something like this. You can figure out what $value1 and $value2 should look like (could just be your Test-Path calls or maybe the function is registry aware...). [bool]function XorValues($value1, $value2, [ref]$outputVal) { if ($value1 -xor $value2) { If ($value1) { $outputVal = $value1 return $true } If ($value2) { $outputVal = $value2 return $true } } else { return $false } } Thanks, Brian Desmond br...@briandesmond.com w - 312.625.1438 | c - 312.731.3132 -----Original Message----- From: Joseph L. Casale [mailto:jcas...@activenetwerx.com] Sent: Tuesday, April 03, 2012 4:27 PM To: NT System Admin Issues Subject: Powershell question Hey guys, What is the most elegant way to -xor test two paths and keep the one that exists? I have a bunch of cases where I check for the existence of two reg keys (both can not co-exist) and then set a variable based on either one. If ((Test-Path "hklm:\..." ) -xor (Test-Path "hklm:\..." )) { $var = value1 or value2 } Else { <must exit the script> } is the logic I need, but then I need additional code to set a single variable to value1 or value2. Not a big deal once, but I have several and I was just hoping for a slick way to accomplish setting $var to either value based on which side tests true w/o another if block. 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 listmana...@lyris.sunbeltsoftware.com 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 listmana...@lyris.sunbeltsoftware.com 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 listmana...@lyris.sunbeltsoftware.com with the body: unsubscribe ntsysadmin