【发布时间】:2014-07-02 15:58:39
【问题描述】:
我有一个使用 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".
我尝试在没有 Import-Module cmdlt 的情况下运行它,但它无法识别 Get-ADUser 命令。如果您能对此有所了解,我将不胜感激!
【问题讨论】:
标签: windows exception powershell module