Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows PowerShell导入模块脚本异常_Windows_Exception_Powershell_Module - Fatal编程技术网

Windows PowerShell导入模块脚本异常

Windows PowerShell导入模块脚本异常,windows,exception,powershell,module,Windows,Exception,Powershell,Module,我有一个脚本,它使用AD模块进行一些操作 Import-Module ActiveDirectory $username=$env:username $computerName=$env:computername $userProperties = Get-ADUser $username $departmentOU = ($userProperties.DistinguishedName -split ',OU=')[1] $officeOU=($userProperties.Distin

我有一个脚本,它使用AD模块进行一些操作

Import-Module ActiveDirectory

$username=$env:username
$computerName=$env:computername

$userProperties = Get-ADUser $username
$departmentOU = ($userProperties.DistinguishedName -split ',OU=')[1]
$officeOU=($userProperties.DistinguishedName -split ',OU=')[2]
$pathOutUser = "C:\Scripts\UsAer_Logger\Output\$officeOU\$departmentOU.txt"

if (Test-Path $pathOutUser) {
    $computerName >> $pathOutUser
} else {
    New-Item $pathOutUser
    $computerName >> $pathOutUser
}
当我尝试在PowerShell ISE上运行它时,会出现以下异常:

Import-Module : The following error occurred while loading the extended type da
ta file: 
Microsoft.PowerShell, C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Active
Directory\ActiveDirectory.Types.ps1xml : File skipped because it was already pr
esent from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Active
Directory\ActiveDirectory.Types.ps1xml : File skipped because it was already pr
esent from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Active
Directory\ActiveDirectory.Types.ps1xml : File skipped because it was already pr
esent from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Active
Directory\ActiveDirectory.Types.ps1xml : File skipped because it was already pr
esent from "Microsoft.PowerShell".
Microsoft.PowerShell, C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Active
Directory\ActiveDirectory.Types.ps1xml : File skipped because it was already pr
esent from "Microsoft.PowerShell".

我尝试在没有导入模块cmdlt的情况下运行它,但它无法识别Get ADUser命令。如果你能解释一下,我会非常感激的

您可能安装了两个不同的ActiveDirectory模块副本。尝试检查已安装的模块列表:

Get-Module -list
如果存在冲突,则应卸载模块:

Remove-Module ActiveDirectory