Microsoft (MSFT 1.44%) stock recently set a new all-time high, eclipsing the record that shares reached just before markets started tanking in early 2022. The stock is up over 40% so far in 2023. Along with some positive news about Microsoft's efforts related to artificial intelligence (AI), a big factor in the rally has also been the surging Nasdaq Composite index, which is up 29% so far this year.

Microsoft's huge gains so far this year raise questions about whether investors can still see good returns from buying the stock at today's prices. Let's take a closer look at whether this diversified tech business is a good fit for long-term investors' portfolios.

The latest results show the power of Microsoft's diverse business

It's not hard to see why Wall Street is more optimistic about Microsoft lately. In late April, the company announced improving growth trends, with year-over-year revenue gains landing at 10% compared to just 2% in the prior quarter. Its cloud and enterprise services all saw strong demand even as economic growth rates slowed in some markets.

The fiscal 2023 Q3 results (for the quarter ended March 31) also demonstrate the value of its diverse operating model. Its consumer hardware segment shrank, and so did parts of its video game unit. But Microsoft was still able to grow the wider business at a healthy clip. This success sets it apart from less diversified companies in the tech space, such as Garmin and Zoom Video Communications.

High expectations for further growth

Investing is more about the future than the past, however, and the good news is there are high expectations for Microsoft's next few years. Yes, the company noted sluggish ordering in parts of the enterprise business as IT budgets became constrained in late 2022 into early 2023.

But that segment is still likely to see excellent gains thanks to long-term trends like the shift toward cloud-based operating models. Executives are even more excited about the potential for AI and its partnership with OpenAI to boost the productivity of several of its software offerings and accelerate growth. "We are the platform of choice to help customers get the most value out of their digital spend," CEO Satya Nadella said in a late-April press release.

Overall, most Wall Street pros are looking for modest growth this year following several above-average fiscal years. Revenue should increase around 7% in 2023 before accelerating back into the double digits next year.

Price and value

Microsoft's stock valuation has jumped in 2023, but it still isn't as expensive as it was during the crazy-growth days in late 2021. You can own the stock for 12 times sales compared to 15 at that time. The recent low for Microsoft's price-to-sales (P/S) ratio has been around 8.

Cautious investors might want to wait before buying the stock at this elevated valuation, especially given the prospects for weak growth in key areas like Windows software and PC hardware. But, if you're a more growth-focused investor, the stock still might look attractive thanks to Microsoft's exposure to so many positive long-term software trends, especially AI. The company is highly profitable and generates mountains of cash, too.

It's hard to go wrong by owning a high-quality business like that, even if your initial entry valuation seems a bit elevated. That's why Microsoft stock could play a positive role in most investors' portfolios.