I was coding some PowerShell modules today, and I noticed that it would be more efficient to re-sign the module, reload it, and run a test function in one go, on a single line in the command line.
However...when I go to reload the module it doesn't appear to do so...
PS C:\> Set-AuthenticodeSignature "\\serv\Redirected\yy-xxxx\My Documents\WindowsPowerShell\dazFunctions.psm1" @(Get-ChildItem cert:\CurrentUser\My -codesign)[0]; Import-Module
"\\serv\Redirected\yy-xxxx\My Documents\WindowsPowerShell\dazFunctions.psm1"; Test-FunctionCall -File \\a-pc\c$\
Users\userguy\NTUSER.DAT
And the changes to my script are not included. They should be because I reloaded it in the second command listed above....right?
According to this https://technet.microsoft.com/library/hh849725.aspx
You may need to use the -force parameter when importing the module. This will force the module to be removed then added again.
PS C:\> Set-AuthenticodeSignature "\\serv\Redirected\yy-xxxx\My Documents\WindowsPowerShell\dazFunctions.psm1" @(Get-ChildItem cert:\CurrentUser\My -codesign)[0]; Import-Module
"\\serv\Redirected\yy-xxxx\My Documents\WindowsPowerShell\dazFunctions.psm1" -Force; Test-FunctionCall -File \\a-pc\c$\Users\userguy\NTUSER.DAT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With