Function vs Function in module
i have function this:
function x { $path = 'c:\asdasd' try { [system.io.directory]::enumeratefiles($path, '*.pst') } catch { write-output "!!!error!!! : $($error[0].fullyqualifiederrorid) : $path" #$error.remove($error[0]) } }
when run output expected:
ps c:\temp> x !!!error!!! : directorynotfoundexception : c:\asdasd
now, put function in module ( .psm1 file ) , import module...
ps c:\temp> import-module .\module.psm1 -forceps ps c:\temp> x !!!error!!! : : c:\asdasd
as can see the $error[0].fullyqualifiederrorid not displayed!
does know why happens?
pedro casalinho
function x { $path = 'c:\asdasd' try { [system.io.directory]::enumeratefiles($path, '*.pst') } catch { "!!!error!!! : $($_.fullyqualifiederrorid) : $path" #write-error "!!!error!!! : $($_.fullyqualifiederrorid) : $path" } }
Windows Server > Windows PowerShell
Comments
Post a Comment