DB moves
This commit is contained in:
parent
137b933ec1
commit
941fa17bbb
@ -5,7 +5,7 @@ if (!($cred)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$AgedOutDays = -270 #store this as a negative number. How many days back should the PC have changed its password
|
$AgedOutDays = -270 #store this as a negative number. How many days back should the PC have changed its password
|
||||||
$CSVPATH = 'C:\Users\eeckert\Downloads\AD-ToDelete.csv'
|
$CSVPATH = "C:\Users\eeckert\OneDrive - MPE Engineering Ltd\Documents\Downloads\Blah.csv"
|
||||||
$computers = get-adcomputer -filter { (Enabled -eq $True) } -properties passwordlastset | where passwordlastset -le (get-date).adddays($AgedOutDays)
|
$computers = get-adcomputer -filter { (Enabled -eq $True) } -properties passwordlastset | where passwordlastset -le (get-date).adddays($AgedOutDays)
|
||||||
|
|
||||||
foreach ($computer in $computers) {
|
foreach ($computer in $computers) {
|
||||||
@ -16,15 +16,15 @@ foreach ($computer in $computers) {
|
|||||||
$computer | move-adobject -TargetPath "OU=Computers,OU=Disabled Objects,DC=mpe,DC=ca" -Credential $cred
|
$computer | move-adobject -TargetPath "OU=Computers,OU=Disabled Objects,DC=mpe,DC=ca" -Credential $cred
|
||||||
}
|
}
|
||||||
|
|
||||||
# $CSVList = import-csv $CSVPATH -ErrorAction SilentlyContinue #get list of hostnames
|
$CSVList = import-csv $CSVPATH -ErrorAction SilentlyContinue #get list of hostnames
|
||||||
|
|
||||||
# foreach ($computer in $csvlist) {
|
foreach ($computer in $csvlist) {
|
||||||
# $Output = 'Moving ' + $computer.hostname + ' to disabled OU.'
|
$Output = 'Moving ' + $computer.hostname + ' to disabled OU.'
|
||||||
# Write-Output $Output
|
Write-Output $Output
|
||||||
# $computer = Get-ADComputer $computer.hostname
|
$computer = Get-ADComputer $computer.hostname
|
||||||
# $DescText = 'Disabled: ' + (get-date)
|
$DescText = 'Disabled: ' + (get-date)
|
||||||
# $computer | set-adcomputer -Enabled $false -Credential $cred -Description $DescText
|
$computer | set-adcomputer -Enabled $false -Credential $cred -Description $DescText
|
||||||
# $computer | move-adobject -TargetPath "OU=Computers,OU=Disabled Objects,DC=mpe,DC=ca" -Credential $cred
|
$computer | move-adobject -TargetPath "OU=Computers,OU=Disabled Objects,DC=mpe,DC=ca" -Credential $cred
|
||||||
# }
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user