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
Post a Comment