Go to conclusion directly

(Seems only works with Windows 11)

Now winget supports to install a Microsoft store app. First, you need to get the store app Id.

Go to the Microsoft official website: https://www.microsoft.com/en-US/

And search the store app here. For example:

Click it. And now you have the address.

So, for example, the 'to do app' has ID: 9nblggh5r558

You can use the command to open a store page:

ms-windows-store://pdp/?ProductId=9nblggh5r558

Put the Product ID on the last.

You can also build a PowerShell to start the store automatically:

Start-Process "ms-windows-store://pdp/?ProductId=9nblggh5r558"

That will lead the user to the store page.

But what if you want to install this app without a prompt?

First, install winget with the following script:

# Install Winget

if (-not $(Get-Command winget)) {
    Write-Host "Installing WinGet..." -ForegroundColor Green
    Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
    while(-not $(Get-Command winget))
    {
        Write-Host "Winget is still not found!" -ForegroundColor Yellow
        Start-Sleep -Seconds 5
    }
}

When you have winget installed and the app Id, you can run this to install it locally:

$storeAppId = "9NBLGGH5R558" # This is your store app ID.

winget install --id $storeAppId --exact --source msstore --accept-package-agreements --accept-source-agreements

That's all. It's installed!

If you are a developer building an automation

If you are building a script that tries to install an app when it is not installed, you need to get the exact winget app Name.

Copy the winget app name. Like here, it's "Microsoft To Do".

Then you can use the following script directly.

Even easier

function Install-StoreApp {
    param (
        [string]$storeAppId,
        [string]$wingetAppName
    )

    # Install Winget
    if (-not $(Get-Command winget)) {
        Write-Host "Installing WinGet..." -ForegroundColor Green
        Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
        while(-not $(Get-Command winget))
        {
            Write-Host "Winget is still not found!" -ForegroundColor Yellow
            Start-Sleep -Seconds 5
        }
    }

    if ("$(winget list --name $wingetAppName --exact --source msstore)".Contains("--")) { 
        Write-Host "$wingetAppName is already installed!" -ForegroundColor Green
    }
    else {
        Write-Host "Attempting to download $wingetAppName..." -ForegroundColor Green
        winget install --id $storeAppId.ToUpper() --name $wingetAppName  --exact --source msstore --accept-package-agreements --accept-source-agreements
    }
}

Examples

Install-StoreApp -storeAppId "9NBLGGH5R558" -wingetAppName "Microsoft To Do"
Install-StoreApp -storeAppId "9MV0B5HZVK9Z" -wingetAppName "Xbox"
Install-StoreApp -storeAppId "9wzdncrfjbh4" -wingetAppName "Microsoft Photos"
Install-StoreApp -storeAppId "9nblggh4qghw" -wingetAppName "Microsoft Sticky Notes"
Install-StoreApp -storeAppId "9wzdncrfhvqm" -wingetAppName "Mail and Calendar"
Install-StoreApp -storeAppId "9ncbcszsjrsb" -wingetAppName "Spotify Music"