Hi,
The parameter -identity accepts type ADUser but the type of $Account.Username is String. Please check if this works for you
$searchbase = "OU=DISABLEDUSERS,OU=LAB,DC=labserver,DC=com"
$ReferenceUsers = Import-Csv "C:\Folder\ReferenceUsers.csv"
$UserCount = 0
foreach($Account in $ReferenceUsers) {
#Assming Username is the SamAccountName which is unique in a domain
$nametmp = $Account.Username
Get-ADUser -Filter {(SamAccountName -eq $nametmp) -and (Enabled -eq $false)} -SearchBase $searchbase | Enable-ADAccount -PassThru | Move-ADObject -TargetPath "OU=ENABLEDUSERS,OU=LAB,DC=labserver,DC=com"
$UserCount=$UserCount+1
}
Best Regards,
Ian
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.