# Import new users $ADUserfiles = Get-ChildItem $userfolderpath\*.csv foreach ($Ufile in $ADUserfiles) { # Import new users .\tabcmd createusers $Ufile $TabParam }
The snippet of code above uses a command line tool to add users to to my application. I have run into a problem.
When the script gets to a particular user(s) it will fail and it skips that entire file instead of just skipping that one ID. This occurs in 2 of my files so far while testing. I can't modify tabcmd, it's part of an application.
What I would like to do is capture this error and use it to delete the row containing that ID then have the script rerun the file.
===== Error importing processing users CSV file (file reference: 5) No Active Directory account named <i>usera usera</i>.
I thought about using Try/Catch but I don't know how to capture the error and pass just the id contained in the error to a variable that I can then use to delete the row from the file. There could be many different problem id's contained in 1 or many different files. If it has to loop through a file once or many times that is ok with me.
Any help is appreciated.