Investing in good companies, and paying reasonable prices to do so, is a winning strategy in the long run. Some companies have enormous competitive advantages and fantastic long-term growth prospects, so paying a premium is often worth it. Microsoft (MSFT 1.82%), dominant in productivity software with massive long-term opportunities in cloud computing and artificial intelligence (AI), is a prime example. Other companies have solid, defensible businesses with rock-bottom valuations. AT&T (T 1.02%) fits the bill.

While Microsoft and AT&T are very different stocks, both are worth buying, even if you have as little as $1,000 to invest.

Microsoft

In the past, Microsoft was heavily dependent on the PC. Global PC shipments are crashing as pandemic-era demand dries up, which is hurting the company's PC-centric businesses. In Microsoft's latest quarter, Windows OEM revenue tumbled 28%, consumer Office revenue grew by just 1%, and sales of devices were down 30%.

Thankfully, Microsoft has diversified away from the PC over the years. While Windows and Office are still critical businesses, the company offers a vast slate of enterprise software, it's become the no. 2 provider of cloud infrastructure services, and its investments in artificial intelligence have put it at the center of the next technological revolution.

Dynamics 365, Microsoft's cloud-based customer relationship management software that goes toe-to-toe with Salesforce, grew sales by 25% in the latest quarter despite the current economic environment. LinkedIn, which Microsoft acquired back in 2016 for a whopping $26.2 billion, grew by 8%.

Meanwhile, Microsoft's Azure cloud platform is catching up to market leader Amazon Web Services. Azure grew by 27% in the latest quarter, continuing a years-long trend of gaining market share. Microsoft's share of the infrastructure-as-a-service, platform-as-a-service, and private cloud markets reached 23% in the fourth quarter of 2022, up from less than 15% five years ago.

While cloud computing has been at the center of Microsoft's growth story in recent years, AI may now take up that mantle. Microsoft invested $10 billion into OpenAI, the company behind ChatGPT, and it's working to integrate AI technology into its various products and services. AI software could potentially generate trillions of dollars in revenue in the long run, and Microsoft is well-positioned to tap into this incredible opportunity.

Microsoft stock is not cheap, trading for roughly 34 times the average analyst estimate for full-year earnings. But given the strength of its cloud computing business and the potential of its AI business, it's certainly worth paying a premium for Microsoft stock. And with shares trading around $326, an investment of $1,000 is more than enough to ride the cloud and AI wave.

AT&T

While Microsoft is a tech stock for investors looking to bet on cloud computing and AI, AT&T is a tech stock for investors more focused on valuation and dividends. AT&T is one of the three major wireless service providers in the United States. The company must continually invest in its wireless network, but the payoff is robust free cash flow generation and a core business that's unlikely to be disrupted.

AT&T is facing some headwinds as consumers react to a difficult economic environment, but even so, the company still expects to generate at least $16 billion of free cash flow this year. Continued growth in wireless plus a burgeoning fiber internet business will drive this important profitability metric. The company has added at least 400,000 postpaid phone net subscribers for the past 11 quarters, and its fiber business is adding a few hundred thousand subscribers each quarter as the company expands the network and increases consumer penetration.

AT&T is valued at just $114 billion, which seems extremely pessimistic to me. Based on the company's guidance, AT&T stock trades for around 7 times free cash flow. It also sports a dividend yield of about 7%. While AT&T did cut its dividend in the wake of its spin-off of WarnerMedia, the current dividend looks sustainable.

AT&T isn't the most exciting stock, but it's capable of producing market-beating returns thanks to its beaten-down valuation and sky-high dividend yield. And trading for less than $16 per share, even the smallest investor can take advantage.