Share via

Installing Office365 with winget

Anonymous
2024-10-16T09:19:47+00:00

Hi everyone!

I'm creating a powershell script that allows me to update my computer and install Office365 automatically using winget. During the first installation everything worked. However, after uninstalling Office and then trying to reinstall it I got an error code: 0-2048 (0).

Does anyone have any ideas?

My script :

winget upgrade --all --accept-package-agreements --silent

$regionCode = Read-Host "Enter the two letters of your region (FR for France | US for United States)"

switch ($regionCode.ToUpper()) {

    "FR" {

        Set-WinUILanguageOverride -Language "fr-FR"

        Set-WinUserLanguageList -LanguageList "fr-FR" -Force

        Set-WinSystemLocale -SystemLocale "fr-FR"

        Set-WinHomeLocation -GeoId 84  # 84 est le GeoID pour la France

        Write-Output "Region defined on France (FR)."

    }

    "US" {

        Set-WinUILanguageOverride -Language "en-US"

        Set-WinUserLanguageList -LanguageList "en-US" -Force

        Set-WinSystemLocale -SystemLocale "en-US"

        Set-WinHomeLocation -GeoId 244  # 244 est le GeoID pour les c

        Write-Output "Region defined on United States (US)."

    }

    default {

        Write-Output "Region code not recognised. Please enter a correct value."

        Write-Output "Only France and the United States are recognised. If your country is not on this list, please contact the administrator."

        exit

    }

}

winget install --id Microsoft.Office -e --silent

Microsoft 365 and Office | Install, redeem, activate | Other | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-10-16T10:36:18+00:00

    Hello Alexandre Grisollet,

    Thank you for visiting the Microsoft community.

    It seems that you have encountered a problem related to the powershell script to automatically install Office365 using winget. There is little knowledge about these issues in our community, so I recommend you post your question in the relevant section of Microsoft Learn (English only) Office Development - Microsoft Q&A, where more experienced professionals can offer advice.

    I will keep this topic open in anticipation of our wonderful volunteers who can guide me.

    Sincerely

    Jonathan Z - MSFT | Microsoft Community Support Specialist

    0 comments No comments