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.

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    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 47,901 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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.