Microbiota of the gut, milk, and cowshed environment were examined at two dairy farms managed by automatic milking systems (AMS). Feed, rumen fluid, feces, milk, bedding, water, and airborne dust were collected and the microbiota on each was assessed by Illumina MiSeq sequencing. The most abundant taxa in feed, rumen fluid, feces, bedding, and water were Lactobacillaceae, Prevotellaceae, Ruminococcaceae, Ruminococcaceae, and Lactobacillaceae, respectively, at both farms. Aerococcaceae was the most abundant taxon in milk and airborne dust microbiota at farm 1, and Staphylococcaceae and Lactobacillaceae were the most abundant taxa in milk and airborne dust microbiota at farm 2. The three most prevalent taxa (Aerococcaceae, Staphylococcaceae, and Ruminococcaceae at farm 1 and Staphylococcaceae, Lactobacillaceae, and Ruminococcaceae at farm 2) were shared between milk and airborne dust microbiota. Indeed, SourceTracker indicated that milk microbiota was related with airborne dust microbiota. Meanwhile, hierarchical clustering and canonical analysis of principal coordinates demonstrated that the milk microbiota was associated with the bedding microbiota but clearly separated from feed, rumen fluid, feces, and water microbiota. Although our findings were derived from only two case studies, the importance of cowshed management for milk quality control and mastitis prevention was emphasized at farms managed by AMS.