Intune script failed - Outlook add-in loadbehavior

Josh Klomp 20 Reputation points
2023-08-02T15:16:01.3966667+00:00

Hi,

I want to disable some Outlook add-ins for all users and figured an Intune script was the best option.

The script works (below) when run manually in a non-admin powershell on a non-admin user account.

However, it fails when pushed out via Intune. Not sure what I'm looking for in the logs.

What am I doing wrong?

Screenshot 2023-08-02 115051


# Define the paths and values for the two Outlook add-ins

$TeamViewerAddInPath = "HKCU:\SOFTWARE\Microsoft\Office\Outlook\Addins\TeamViewerMeetingAddIn.AddIn"

$LoadBehaviorValue = 2

# Function to set registry values

function Set-RegistryValue {

param (

[string]$Path,

[string]$Name,

[string]$Value,

[string]$Type

)

$registryKey = Get-Item -LiteralPath $Path

if (!$registryKey) {

Write-Host "Registry path not found: $Path" -ForegroundColor Red

return

}

Set-ItemProperty -Path $Path -Name $Name -Value $Value -Type $Type -Force

Write-Host "Registry value set: $Path\$Name = $Value" -ForegroundColor Green

}

# Set the LoadBehavior for the TeamViewer add-in

Set-RegistryValue -Path $TeamViewerAddInPath -Name "LoadBehavior" -Value $LoadBehaviorValue -Type DWord

Outlook Windows Classic Outlook for Windows For business
Windows for business Windows Server User experience PowerShell
Microsoft Security Intune Configuration
{count} votes

Accepted answer
  1. Crystal-MSFT 53,981 Reputation points Microsoft External Staff
    2023-08-11T02:33:25.3833333+00:00

    @Josh Klomp, Thanks for the update. I am glad to hear that it is working. Congratulation! To help others to quickly find the solution, please let me write a summary:

    Issue:

    Deploy PowerShell script to disable some Outlook add-ins.

    Resolution:

    User's image

    The PowerShell script configuration in Intune. Set the "Run the script using the logged on credentials" as yes.

    User's image

    Thanks for your time and have a nice day!


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Crystal-MSFT 53,981 Reputation points Microsoft External Staff
    2023-08-03T05:34:02.89+00:00

    @Josh Klomp, Thanks for posting in Q&A. From your description, I know we use PowerShell script to disable some Outlook add-in. When we manually run the script, it works. But when we deploy the script via Intune. It is failed.

    After checking the script, I find the script is used to change the LoadBehavior registry key under current user.

    From the PowerShell Script setting in Intune, I notice the "Run the script using the logged on credentials" is set as NO which means the script is run in the system context. So the registry key is set for system account.

    https://learn.microsoft.com/en-us/mem/intune/apps/intune-management-extension

    But from your description, I know the PowerShell script needs to run under logged on user. Given the situation, please change the setting "Run the script using the logged on credentials" to Yes to see if it can work.

    Please try the above suggestion and if there's any update, feel free to let us know.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Josh Klomp 20 Reputation points
    2023-08-10T09:06:29.2933333+00:00

    The below script worked!

    Turns out the previous script was working, but the LoadBehavior value of 2 wasn't disabling the add-in. Odd since manually changing the value to 2 in regedit did disable the add-in.

    I simplified the script and changed the LoadBehavior value to 0.

    Thank you for your help @Crystal-MSFT and @MotoX80

    # Set Outlook Addin Load behavior to 0  
    
    if((Test-Path -LiteralPath "HKCU:\SOFTWARE\Microsoft\Office\Outlook\Addins\TeamViewerMeetingAddIn.AddIn") -ne $true) {  New-Item "HKCU:\SOFTWARE\Microsoft\Office\Outlook\Addins\TeamViewerMeetingAddIn.AddIn" -force -ea SilentlyContinue };          
    
    New-ItemProperty -LiteralPath 'HKCU:\SOFTWARE\Microsoft\Office\Outlook\Addins\TeamViewerMeetingAddIn.AddIn' -Name 'LoadBehavior' -Value 0 -PropertyType DWord -Force -ea SilentlyContinue;
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.