In vivo imaging with two-photon microscopy (TPM) has become an increasingly important tool for studying the structure and function of brain cells in living animals. TPM imaging studies of neuronal structures over intervals ranging from seconds to years have begun to provide important insights into the structural plasticity of synapses and the modulating effects of experience in the intact brain. TPM imaging has also started to reveal how neuronal connections and glial cells are altered in animal models of neurodegeneration, acute brain injury and cerebrovascular disease. Here we present protocols for in vivo imaging of dendritic spine dynamics through either a thinned-skull window or an open-skull glass window. We discuss technical considerations that are critical for the acquisition of in vivo imaging data and show that the use of an open-skull glass window, but not a thinned-skull window, for in vivo imaging is associated with high spine turnover and substantial glial activation during the first month after surgery.