Dear All,
I need your little assistance with the below code, it is working fine. However, I want that each successful change and error should be recorded in a log file. IF the modification is successful then it should record a log success message & should record an error in case of a failure.
$List = Import-csv c:\new\input.csv
ForEach ($User in $List)
{
Get-ADUser -Identity $User.samaccountname | Set-ADAccountExpiration -TimeSpan (New-TimeSpan -Days 100)
}