Reputation: 11
While running a powershell script, I am getting the following error:
Error provided :
The 'New-SmbMapping' command was found in the module 'SmbShare', but the module could not be loaded. For more information, run 'Import-Module SmbShare'.
However, SMB-Share is already there in system and Get-SmbShare, Remove-SmbShare, New-SMBShare works if called directly in console.
[Note] Powershell Information :
1)Running Powershell version as administrator: Major:5 Minor:1 Build:18362 Revision:752
2)Running the code in windows 10 pro.
Upvotes: 1
Views: 945
Reputation: 13483
Add to the beginning of your script:
Import-Module SmbShare
The commands are available in your console because PowerShell auto imports them for you. Inside a script, it doesn't auto import the module. You have to explicitly import the module for the cmdlets to be available.
Upvotes: 1