不能再导入任何模块
Can no longer Import Any Modules
近 5 个月来,我每天都在使用 PowerShell,特别是 Active Directory 模块。今天去导入模块,报错:
PS H:\> import-module activedirectory
import-module : The assembly 'Microsoft.ActiveDirectory.Management' was not loaded because no assembly with that name was found. Verify the assembly name, and then try again.
At line:1 char:1
+ import-module activedirectory
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Import-Module], DllNotFoundException
+ FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
我已经用谷歌搜索了几个小时,但我仍然不知道发生了什么。我的电脑没有任何变化,我没有安装任何新软件、模块或补丁。所有 AD Windows 功能均已启用,并且我已重新启动多次。如果我 运行 Get-Module
,ActiveDirectory 显示:
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0.0.0 ActiveDirectory
我以前从未见过这样的事情,所以我一直在执行我能在 Google 上找到的每个步骤。
这是我到目前为止所做的:
- 重启一百万次
- 已尝试 运行在提升的 Windows 中执行命令(仍然失败)
我可以通过CMD成功运行 powershell -importsystemmodules
Import-Module : The specified module 'activedirectory' was not loaded because no valid module file was found in any module directory
我在这个位置有 AD 模块:C:\Windows\System32\WindowsPowerShell\v1.0\Modules\ActiveDirectory
,还有文档(我不确定它是否应该在这两个位置,这正是我找到的)。
PS C:\Windows> dism /online /Get-FeatureInfo /FeatureName:RemoteServerAdministrationTools-Roles-AD-Powershell
Deployment Image Servicing and Management tool
Version: 6.1.7600.16385
Image Version: 6.1.7601.18489
Feature Information:
Feature Name : RemoteServerAdministrationTools-Roles-AD-Powershell
Display Name : Active Directory Module for Windows PowerShell
Description : Active Directory Module for Windows PowerShell provides a centralized experience for administering directory service objects.
Restart Required : Possible
State : Enabled
Custom Properties:
(No custom properties found)
就像我说的,我没有在我的电脑上做任何改变。我什至几天都没有重新启动。我今天早上还在用,今天下午就没用了。
卸载、重新安装和重新配置 Active Directory 可以修复它。由于某种原因,它两次卸载失败,一次安装失败,我不得不在 "Turn Windows Features on or off" 中配置它四次,因为它会说它接受了更改,但重新启动后,它们就会消失。
附带说明一下,我也认为我知道导致问题的原因。当天早些时候,我正在编写一个脚本来删除安全 outlook 文件夹中的文件。我不是 运行 作为管理员,所以它不应该做任何事情,但由于某种原因它开始循环系统文件。我收到了一百万条 "Access Denied" 条消息,但我想知道它是否设法在它停止之前删除了对 Active Directory 模块至关重要的文件。
近 5 个月来,我每天都在使用 PowerShell,特别是 Active Directory 模块。今天去导入模块,报错:
PS H:\> import-module activedirectory
import-module : The assembly 'Microsoft.ActiveDirectory.Management' was not loaded because no assembly with that name was found. Verify the assembly name, and then try again.
At line:1 char:1
+ import-module activedirectory
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Import-Module], DllNotFoundException
+ FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand
我已经用谷歌搜索了几个小时,但我仍然不知道发生了什么。我的电脑没有任何变化,我没有安装任何新软件、模块或补丁。所有 AD Windows 功能均已启用,并且我已重新启动多次。如果我 运行 Get-Module
,ActiveDirectory 显示:
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0.0.0 ActiveDirectory
我以前从未见过这样的事情,所以我一直在执行我能在 Google 上找到的每个步骤。
这是我到目前为止所做的:
- 重启一百万次
- 已尝试 运行在提升的 Windows 中执行命令(仍然失败)
我可以通过CMD成功运行 powershell -importsystemmodules
Import-Module : The specified module 'activedirectory' was not loaded because no valid module file was found in any module directory
我在这个位置有 AD 模块:C:\Windows\System32\WindowsPowerShell\v1.0\Modules\ActiveDirectory
,还有文档(我不确定它是否应该在这两个位置,这正是我找到的)。
PS C:\Windows> dism /online /Get-FeatureInfo /FeatureName:RemoteServerAdministrationTools-Roles-AD-Powershell
Deployment Image Servicing and Management tool
Version: 6.1.7600.16385
Image Version: 6.1.7601.18489
Feature Information:
Feature Name : RemoteServerAdministrationTools-Roles-AD-Powershell
Display Name : Active Directory Module for Windows PowerShell
Description : Active Directory Module for Windows PowerShell provides a centralized experience for administering directory service objects.
Restart Required : Possible
State : Enabled
Custom Properties:
(No custom properties found)
就像我说的,我没有在我的电脑上做任何改变。我什至几天都没有重新启动。我今天早上还在用,今天下午就没用了。
卸载、重新安装和重新配置 Active Directory 可以修复它。由于某种原因,它两次卸载失败,一次安装失败,我不得不在 "Turn Windows Features on or off" 中配置它四次,因为它会说它接受了更改,但重新启动后,它们就会消失。
附带说明一下,我也认为我知道导致问题的原因。当天早些时候,我正在编写一个脚本来删除安全 outlook 文件夹中的文件。我不是 运行 作为管理员,所以它不应该做任何事情,但由于某种原因它开始循环系统文件。我收到了一百万条 "Access Denied" 条消息,但我想知道它是否设法在它停止之前删除了对 Active Directory 模块至关重要的文件。