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

Popular posts from this blog

Motherboard replacement

Remote Desktop App - Error 0x207 or 0x607

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state