Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

PowerShell prompt for a command is not a valid command

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

To the task, due to the Windows server version to upgrade: 2008-> 2016, so we need to do a lot of preparatory work, such as OU, GPO. Because the OU is divided into several hundred OU, you need to create all the OU that already exist under 2008OU under 2016OU. Then use PowerShell to do it! But found a 2008 server, run the command Get-ADOrganizationalUnit this PowerShell, I went, unexpectedly prompted me that I was not a valid command, the error details are as follows:

Strangely, it can be used on another server before. At first, I wonder if the PowerShell version is too low. Just check:

PS C:\ Users\ admin > $PSVersionTableName Value- -PSVersion 5.1.14393.2515 PSEdition Desktop PSCompatibleVersions {1.0 2.0, 3.0 4.0...} BuildVersion 10.0.14393.2515 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

Version 5.1, not very old! OK, let's see if there is an AD module. After all, this command is an operation on AD. Run: get-module-listavailable enter, walk you, take a look at the results. I see. There is no AD module visually.

Then import it and run:

PS C:\ Windows\ system32 > Add-WindowsFeature RSAT-AD-PowerShell and then run a get-module. Take a look, ActiveDirectory loads PS C:\ Windows\ system32 > get-module-listavailable

RSAT = Remote Server Administrator Tools

Finally, run the command: PS C:\ Windows\ system32 > Get-ADOrganizationalUnit, no longer report an error, and prompt for parameters, just click on it.

I also tried another method on another server:

First run: get-module-listavailable to see if the ActiveDirectory module has been loaded.

And then run it directly: import-module activedirectory

If there is no error, run it again: get-module-listavailable

At this point, the ActiveDirectory module is imported, and you can start using the AD-related PowerShell commands.

The term 'Get-ADOrganizationalUnit' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.At line:5 char:38+ $SVSOUList = Get-ADOrganizationalUnit

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report