In this paper, a novel stochastic model is proposed to model the spread of a virus in epidemics. The model is based on a discrete-time non-homogeneous Markov system with state capacities. In order to study the distributions of the state sizes, recursive formulae for their factorial and mixed factorial moments were derived in matrix form. As a consequence, the probability mass function of each state size can be evaluated in the transient period. To avoid the computational complexity of the proposed algorithm, an alternative method for the computation of the state size distributions was recommended. The proposed Markovian approach was then tailored to the characteristics of a SIQS (susceptible-infected-quarantined-susceptible) epidemic scheme, which took into account external infections and the potential for secondary infections. This epidemic model is well-suited for describing infections in computer networks, where the quarantine capacity can be likened to the number of working people (IT professionals) available to restore an infected computer. We presented numerical examples and sensitivity analysis to illustrate the behavior and performance of the system under different scenarios and parameter values. We show that the state capacities and the infection rates have significant effects on the evolution and extinction of the epidemic. We note that the optimal number of employed technicians can be identified, aiming to keep the computer network functional. Higher internal infection rates significantly affect the sustainability of the computer network, while controlling external infections is not always feasible. On the other hand, faster detection rates and higher malware elimination rates will considerably increase the number of computers that remain operational in the long term. Consequently, the quality of services provided by IT technicians plays a crucial role in the system’s viability.