【问题标题】:The 'New-SmbMapping' command was found in the module 'SmbShare', but the module could not be loaded在模块“SmbShare”中找到“New-SmbMapping”命令,但无法加载该模块
【发布时间】:2020-04-25 16:49:25
【问题描述】:

在运行 powershell 脚本时,我收到以下错误:

提供错误:

The 'New-SmbMapping' command was found in the module 'SmbShare', but the module could not be loaded. For more information, run 'Import-Module SmbShare'.

但是,SMB-Share 已经存在于系统中,如果直接在控制台中调用 Get-SmbShare、Remove-SmbShare、New-SMBShare,则可以正常工作。

[注意] Powershell 信息:

1)Running Powershell version as administrator: Major:5 Minor:1  Build:18362  Revision:752

2)Running the code in windows 10 pro.

【问题讨论】:

    标签: powershell windows-10 azure-powershell powershell-5.0 windows-scripting


    【解决方案1】:

    添加到脚本的开头:

    Import-Module SmbShare
    

    这些命令在您的控制台中可用,因为 PowerShell 会为您自动导入它们。在脚本中,它不会自动导入模块。您必须显式导入模块才能使 cmdlet 可用。

    【讨论】:

    • 感谢 HAL9256,但我已经将它导入并可用了。但是,我确实输入了导入语句,但无法再次加载,它给出了同样的错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-03-07
    • 2019-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-30
    相关资源
    最近更新 更多