Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Re-signing, Reloading, and running a test function from a powershell module?

Tags:

powershell

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?

like image 440
leeand00 Avatar asked Jun 23 '26 16:06

leeand00


1 Answers

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
like image 142
Poorkenny Avatar answered Jul 03 '26 03:07

Poorkenny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!