从 powershell 模块重新签名、重新加载和运行测试功能? [英] Re-signing, Reloading, and running a test function from a powershell module?

查看:50
本文介绍了从 powershell 模块重新签名、重新加载和运行测试功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天正在编写一些 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?

推荐答案

根据此https:///technet.microsoft.com/library/hh849725.aspx导入模块时,您可能需要使用 -force 参数.这将强制移除模块,然后再次添加.

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

这篇关于从 powershell 模块重新签名、重新加载和运行测试功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