PowerShell for Windows Admins

Aug 23 2018   3:21PM GMT

PowerShell v6.1– using PowerShell v5.1 modules

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Tags:
Powershell

Something new to be aware of in PowerShell v6.1– using PowerShell v5.1 modules.

In PowerShell v6.0.4 the default module path is:

PS> $env:PSModulePath -split ';'
C:\Users\Richard\Documents\PowerShell\Modules
C:\Program Files\PowerShell\Modules
c:\program files\powershell\6.0.4\Modules

If you want to use the netadapter cmdlets for instance to need to explicitly load the module.

Import-Module 'C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\netadapter\netadapter.psd1'

You can then use Get-Netadapter.

There appears to be an issue with PowerShell v6.0.4 as it only displays the interface index, the status and the MAC address!

In PowerShell v6.1 RC1 the module path changes to:

PS> $env:PSModulePath -split ';'
C:\Users\Richard\Documents\PowerShell\Modules
C:\Program Files\PowerShell\Modules
c:\program files\powershell\6-preview\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

In theory you’d expect this to work:

PS> Get-Module -ListAvailable net*
PS> Get-Module -ListAvailable netadapter

But you get nothing back.

Importing the module directly gives:

PS> Import-Module netadapter
Import-Module : Module 'C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\netadapter\netadapter.psd1' does not support current PowerShell edition 'Core'. Its supported editions are 'Desktop'. Use 'Import-Module -SkipEditionCheck' to ignore the compatibility of this module.
At line:1 char:1
+ Import-Module netadapter
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (C:\WINDOWS\syst...netadapter.psd1:String) [Import-Module], InvalidOperationException
+ FullyQualifiedErrorId : Modules_PSEditionNotSupported,Microsoft.PowerShell.Commands.ImportModuleCommand
PS> Import-Module netadapter -SkipEditionCheck
PS> Get-NetAdapter

Works and you see the expected data! Definitely looks like a bug in v6.0.4.

Get-Module also can skip the edition check

Get-Module -ListAvailable net* –SkipEditionCheck

Will display the modules.

If you’re using v6.1 RC 1 AND you want to use PowerShell v5.1 modules you may want to think about using $PsDefaultParameterValues to set SkipEditionCheck on for Get-Module and Import-Module.

This change will more than likely break your scripts.

Using SkipEditionCheck won’t allow you to run a binary module such as Active Directory that’s complied using full .NET

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: