[RISOLTO] Pacchetto per disabilitare la migrazione al nuovo Outlook

Domande sul packaging WAPT / Richieste e assistenza sui pacchetti Wapt.
Regole del forum
Regole del forum della community
* Supporto in inglese su www.reddit.com/r/wapt
* Supporto della community in francese disponibile su questo forum
* Si prega di anteporre [RISOLTO] al titolo dell'argomento se è stato risolto.
* Si prega di non modificare un argomento contrassegnato con [RISOLTO]. Aprire un nuovo argomento facendo riferimento a quello precedente.
* Specificare la versione di WAPT installata, la versione completa e il numero di build (2.2.1.11957 / 2.2.2.12337 / ecc.) nonché l'edizione Enterprise/Discovery.
* Le versioni 1.8.2 e precedenti non sono più supportate. Le uniche domande accettate relative alla versione 1.8.2 riguardano l'aggiornamento a una versione supportata (2.1, 2.2, ecc.).
* Specificare il sistema operativo del server (Linux/Windows) e la versione (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Specificare il sistema operativo della macchina di amministrazione/creazione dei pacchetti e della macchina con l'agente problematico, se applicabile (Windows 7/10/11/Debian 11/ecc.).
* Evitare di porre più domande quando si apre una discussione, altrimenti potrebbe essere ignorata. Se ci sono più discussioni, aprirle separatamente, preferibilmente una dopo l'altra e non tutte contemporaneamente (ovvero, non intasare il forum).
* Includere frammenti di codice, screenshot e altre immagini direttamente nel post. I link a Pastebin, Bitly e altri siti di terze parti verranno sistematicamente rimossi.
* Come in qualsiasi forum della community, il supporto è fornito volontariamente dai membri. Se si necessita di supporto commerciale, è possibile contattare il reparto vendite di Tranquil IT al numero 02.40.97.57.55
Risposta
bastien30
Messaggi: 38
Registrazione: 8 marzo 2024 - 15:21

26 dicembre 2024 - 17:16

Buongiorno,

MODIFICA 1: Correzione del valore della chiave HideNewOutlookToggle (1 e non 0), errore mio.
MODIFICA 2: Le chiavi del Registro di sistema vengono configurate per tutti gli utenti nella funzione install() anziché durante session_setup() perché gli utenti non amministratori non hanno il diritto di scrivere su HKEY_CURRENT_USER\Software\Policies\.
MODIFICA 3: Riapplicazione della configurazione della chiave di registro dall'audit se le chiavi sono errate o mancanti per un utente (caso di utenti creati dopo l'installazione del pacchetto).

