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.
Some time ago I got asked how one could find if a network interface card (NIC) is configured to register itself in DNS.
In the GUI it’s a checkbox, a little hidden and you have to click a bit to find it.
The intention was to do an inventory of the environment to see which servers were properly configured.
So, PowerShell to the resque yet again
$NIC = Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.IPEnabled -eq "True"}
$NIC.FullDNSRegistrationEnabled
This works for PowerShell v1 and v2 but in v3 you can do this with a simple oneliner:
(Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.IPEnabled -eq "True"}).FullDNSRegistrationEnabled

Categories
Tag Cloud
Blog RSS
Comments RSS
Last 50 Posts
Back
Void « Default
Life
Earth
Wind
Water
Fire
Light 