Quantcast
Channel: Microsoft – JeffOps
Viewing all articles
Browse latest Browse all 120

Enable and disable MSI logging through PowerShell

$
0
0

This morning I was contacted by an IT Pro asking me if I could write some PowerShell code to enable and disable MSI logging.
He both wanted to use it from a command line and needed it to be part of a big troubleshooting script he’s working on; so reusable code.

First up is a function to enable the MSI logging:

function Enable-MSILogging
{
  if((Test-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\Installer" -Name "Logging" ) -eq $False)
  {
    New-Item -Path "HKLM:\Software\Policies\Microsoft\Windows\Installer" -Force
  }
  Set-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\Installer" -Name "Logging" -Value "voicewarmupx" -Force
}

Next is a function to disable the MSI logging:

function Disable-MSILogging
{
  if(Test-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\Installer" -Name "Logging")
  {
    Remove-ItemProperty -Path "HKLM:\Software\Policies\Microsoft\Windows\Installer" -Name "Logging" -Force
  }
}

As you can see I’m simply using the registry to enable/disable it.
I’m currently writing some other functions that I’ll post in the near future.

Update: Shay Levy contacted me stating that I’m using Test-ItemProperty and that doesn’t exist. He’s correct since it’s part of my personal toolkit. So I’ve decided to share it with you here.

Post to Twitter


Viewing all articles
Browse latest Browse all 120

Trending Articles