Ecco un pacchetto che consente di disabilitare la migrazione al nuovo Outlook (vedere https://www.it-connect.fr/gpo-bloquer-m ... l-outlook/).
Disinstalla anche l'applicazione se installata.

Per favore, fammi sapere se funziona bene per te :D

Codice: Seleziona tutto

# -*- coding: utf-8 -*-
from setuphelpers import *

# https://learn.microsoft.com/en-us/microsoft-365-apps/outlook/get-started/control-install

# Disable new outlook migration
new_outlook_migration = { "path" : r'Software\Policies\Microsoft\office\16.0\outlook\preferences', "name" : "NewOutlookMigrationUserSetting", "value" : 0 }

# Hide "Try new Outlook" button
new_outlook_button = { "path" : r'Software\Microsoft\Office\16.0\Outlook\Options\General', "name" : "HideNewOutlookToggle", "value" : 1 }

def install():
    # Remove new Outlook Appx if installed (computer environment)
    remove_appx(r'Microsoft.OutlookForWindows')

    # Set registry values for all users
    set_registry_all_users()

def session_setup():
    # Remove new Outlook Appx if installed (user environment)
    remove_user_appx(r'Microsoft.OutlookForWindows')
        
def audit():
    audit_result = "OK"
    need_reapply = False
    # Check registry values for all users if exists
    for i in [new_outlook_migration, new_outlook_button]:
        for user_sid in get_all_users_sids():
            if reg_key_exists(HKEY_USERS, user_sid):
                if reg_value_exists(HKEY_USERS, r'%s\%s' % (user_sid, i["path"]), i["name"]):
                    if registry_readstring(HKEY_USERS, r'%s\%s' % (user_sid, i["path"]), i["name"]) != str(i["value"]):
                        print(r'Registry value "%s" is wrong for user "%s", reapplying...' % (i["name"], get_user_from_sid(user_sid)))
                        need_reapply = True
                else:
                    print(r'Registry value "%s" is missing for user "%s", reapplying...' % (i["name"], get_user_from_sid(user_sid)))
                    need_reapply = True

    if need_reapply:
        set_registry_all_users()
        audit_result = "WARNING"

    return audit_result
    
def uninstall():
    # Remove registry values for all users if exists
    for i in [new_outlook_migration, new_outlook_button]:
        for user_sid in get_all_users_sids():
            if reg_value_exists(HKEY_USERS, r'%s\%s' % (user_sid, i["path"]), i["name"]):
                registry_delete(HKEY_USERS, r'%s\%s' % (user_sid, i["path"]), i["name"])

def set_registry_all_users():
    for i in [new_outlook_migration, new_outlook_button]:
        for user_sid in get_all_users_sids():
            if reg_key_exists(HKEY_USERS, user_sid):
                registry_set(HKEY_USERS, r'%s\%s' % (user_sid, i["path"]), i["name"], i["value"], REG_DWORD)

def get_all_users_sids():
    user_sids = []
    with reg_openkey_noredir(HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList') as sids:
        for sid in reg_enum_subkeys(sids):
            # Exclude system users SIDs
            if sid.startswith("S-1-5-21-"):
                user_sids.append(sid)
    # Return all users SIDs as list
    return ensure_list(user_sids)
fdu
Messaggi: 1
Registrazione: 3 gennaio 2025 - 16:11

3 gennaio 2025 - 16:55

CIAO,
Ecco alcune piccole modifiche apportate, per il nostro caso specifico, con il supporto di Bastien.
E buona fortuna per lunedì! :D

---

Chiarimenti sui test eseguiti (pacchetto denominato disable-newoutlook nel nostro sistema).
Testato su Windows Pro 10 22H2 e Windows Pro 11 23H2
Funziona su macchine con più sessioni utente
E non ripristinare gli utenti che hanno già eseguito la migrazione al nuovo Outlook

Non è necessario riavviare i computer affinché la modifica abbia effetto: è sufficiente chiudere e riaprire Outlook.

Codice: Seleziona tutto

# -*- coding: utf-8 -*-
from setuphelpers import *

#source: https://learn.microsoft.com/en-us/microsoft-365-apps/outlook/get-started/control-install

# Disable new outlook migration
int_newoutlook_migration = 0
# Hide "Try new Outlook" button
int_newoutlook_button = 1

#Migration to New Outlook (default is disabled)
reg_newoutlook_migration = { "path" : r'Software\Policies\Microsoft\office\16.0\outlook\preferences', "name" : "NewOutlookMigrationUserSetting", "value" : int_newoutlook_migration, "type" : REG_DWORD }
# "Try new Outlook" button (default is hidden)
reg_newoutlook_button = { "path" : r'Software\Microsoft\Office\16.0\Outlook\Options\General', "name" : "HideNewOutlookToggle", "value" : int_newoutlook_button, "type" : REG_DWORD }


def install():
    # Remove new Outlook Appx if installed (computer environment)
    #remove_appx(r'Microsoft.OutlookForWindows')

    # Set registry values for all users
    for registry in [reg_newoutlook_migration, reg_newoutlook_button]:
        for user_sid in get_all_users_sids():
            if reg_key_exists(HKEY_USERS, user_sid):
                registry_set(HKEY_USERS, r'%s\%s' % (user_sid, registry["path"]), registry["name"], registry["value"], registry["type"])

def session_setup():
    pass
    # Remove new Outlook Appx if installed (user environment)
    #remove_user_appx(r'Microsoft.OutlookForWindows')

def audit():
    audit_result = "OK"
    # Check registry values for all users if exists
    for registry in [reg_newoutlook_migration, reg_newoutlook_button]:
        for user_sid in get_all_users_sids():
            if reg_value_exists(HKEY_USERS, r'%s\%s' % (user_sid, registry["path"]), registry["name"]):
                if registry_readstring(HKEY_USERS, r'%s\%s' % (user_sid, registry["path"]), registry["name"]) != str(registry["value"]):
                    print(r'Registry value "%s" is wrong for user "%s"' % (registry["name"], get_user_from_sid(user_sid)))
                    audit_result = "ERROR"
    return audit_result

def uninstall():
    #Enable
    # Force new outlook migration
    #int_newoutlook_migration = 1
    # Show "Try new Outlook" button
    int_newoutlook_button = 0

    #Force to New Outlook
    #reg_newoutlook_migration = { "path" : r'Software\Policies\Microsoft\office\16.0\outlook\preferences', "name" : "NewOutlookMigrationUserSetting", "value" : int_newoutlook_migration, "type" : REG_DWORD }
    # "Try new Outlook" button
    reg_newoutlook_button = { "path" : r'Software\Microsoft\Office\16.0\Outlook\Options\General', "name" : "HideNewOutlookToggle", "value" : int_newoutlook_button, "type" : REG_DWORD }

    # Set registry values for all users
    for registry in [reg_newoutlook_button]:
        for user_sid in get_all_users_sids():
            if reg_key_exists(HKEY_USERS, user_sid):
                registry_set(HKEY_USERS, r'%s\%s' % (user_sid, registry["path"]), registry["name"], registry["value"], registry["type"])

def get_all_users_sids():
    user_sids = []
    with reg_openkey_noredir(HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList') as sids:
        for sid in reg_enum_subkeys(sids):
            # Exclude system users SIDs
            if sid.startswith("S-1-5-21-"):
                user_sids.append(sid)
    # Return all users SIDs as list
    return ensure_list(user_sids)
Risposta