Preheat oven to 400 degrees. In a large roasting pan, toss squash, onions, garlic, and apples with oil to coat. Season well with salt and chile powder. Roast, stirring every 10 minutes, until vegetables are fork-tender and lightly browned, about 40 minutes.
Transfer half the vegetables and 2 cups stock to a food processor; puree until smooth. Repeat with remaining vegetables and broth. Return pureed mixture to pot, thinning soup with stock, if necessary. Season with salt and chile powder; bring to a simmer over medium-low heat. Serve immediately, garnished with Cilantro Walnut Pesto, if desired.