The invariant probability distribution is found for a class of birth-and-death processes on the integers with phases and one or two boundaries. The invariant vector has a matrix geometric form and is found by solving a non-linear matrix equation and then finding an invariant probability distribution on the boundary states. Levy's concept of watching a Markov process in a subset is used to naturally decouple the computation of distributions on the boundary and interior states.