Char the poblanos over a gas flame or under a broiler, turning frequently until skin has blackened. Place chile in a plastic bag or bowl covered with plastic wrap. Allow to steam briefly until slightly cooled, then remove and discard skin and seeds (avoid rinsing to retain the most flavor). Chop poblano into small pieces and set aside.
Meanwhile, bring a large pot of well-salted water to a boil and have a bowl of cold water nearby. Cut potatoes into 1/8-inch-thick slices -- use a mandoline if you have one. Immediately place slices in the bowl of water to keep them from oxidizing and to remove any excess starch.
Working in batches, separate potato slices as you add them to the boiling water; cook just until potatoes are tender and fully cooked but the pieces still hold together. Remove and place in the cold water, drain well and set aside.
Butter a 3-quart baking dish. Add a single layer of potato slices, season with salt and pepper, then scatter on some of the poblano, ham and some cheese, if using. Repeat until all the ingredients are used up, ending with a little poblano and ham on top. Wrap well and refrigerate. The recipe can be made to this point a day ahead.
To finish: Place the rack in the middle of the oven, and preheat the oven to 350 degrees. Remove the baking dish from the refrigerator. Whisk together the eggs, sour cream, melted butter and herbs, if using. Season to taste with salt and pepper. Pour over the potato and other ingredients and bake until eggs have just set, about 35 to 40 minutes. Serve immediately.