- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
潜伏了很长时间,但我终于找到了一个找不到答案的问题,因此我决定该加入了。我正在尝试收集早于X天($ DelCompDays)的AD中的计算机列表。然后根据DistinguishedName字段,使用Identity标志删除该计算机。问题甚至出现在域管理员的凭据中:Remove-ADComputer:访问被拒绝
即使我运行Remove-ADComputer -Identity“全名CN或简称”,我也会被拒绝访问。谁有想法?先感谢您!
#Get AD computers older than $DelCompDays
$results = Search-ADAccount -ComputersOnly -AccountInactive -TimeSpan "$DelCompDays.00:00:00"
#Loop and try to delete
foreach ($result in $results){
if ($result -ne $NULL){
try {
Remove-ADComputer -Identity $result.DistinguishedName -confirm:$false
$Success = "Deleted: $result.DistinguishedName"
WriteCustomOutput -message "$Success" -foregroundcolor green -backgroundcolor DarkMagenta
}
catch {
$Error = "Failed to delete: $result.DistinguishedName"
WriteCustomOutput -message "$Error" -foregroundcolor Red -backgroundcolor Black
}
}
else{
$Warning = "No computers older than $ArcDays days to delete"
WriteCustomOutput -message "$Warning" -foregroundcolor yellow -backgroundcolor DarkMagenta
}
}
最佳答案
弄清楚了。当以非交互方式运行时,您需要在命令调用中指定凭据。
$secpasswd = ConvertTo-SecureString "ClearTextPass" -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential ("Username", $secpasswd)
Remove-ADComputer -Identity $result.DistinguishedName -Recursive -confirm:$false -credential $creds
关于powershell - Remove-ADComputer:拒绝访问Powershell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24049049/
这个问题在这里已经有了答案: Powershell - Filtering OUs while using get-adcomputer (2 个答案) 关闭 8 年前。 使用事件目录模块,我需要获
我试图创建一个 powershell 脚本,它允许我通过它在 AD 中的服务标签找到正确的计算机。到目前为止,我可以通过在脚本中编写服务标签来完成,但是当我想用变量传递它时,它不允许我这样做,并显示此
潜伏了很长时间,但我终于找到了一个找不到答案的问题,因此我决定该加入了。我正在尝试收集早于X天($ DelCompDays)的AD中的计算机列表。然后根据DistinguishedName字段,使用I
我是 Powershell 的新手,在使用 Get-ADUser 和 GetADComputer cmdlet 时遇到问题。 我正在尝试使用 Get-ADComputer 和 Get-ADUser 从
我刚刚开始使用 AD 研究 PowerShell,所以如果这个问题看起来很明显,我深表歉意。 我正在尝试检查列表中提供的哪些设备是否在 AD 中。到目前为止,我使用的代码来自: Powershell
我想要获取我的域中所有已启用且具有 2003 操作系统的计算机,并且计算机名称不包含“ping 、 pict 、 pire ”这是我所拥有的,但完全失败了: Get-ADComputer -filte
尝试列出所有计算机及其属于另一个受信任域的操作系统信息,但 OperatingSystem 和 OperatingSystemVersion 返回空值: Get-ADComputer -Filter
我正在使用下面的代码通过 Get-ADComputer 获取 Active Directory 信息,它工作正常 $computersFilter= "(&(operatingSystem=*Wind
我在 PowerShell 脚本中偶然发现了一个奇怪的错误,该脚本为我返回特定 OU(和子 OU)中 Active Directory 中的计算机,这些计算机在特定日期内启用并登录。 以下代码段确实有
我正在尝试从CSV文件禁用PC,但是我一直收到以下错误消息。 当我手动将设备列表复制到文本文件(记事本)中时,该代码有效 谢谢 Get-ADComputer : Cannot find an obje
我是一名优秀的程序员,十分优秀!