Given the rally in Microsoft (MSFT -0.32%) shares on Friday, Steve Ballmer's retirement was long overdue. With a new CEO in place, Microsoft might finally be able to turn it around. Although it has been a steady dividend payer, Microsoft shares have largely traded flat over the last decade, as rivals like Apple, Google (GOOGL -0.09%), and even Amazon (AMZN 0.23%) have passed it by.

New management means hope for Microsoft. Unfortunately, whomever comes in is going to have their hands full. Nearly every part of Microsoft's business is immensely challenged.

The Windows ecosystem is shrinking fast

Perhaps its biggest issue is Windows. Sales of traditional PCs (laptops and desktops) have declined as consumers have opted for mobile devices instead. Microsoft's foray into mobile -- Windows 8 and Windows Phone -- has mostly fallen flat.

In the first quarter, sales of traditional PCs fell nearly 14%, the largest decline on record. When Microsoft reported earnings in July, it admitted that demand for PCs was down about 20% among consumers. Meanwhile, Windows Phone is growing, but remains a marginal player with only a 3% market share.

And as Windows slowly dies, Google benefits. Research firm Gartner expects Android, Google's mobile operating system, to largely supplant Windows by 2017.

Microsoft's internet investment hasn't paid off

Since 2009, Microsoft has poured billions into its web services. Unfortunately, the company has little to show for it. Bing continues to remain far behind Google in search, while Google's webmail and browser have grown their market share at Microsoft's expense.  

Since the first quarter of 2005, Microsoft's online services division has cost the company over $11 billion. Bing is the single largest product in that division, and despite investing all those billions, Microsoft's share of the search market has remained far behind Google's -- last month, it took about 18% of the market, compared to Google's 67%.

Last year, Google's Gmail overtook Microsoft's Hotmail to become the world's largest email service. And while Google's Chrome browser continues to lag Microsoft's Internet Explorer, Google is, with its Chromebooks, turing Chrome into a full-fledged operating system -- Internet Explorer remains just a browser.

Office is starting to see legitimate competition

Office is perhaps the best positioned of Microsoft's businesses. For the most part, it remains a monopoly product -- business users have little choice but to go with Office. Consequently, it's been a veritable cash cow for Microsoft, and continues to rake in billions. Last quarter, Microsoft's Business Division -- of which Office is the dominant product -- accounted for a third of its revenue, and the majority of its profit.

But unfortunately for Microsoft, competition is starting to emerge. Google's Docs is an inferior product to Office, but has the advantage of being free. Microsoft clearly fears Google Docs to some extent, as it has financed an ad trashing Google's product.

Last December, Google's Enterprise Chief Amit Singh told AllThingsD his company hopes to steal 90% of Microsoft's Office customers -- those who do not require the most advanced features of Office.

Azure remains second to Amazon Web Services

Microsoft's infrastructure-as-a-service product, Azure, is its most intriguing product from a long-term standpoint. Hedge fund ValueAct poured $2 billion into Microsoft shares mostly on Azure's potential. But Azure continues to lag Amazon Web Services, and there's no guarantee it will ever catch up.

The exact market share for public cloud products like Azure and AWS remains unknown. But by most estimates, AWS dominates the sector. AWS had 35% of the market in the fourth quarter of last year, according to a study done by Synergy Research Group (via Datacenter Dynamics).

AWS has become a big part of Amazon. According to Macquaire analysts, AWS will bring in $3.8 billion in revenue this year, and if it were a stand-alone company, would be worth $19-30 billion -- 15-23% of Amazon's total business.

It's possible that Azure could upend AWS, but Morgan Stanley isn't concerned. It thinks AWS' lead is large, and that, by 2024, it will generate $24 billion in revenue per year, and threaten the entire legacy tech space (including Microsoft).

Investing in Microsoft

In the second quarter, hedge fund manager David Einhorn sold his entire stake in Microsoft. In a letter to investors, he wrote that a "decade of mismanagement" has set the company up for decline.

While a new, and more visionary CEO could, in theory, turn Microsoft around, the company is in danger. In most of its divisions, Microsoft lags its competition, and even in the areas where Microsoft dominates (like Office), new competitors are rising to challenge the tech giant.

For now, investors should take a wait and see approach.