question

PhucMai-8671 avatar image
0 Votes"
PhucMai-8671 asked ·

ActiveDirectory with Powershell 7 on Windows Server 2016

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-server-powershellwindows-active-directory
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered ·

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.


·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered ·

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.

·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.