ActiveDirectory with Powershell 7 on Windows Server 2016

Phuc Mai 136 Reputation points
2021-03-02T13:47:31.993+00:00

Hello,

I get this error when I run Import-Module -Name ActiveDirectory on Powershell 7:

WARNING: Module ActiveDirectory is loaded in Windows PowerShell using WinPSCompatSession remoting session; please note that all input and output of commands from this module will be deserialized objects. If you want to load this module into PowerShell please use 'Import-Module -SkipEditionCheck' syntax.

The suggested -SkipEditionCheck parameter also does not work:

Import-Module: Could not load type 'System.Management.Automation.PSSnapIn' from assembly 'System.Management.Automation, Version=7.1.1.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxx'.

My ps1 script does not work with deserialized objects. A hint from https://github.com/PowerShell/PowerShell/issues/12907 suggests that I need the module from Windows Server 2019.

Is there a way to upgrade the ActiveDirectory module without upgrading Windows Server? Or is there a way to import the module "correctly" into Powershell 7?

Thank you.

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
5,857 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,364 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 29,651 Reputation points Microsoft Vendor
    2021-03-03T07:23:14.133+00:00

    Hi,

    The ActiveDirectory module is only compatible with PowerShell 7 on Windows Server 1809+. You have to use Windows PowerShell 5.1 on Windows Server 2016.

    PowerShell 7 module compatibility

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Rich Matheisen 44,776 Reputation points
    2021-03-02T21:04:31.04+00:00

    Note that PowerShell 7 is not Windows PowerShell 7. It's a cross-platform version of PowerShell and you're going to find a lot of things that are different. Some of the differences will be good; others not so good. Deserialized objects are one of the not-so-good things.

    0 comments No comments