Wirelessany, thank you for the direct answer.
I asked this question sort of as a theoretical question. I really did not know the sublet was illegal until some time after I had already paid and gotten the keys - I really believed it was her apartment until that point, this was my first time in NY and I didn't know that people needed permission of their management companies to sublet, and I thought it was her apartment.
There was a verbal agreement on the basis of a sublet that is legal.
I accepted payment temporarily as a way to help alice find another tenant. I gave bob the keys, but alice got upset and told me via the phone she wanted to reverse the transaction in exchange for her keys back. Then she decided to deal directly with the new tenant. I gave him the money back in a couple days before I found out she had cashed my check.
Does it matter that I did not knowingly enter into an illegal verbal contract?
That's why I think I should get my $2000 back. You guys are saying that I don't have any legal recourse because I knowingly entered into a verbal contract, but I actually did not. I asked that in theory because that is what alice is claiming and will say in court even though I know it's not true (I have emails that show me being upset over the fact that she did not tell me it was illegal when I paid her and her response that she thought it was okay because she doesn't know about the laws here).
My mistake was in re-subletting it at all rather than just breaking the "agreement" right then and suing her at that point.
If the answer to the first question is that I should get my money back if I did not know it was illegal, does the fact that I re-subletted after knowing that it was illegal change this?
I just want to know what to expect in court, I know you think that what you say is irrelevant, but for me it helps to get opinions of others before pursuing this issue further, even if it's just from other members of a forum

I don't really know anyone else who knows about these issues and I can't find anything online