我正在尝试Active Directory
从特定的Organization Unit
using中获取所有电子邮件和用户名powershell
。这是我的代码:
function Invoke-CmdCommand {
Param(
[parameter(position = 0)]
$Cmd ,
[parameter(position = 1)]
$RunFolder = $PSScriptRoot
)
try {
$cmdToRun = "cmd /c cd `"$RunFolder`" `"&`" $Cmd";
Write-Host "$RunFolder> $Cmd";
Invoke-Expression "& $($cmdToRun.Replace("^","^^"))";
}
catch {
Write-Error "********** Function $($MyInvocation.MyCommand.Name) failed **********";
Write-Error $_.Exception.Detail.InnerText;
exit 1;
}
}
$cmd = "dsquery user `"OU=Disabled Users,DC=microfinancial,DC=com`" -limit 10000 | dsget user -samid -email"
$test = Invoke-CmdCommand -Cmd $cmd
我收到以下错误:
dsget 失败:“此命令的目标对象”的值格式不正确。输入 dsget /? 求助。
我能做些什么?