Technically, there's no problem -- you can almost always see enough satellites through the cabin window to get a good lock. I've done it many times. They don't always work from the flight deck, I understand, due to extra shielding in the glass at the front to protect pilots from radiation.
Legally is another matter. Strictly speaking, as they're radio receivers they're banned by most authorities. Some ban everything anyway (thanks, IAA). I ask the cabin crew whether I'm allowed, and if they're unsure I ask them to take the GPS up to the flight deck when convenient and get a pronouncement.
And it's great fun.
R