0
我有一個使用AD模塊進行某些操作的腳本。PowerShell導入模塊腳本異常
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命令。如果你能夠闡明這一點,我會非常感激!