csehz
asked on
PowerShell - Move errors to file
Dear Experts,
I have been running this command to remove users from a certain Active Directory group, basically their names are listed in a .csv file column and from there imported, then for each the command executed and putting the errors to a .txt file:
Import-Csv C:\users\z.cseh\desktop\di splaynames .csv | ForEach {remove-adgroupmember -Identi
ty "Users" -Member $_.displayname -Confirm:$false} 2>> c:\users\z.cseh\desktop\Di splayNames Err.txt
In general that works fine, but relating the errors the issue is that it puts to the .txt file when error happens, but not showing at which .csv line or at which users. Always just repeating this pattern:
Could you please advise how to parameterise somehow to show at least at which .csv line the error happened?
Thanks,
I have been running this command to remove users from a certain Active Directory group, basically their names are listed in a .csv file column and from there imported, then for each the command executed and putting the errors to a .txt file:
Import-Csv C:\users\z.cseh\desktop\di
ty "Users" -Member $_.displayname -Confirm:$false} 2>> c:\users\z.cseh\desktop\Di
In general that works fine, but relating the errors the issue is that it puts to the .txt file when error happens, but not showing at which .csv line or at which users. Always just repeating this pattern:
Could you please advise how to parameterise somehow to show at least at which .csv line the error happened?
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER