Andrew John
Andrew John

Reputation: 1

PowerShell V6 SmbShare commands returning error ... is not recognized as the name of a cmdlet, function, script file, or operable program

I'm new to PowerShell, so this may be a basic oversight. On windows 10 pro (for development) and Windows Server 2016 (target environment) I have installed the latest released version of PowerShell.

(Get-Host).Version gives Major 6, Minor 1, Build 0, Revision -1.

My first mistake? as a version of PowerShell is already installed by default?

The process I am trying to automate is to share a backup cartridge drive from host physical machines, and access it as a network share for the VMs (Hyper-V) to backup to. In development I'm just using a USB attached drive, but errors are the same in both environments.

I keep getting errors in any of the SMBShare commands :

Get-SmbShare, Remove-SmbShare, New-SMBShare.

The errors are of the format:

"The term 'Get-SmbShare' is not recognized as the name of a cmdlet, function, script file, or operable program"

I am running Powershell as administrator, and getting the same errors when typing directly, or from running a script.

Is there something I need to add/import to use SMBShare commands ?

Upvotes: 0

Views: 6432

Answers (1)

TessellatingHeckler
TessellatingHeckler

Reputation: 29033

PowerShell has fractured; everything up to v5.1 was Windows only, then v6 was made cross-platform by moving it to a new foundation, and that lost a lot of compatibility.

Your easiest way forward is to use PowerShell 5.1, unless you need v6 for some specific feature. Or to use 6 to launch 5.1 and run a script, the same way you might launch Python or VBScript engines to run a script.

But if you are staying with 6, then there is another option - Microsoft have released a WindowsCompatibility Module - still an early release candidate, so not heavily tested. This brings a way to run Windows modules inside PS v6 (only on Windows, not cross platform).

You would need to install it, with this as an administrator:

Install-Module WindowsCompatibility

Then you can:

Import-Module WindowsCompatibility
Import-WinModule SmbShare
Get-SmbShare

Upvotes: 1

Related Questions