Remove-QADObject in Powershell needs interaction. Needs a way out -
i trying write powershell script delete old advertisement accounts.
it works, when run powershellgui, prompts click yes/no. looked through powergui's remove-qadobject documentation, there no mention of silent mode. know work-around?
# date 6 months ago today. $dateobj = (get-date).adddays(-180) $oldadusers = get-qaduser -searchroot "ou=expired_test,ou=students,dc=..." -accountexpiresbefore $dateobj foreach ($user in $oldadusers) { remove-qadobject $user }
try using -force
, -confirm:$false
. -confirm:$false
tells cmdlet not prompt confirmation. -force
may not required, is. don't have qad-module test if it's required here, won't harm include it.
# date 6 months ago today. $dateobj = (get-date).adddays(-180) $oldadusers = get-qaduser -searchroot "ou=expired_test,ou=students,dc=..." -accountexpiresbefore $dateobj foreach ($user in $oldadusers) { remove-qadobject $user -force -confirm:$false }
powershell
No comments:
Post a Comment