Powershell Try&Catch Run multiple commands inside try -


hi trying figure out how or way of doing it

try { get-adcomputer -identity namedoesnotexist (get-childitem).fullname } catch {$_ | out-file log.log} 

when running code using name not exist error , catch write logfile (just example) want accomplish error catched try statement continues run get-childitem command , tries too. other simple way of doing this?

put 1 line in try..catch give effect

try  {   get-adcomputer -identity namedoesnotexist } catch  {   $_ | out-file log.log } (get-childitem).fullname 

but maybe trap looking for

trap {   $_ | out-file log.log   continue # remove if still want see each error } get-adcomputer -identity namedoesnotexist (get-childitem).fullname 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -