我在Windows Server 2012 R2上使用PowerShell 4。
在调用来自此模块的Cmdlet时,特定模块WebAdministration不会自动加载。我试过的所有其他模块成功自动加载。我可以使用Import-Module手动加载此模块,它的行为符合预期。
PSModulePath =%SystemRoot%\ system32 \ WindowsPowerShell \ v1.0 \ Modules \ 网络管理模块路径 = C:\ Windows \ System32 \ WindowsPowerShell \ v1.0 \ Modules \ WebAdministration
简单测试的输出
PS C:\ Users \ Administrator> $ PSModuleAutoLoadingPreference =“全部”
PS C:\ Users \ Administrator>得到-WebBinding Get-WebBinding:术语“Get-WebBinding”不被识别为cmdlet,函数,脚本文件或可操作程序的名称。检查拼写 如果包含名称,或者包含路径,请验证路径是否正确,然后重试。 在行:1个字符:1 + Get-WebBinding + ~~~~~~~~~~~~~~ + CategoryInfo:ObjectNotFound:(Get-WebBinding:String)[],CommandNotFoundException + FullyQualifiedErrorId:CommandNotFoundException
PS C:\ Users \ Administrator>导入模块Web管理
PS C:\ Users \ Administrator>得到-WebBinding
protocol bindingInformation sslFlags -------- ------------------ -------- http *:8082:0 http *:8081:0
任何有关自动加载不起作用的建议都将不胜感激。谢谢!
答案 0 :(得分:0)
尝试重新安装模块以查看是否有作用。
如果这行不通,但令人烦恼的是自动加载功能无法正常运行,则可以在使用模块之前导入该模块,并期望它能够正常工作。
Import-Module WebAdministration
Get-WebBinding
或者如果您需要单线:
Import-Module WebAdministration; Get-WebBinding