Lots of good responses here. I've lived in Brooklyn for the past 7 years, so I can speak to some areas. With a $1MM dollar budget, you're going to be hard-pressed to find anything more than 1bd (or small 2bd) in Williamsburg, Greenpoint, Dumbo, Brooklyn Heights, Cobble Hill, Fort Greene, Boerum Hill and Park Slope. So you'll need to go outside of those prime areas. This means a significantly longer commute to Manhattan. Where is grad school? If lower Manhattan, south Brooklyn may work. If upper Manhattan (i.e. Columbia), you're looking at an hour and a half. You can find multis further south of prospect park for less than a $1mm. Sunset Park and Bay Ridge are good areas. The further east you go from there, the cheaper places get.
I guess the question is: do you want to spend your two years on the outskirts of NYC or in NJ, potentially in questionable neighborhoods, with long commutes just to have an investment there? It might be worth investing in cash flow properties in other cities and using the proceeds to subsidize your rent in a convenient NYC neighborhood.