Can you get vitamin D through a window?
Unfortunately, no.
Sunlight is made up of ultraviolet A (UVA) and ultraviolet B (UVB). It’s the UVB that triggers the synthesis of vitamin D. Most glass windows filter out UVB, so sitting near a sunny window is nice for the light, but not going to help with your vitamin D levels. This is the same for car windows too.
But...all you need to do is open your window nice and wide, let the sunlight stream in and place your skin in its direct path. Same deal with a door and a car window. And even when it's not directly on the skin, the UV light helps power our hormones, power our circadian rhythm, and power our mitochondria. So, even if you're working indoors, open the windows, let the fresh air and light in.
Remember though to protect your skin you need to prepare it, allowing it to gradually build up its own natural sunscreen, melanin.
Start slow if you haven't spent much time in the sun regularly.
For darker skin which already has a higher melanin content, this means around 20-30 minutes to start with.
For lighter skin, with lower melanin content, start at 10 minutes.
Then increase this 10 minutes a day, listening to your body as you go. If your skin turns pink, this doesn't mean it's burnt. This is your blood coming to the surface for ultraviolet light but it is a sign that you skin has had enough direct sunlight. If you have the time, find a shaded area and stay outdoors, to be in nature for as long as you can. It's good for your health, it's good for your soul.