The stock market has been on a bull run for close to two years, which is good news for investors. The "we should keep an eye on that" news is that it's now historically pricey, which leaves it more susceptible to a pullback if investor sentiment quickly shifts (which isn't far-fetched).

Despite the priciness of the current market, one stock remains a no-brainer buy: Microsoft (MSFT -0.77%). The stock is up over 22% year to date through Sept. 26 and flirting with its all-time high, which it reached in early August.

Someone leaning against a glass wall, holding and looking at a tablet.

Image source: Getty Images.

A good amount of the market's growth, based on the S&P 500, has come from tech stocks skyrocketing in valuation due to the artificial intelligence (AI) boom. The "Magnificent Seven" stocks, of which Microsoft is a part, now account for over one-third of the S&P 500. That's not ideal from a diversification perspective.

Microsoft stands out as a no-brainer amid the current environment due to the diversity of its business compared to most other companies, regardless of industry. I like to refer to Microsoft as the tech Swiss Army knife because it touches so many different parts of the tech world. It has enterprise and consumer productivity software (Excel, Word, Teams, etc.); a thriving cloud platform (Azure); hardware (PCs, tablets, accessories); gaming (Xbox); professional networking (LinkedIn); and search/advertising (Bing).

While other tech companies' valuations may be propped up by the recent AI hype, Microsoft's diversified business ensures it remains reliable even if/when the AI hype fades, and if one or a couple segments lag, Microsoft has plenty of others that can hold their own weight. This doesn't mean it can't experience down periods; however, in the long term, it's in a great position.