To investigate the molecular mechanism of Yiwei Decoction (YWD) in preventing Premature ovarian insufficiency (POI)-related osteoporosis from the hypothalamic perspective , and to screen for the key active and acting molecules in YWD. Cyclophosphamide was used to create the POI rat model. Groups A, B, and C were established. The Model + YWD group was group A, the model control group was group B, and the normal control group was group C. ELISA was used to determine serum GnRH and FSH levels after gavage. The transcription levels of mRNAs in each group's hypothalamus tissues were examined using RNA-seq sequencing technology. The GSEA method was used to enrich pathways based on the gene expression levels of each group. The TCM–active ingredient–target–disease network map was created using differentially expressed mRNAs (DEmRNAs) and network pharmacology. The molecular docking method was employed to investigate the affinity of the active ingredient with key targets. GnRH and FSH levels in POI rats' serum were reduced by YWD. Between groups A and B, there were 638 DEmRNAs (P < 0.05) and 55 high-significance DEmRNAs (P-adjust < 0.01). The MAPK, Hedgehog, Calcium, and B cell receptor pathways are primarily enriched in DEmRNAs from Group A and Group B. The GSEA pathway enrichment analysis indicates that YWD may regulate Long-term potentiation, Amphetamine addiction, and the Renin-angiotensin system and play a role in preventing osteoporosis. The Chinese herbal medicine (CHM)—Active ingredient-Target-disease network map includes 137 targets, 4 CHMs, and 22 active ingredients. The result of docking indicated that Stigmasterol, interacts well with the core proteins ALB, VCL and KAT5. Following the screening, we identified the targets, active components, and key pathways associated with YWD osteoporosis prevention. Most of these key targets and pathways are associated with osteoporosis, but further experimental validation is required.