Windows PowerShell导入模块脚本异常
我有一个脚本,它使用AD模块进行一些操作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
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