Answer the question
In order to leave comments, you need to log in
Transferring a folder with a domain username after disabling it?
Hello. Such a task is worth it. The exchanger has folders for each domain user. You need to create a script so that when a user is disabled, the folder with the username is moved to another folder (for example, the "Trash" folder)
Found how to select disabled users
Import-Module ActiveDirectory
Get-ADUser -filter {enabled -eq $false}
There is a transfer option folders
Move-Item -Path "C:\Obmen\Operators\Petr Petrov\New Folder" -Destination "C:\Trash" It's
not clear how to link them. Like if the user has such a status "False", that such a folder would be transferred to the Trash folder.
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
Hello.
Ismat Gayibov If I understood everything correctly, simple programming is enough to connect here. use if else.
I write the code very exemplary on the go without checking it on the machine.
$checkuser = Get-ADUser user12 -filter {enabled -eq $false}
if($checkuser){
Move-Item -Path "C:\Obmen\Операторы\user12\Новая папка" -Destination "C:\Мусор"
}
else{
Write-host "отключенных пользователей более не найдено"
}
$DisabledUsers = (Get-ADUser -filter {enabled -eq $false} -Properties displayname | select displayname).displayname
foreach ($User in $DisabledUsers)
{
$FolderPath = "C:\Obmen\Операторы\$User"
If (Test-Path $FolderPath)
{
Move-Item -Path $FolderPath -Destination "C:\Мусор" -Force
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question