29 May 2014

Enable Wake-On-LAN

NOTE: This is an old script. I have a newer and more efficient one located here.

This script will enable WOL and test to make sure it has been set. It will return whether it was a success or failure both to a log file and the screen. This script was written to also be incorporated with my new build logging process that I am getting ready to release soon. If you do not want this, just delete the buildlog and sequence variables out, along with their use in the ProcessLogFile function.


You can download the script from here.


 <#  
 .SYNOPSIS  
   Wake-On-LAN  
 .DESCRIPTION  
   Enable Wake-On-LAN  
 .PARAMETER <paramName>  
   <Description of script parameter>  
 .EXAMPLE  
   <An example of using the script>  
 #>  
 #Declare Global Memory  
 Set-Variable -Name AppLog -Scope Global -Force  
 Set-Variable -Name BuildLog -Scope Global -Force  
 Set-Variable -Name Errors -Value $null -Scope Global -Force  
 Set-Variable -Name LogFile -Scope Global -Force  
 Set-Variable -Name RelativePath -Scope Global -Force  
 Set-Variable -Name Sequence -Scope Global -Force  
 Set-Variable -Name Title -Scope Global -Force  
 Function ConsoleTitle ($Title){  
      $host.ui.RawUI.WindowTitle = $Title  
 }  
 Function DeclareGlobalVariables {  
      $Global:AppLog = "/lvx "+$Env:windir + "\Logs\ApplicationLogs\WakeOnLAN.log"  
      $Global:BuildLog = $Env:windir + "\Logs\BuildLogs\Build.log"  
      $Global:LogFile = $Env:windir + "\Logs\BuildLogs\WakeOnLAN.log"  
      $Global:Sequence = "08"  
      $Global:Title = "Wake On LAN"  
 }  
 Function GetRelativePath {   
      $Global:RelativePath = (split-path $SCRIPT:MyInvocation.MyCommand.Path -parent)+"\"   
 }  
 Function EnableWOL {  
      # Get all physical ethernet adaptors  
      $nics = Get-WmiObject Win32_NetworkAdapter -filter "AdapterTypeID = '0' `  
      AND PhysicalAdapter = 'true' `  
      AND NOT Description LIKE '%Centrino%' `  
      AND NOT Description LIKE '%wireless%' `  
      AND NOT Description LIKE '%virtual%' `  
      AND NOT Description LIKE '%WiFi%' `  
      AND NOT Description LIKE '%Bluetooth%'"  
      foreach ($nic in $nics) {  
           $nicName = $nic.Name  
           $Output = "NIC:"+$nicName+[char]10  
           Write-Host "NIC:"$nicName  
           $Output = $Output + "Allow the computer to turn off this device....."  
           Write-Host "Allow the computer to turn off this device....." -NoNewline  
           $nicPower = Get-WmiObject MSPower_DeviceEnable -Namespace root\wmi | where {$_.instancename -match [regex]::escape($nic.PNPDeviceID) }  
           If ($nicPower.Enable -ne $True) {  
                $nicPower.Enable = $True  
                $Temp = $nicPower.psbase.Put()  
           }  
           If ($nicPower.Enable -eq $True) {  
                $Output = $Output + "Enabled"  
                Write-Host "Enabled" -ForegroundColor Yellow  
           } else {  
                $Output = $Output + "Failed"  
                Write-Host "Failed" -ForegroundColor Red  
           }  
           $Output = $Output + [char]10  
           $Output = $Output + "Allow this device to wake the computer....."  
           Write-Host "Allow this device to wake the computer....." -NoNewline  
           $nicPowerWake = Get-WmiObject MSPower_DeviceWakeEnable -Namespace root\wmi | where {$_.instancename -match [regex]::escape($nic.PNPDeviceID) }  
           If ($nicPowerWake.Enable -ne $True) {  
                $nicPowerWake.Enable = $True  
                $Temp = $nicPowerWake.psbase.Put()  
           }  
           If ($nicPowerWake.Enable -eq $True) {  
                $Output = $Output + "Enabled"  
                Write-Host "Enabled" -ForegroundColor Yellow  
           } else {  
                $Output = $Output + "Failed"  
                Write-Host "Failed" -ForegroundColor Red  
           }  
           $Output = $Output + [char]10  
           $Output = $Output + "Only allow a magic packet to wake the computer....."  
           Write-Host "Only allow a magic packet to wake the computer....." -NoNewline  
           $nicMagicPacket = Get-WmiObject MSNdis_DeviceWakeOnMagicPacketOnly -Namespace root\wmi | where {$_.instancename -match [regex]::escape($nic.PNPDeviceID) }  
           If ($nicMagicPacket.EnableWakeOnMagicPacketOnly -ne $True) {  
                $nicMagicPacket.EnableWakeOnMagicPacketOnly = $True  
                $Temp = $nicMagicPacket.psbase.Put()  
           }  
           If ($nicMagicPacket.EnableWakeOnMagicPacketOnly -eq $True) {  
                $Output = $Output + "Enabled"  
                Write-Host "Enabled" -ForegroundColor Yellow  
           } else {  
                $Output = $Output + "Failed"  
                Write-Host "Failed" -ForegroundColor Red  
           }  
      }  
      Out-File -FilePath $Global:LogFile -InputObject $Output -Append -Force  
 }  
 Function ProcessLogFile {  
      If ((Test-Path $Env:windir"\Logs") -eq $false) {  
           New-Item -ItemType Directory -Path $Env:windir"\Logs"  
      }  
      If ((Test-Path $Env:windir"\Logs\ApplicationLogs") -eq $false) {  
           New-Item -ItemType Directory -Path $Env:windir"\Logs\ApplicationLogs"  
      }  
      If ((Test-Path $Env:windir"\Logs\BuildLogs") -eq $false) {  
           New-Item -ItemType Directory -Path $Env:windir"\Logs\BuildLogs"  
      }  
      If ($Global:Errors -eq $null) {  
           If (Test-Path $Global:LogFile) {  
                Remove-Item $Global:LogFile -Force  
           }  
           $File1 = $Global:LogFile.Split(".")  
           $Filename1 = $File1[0]+"_ERROR"+"."+$File1[1]  
           If (Test-Path $Filename1) {  
                Remove-Item $Filename1 -Force  
           }  
           $Global:Errors = 0  
      } elseIf ($Global:Errors -ne 0) {  
           If (Test-Path $Global:LogFile) {  
                $Global:LogFile.ToString()  
                $File1 = $Global:LogFile.Split(".")  
                $Filename1 = $File1[0]+"_ERROR"+"."+$File1[1]  
                Rename-Item $Global:LogFile -NewName $Filename1 -Force  
           }  
      } else {  
           $LogTitle = $Global:Sequence + " - "+$Global:Title  
           Out-File -FilePath $Global:BuildLog -InputObject $LogTitle -Append -Force  
      }  
 }  
 Function ExitPowerShell {  
      If ($Global:Errors -ne $null) {  
           Exit 1  
      }  
 }  
 cls  
 GetRelativePath  
 DeclareGlobalVariables  
 ConsoleTitle $Global:Title  
 ProcessLogFile  
 EnableWOL  
 ProcessLogFile  
 ExitPowerShell  
 Start-Sleep -Seconds 10  

22 May 2014

Executing Command Line on Remote Systems

I have been a huge fan of PsExec ever since I became and SCCM Administrator. The problem with PsExec is that it transmits credentials in clear text. There is a great alternative to this and it is PAExec. It is freeware and can be redistributed. It has all of the same functionality as PsExec with a few additional minor features. You can get the software at PowerAdmin.

02 May 2014

Enable or Disable Internet Explorer Active X Components

This script will enable or disable Internet Explorer Active X components. All you have to do is pass the user friendly name of the component, component's GUID, and the flag. The app will verify if the change actually takes place and returns a success or failure status.

You can download this from here.


<#
.SYNOPSIS
   Enable/Disable IE Active X Components
.DESCRIPTION
   
.PARAMETER <paramName>
   <Description of script parameter>
.EXAMPLE
   EnableIEActiveXControl "Application Name" "GUID" "Value"
   EnableIEActiveXControl "Flash for IE" "{D27CDB6E-AE6D-11CF-96B8-444553540000}" "0x00000000"
#>

#Declare Global Memory
Set-Variable -Name Errors -Value $null -Scope Global -Force
Set-Variable -Name LogFile -Value "c:\windows\waller\Logs\BuildLogs\AdobeFlashPlayer.log" -Scope Global -Force
Set-Variable -Name RelativePath -Scope Global -Force

Function ConsoleTitle ($Title){
    $host.ui.RawUI.WindowTitle = $Title
}

Function GetRelativePath { 
    $Global:RelativePath = (split-path $SCRIPT:MyInvocation.MyCommand.Path -parent)+"\" 
}

Function DisableIEActiveXControl ($AppName,$GUID,$Flag) {
    $Key = "HKLM:\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\"+$GUID
    If ((Test-Path $Key) -eq $true) {
        Write-Host $AppName"....." -NoNewline
        Set-ItemProperty -Path $Key -Name "Compatibility Flags" -Value $Flag -Force
        $Var = Get-ItemProperty -Path $Key -Name "Compatibility Flags"
        If ($Var."Compatibility Flags" -eq 1024) {
            Write-Host "Disabled" -ForegroundColor Yellow
        } else {
            Write-Host "Enabled" -ForegroundColor Red
        }
    }
}

Function EnableIEActiveXControl ($AppName,$GUID,$Flag) {
    $Key = "HKLM:\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\"+$GUID
    If ((Test-Path $Key) -eq $true) {
        Write-Host $AppName"....." -NoNewline
        Set-ItemProperty -Path $Key -Name "Compatibility Flags" -Value $Flag -Force
        $Var = Get-ItemProperty -Path $Key -Name "Compatibility Flags"
        If ($Var."Compatibility Flags" -eq 0) {
            Write-Host "Enabled" -ForegroundColor Yellow
        } else {
            Write-Host "Disabled" -ForegroundColor Red
        }
    }
}

cls
#DisableIEActiveXControl "Flash for IE" "{D27CDB6E-AE6D-11CF-96B8-444553540000}" "0x00000400"
EnableIEActiveXControl "Flash for IE" "{D27CDB6E-AE6D-11CF-96B8-444553540000}" "0x00000000"
Start-Sleep -Seconds 5

01 May 2014

Installing Dell CCTK and Configuring BIOS Settings

This script will install the Dell CCTK and set specified BIOS settings. Unlike the CCTK that allows you to create a multiplatform file to run against any Dell model machine, this script takes a different approach so that there is a description, logging, and verification of each BIOS setting. This script will first install the CCTK that needs to be in the same directory as the script. It then executes the CCTKSetting function that allows for you to enter each desired setting. There are four variables passed into the function. The first is a description. The second is the actual name of the BIOS setting. The third is the desired value for the setting. Finally, the fourth is only for the bootorder setting. There has to be an additional value passed for this setting.

When executed, the script writes both to the screen and a log file the settings that were changed. Since this is a multiplatform, I have included a return message "unavailable" for those settings not present of the machine this was executed on.

NOTE: If you use this script in a build process and make changes to embsataraid, the OS will likely fail to load. This setting has to be changed before the OS is layed down.

You can download this script here.


<#
.Author
   Mick Pletcher
.Date
   01 May 2014
.SYNOPSIS
   Dell Client Configuration Toolkit
.DESCRIPTION
   Installs CCTK
.PARAMETER <paramName>
   <Description of script parameter>
.EXAMPLE
   <An example of using the script>
#>

#Declare Global Memory
Set-Variable -Name Errors -Value $null -Scope Global -Force
Set-Variable -Name LogFile -Value $Env:windir"\Logs\BuildLogs\CCTK.log" -Scope Global -Force
Set-Variable -Name BuildLog -Value $Env:windir"\Logs\BuildLogs\Build.log" -Scope Global -Force
Set-Variable -Name RelativePath -Scope Global -Force

Function ConsoleTitle ($Title){
    $host.ui.RawUI.WindowTitle = $Title
}

Function GetRelativePath { 
    $Global:RelativePath = (split-path $SCRIPT:MyInvocation.MyCommand.Path -parent)+"\" 
}

Function InstallCCTK {
    $MSI = "/i "+[char]34+$Global:RelativePath+"cctk.msi"+[char]34
    $Switches = [char]32+"/qb- /norestart /lvx C:\Windows\logs\ApplicationLogs\CCTK.log"
    $Argument = $MSI+$Switches
    $Output = "Install CCTK....."
    Write-Host "Install CCTK....." -NoNewline
    $ErrCode = (Start-Process -FilePath msiexec.exe -ArgumentList $Argument -Wait -Passthru).ExitCode
    If ($ErrCode -eq 0) {
        $Output = $Output+"Success"
        Write-Host "Success" -ForegroundColor Yellow
    } else {
        $Output = $Output+"Failed with error code "+$ErrCode
        Write-Host "Failed with error code "$ErrCode -ForegroundColor Red
        $Global:Errors++
    }
    Out-File -FilePath $Global:LogFile -InputObject $Output -Append -Force
}

Function CCTKSetting ($Name,$Option,$Setting,$Drives) {
    $EXE = $Env:PROGRAMFILES+"\Dell\CCTK\X86\cctk.exe"
    If ($Option -ne "bootorder") {
        $Argument = "--"+$Option+"="+$Setting
    } else {
        $Argument = "bootorder"+[char]32+"--"+$Setting+"="+$Drives
    }
    $Output = $Name+"....."
    Write-Host $Name"....." -NoNewline
    $ErrCode = (Start-Process -FilePath $EXE -ArgumentList $Argument -Wait -Passthru).ExitCode
    If ($ErrCode -eq 0) {
        If ($Drives -eq "") {
            $Output = $Output+$Setting
            Write-Host $Setting -ForegroundColor Yellow
        } else {
            $Output = $Output+$Drives
            Write-Host $Drives -ForegroundColor Yellow
        }
    } elseIf ($ErrCode -eq 119) {
        $Output = $Output+"Unavailable"
        Write-Host "Unavailable" -ForegroundColor Green
    } else {
        $Output = $Output+"Failed with error code "+$ErrCode
        Write-Host "Failed with error code "$ErrCode -ForegroundColor Red
        $Global:Errors++
    }
    Out-File -FilePath $Global:LogFile -InputObject $Output -Append -Force
}

Function ProcessLogFile {
    If ((Test-Path $Env:windir"\logs") -eq $false) {
        New-Item -ItemType Directory -Path $Env:windir"\logs"
    }
    If ((Test-Path $Env:windir"\Logs\BuildLogs") -eq $false) {
        New-Item -ItemType Directory -Path $Env:windir"\Logs\BuildLogs"
    }
    If ((Test-Path $Env:windir"\Logs\ApplicationLogs") -eq $false) {
        New-Item -ItemType Directory -Path $Env:windir"\Logs\ApplicationLogs"
    }
    If ($Global:Errors -eq $null) {
        If (Test-Path $Global:LogFile) {
            Remove-Item $Global:LogFile -Force
        }
        $File1 = $Global:LogFile.Split(".")
        $Filename1 = $File1[0]+"_ERROR"+"."+$File1[1]
        If (Test-Path $Filename1) {
            Remove-Item $Filename1 -Force
        }
        $Global:Errors = 0
    } elseIf ($Global:Errors -ne 0) {
        If (Test-Path $Global:LogFile) {
            $Global:LogFile.ToString()
            $File1 = $Global:LogFile.Split(".")
            $Filename1 = $File1[0]+"_ERROR"+"."+$File1[1]
            Rename-Item $Global:LogFile -NewName $Filename1 -Force
        }
    } else {
        Out-File -FilePath $Global:BuildLog -InputObject "08-Dell Client Configuration Toolkit" -Append -Force
    }
}

cls
ConsoleTitle "Dell Client Configuration Toolkit"
GetRelativePath
ProcessLogFile
InstallCCTK
CCTKSetting "PowerLoss" "acpower" "last" ""
CCTKSetting "Advanced Battery Charge" "advbatterychargecfg" "enable" ""
CCTKSetting "On-Board AGP Slot" "agpslot" "enable" ""
CCTKSetting "Resume from Suspended Mode" "alarmresume" "enable" ""
CCTKSetting "Ambient Light Sensor" "amblightsen" "enable" ""
CCTKSetting "Auto On" "autoon" "disable" ""
CCTKSetting "Battery Charge" "batteryslicecfg" "express" ""
CCTKSetting "Bluetooth Devices" "bluetoothdevice" "enable" ""
CCTKSetting "Camera" "camera" "enable" ""
CCTKSetting "Cellular Radio" "cellularradio" "enable" ""
CCTKSetting "Chassis Intrustion" "chasintrusion" "disable" ""
CCTKSetting "Clear BIOS Event Log" "clearsel" "yes" ""
CCTKSetting "Disable WiFi for Ethernet" "controlwwanradio" "enable" ""
CCTKSetting "CPU eXecute Disable" "cpuxdsupport" "disable" ""
CCTKSetting "C states" "cstatesctrl" "enable" ""
CCTKSetting "System Power Mode" "deepsleepctrl" "disable" ""
CCTKSetting "Dell Reliable Memory Technology" "drmt" "enable" ""
CCTKSetting "Built-in NIC" "embnic1" "on" ""
CCTKSetting "Embedded SATA RAID Controller" "embsataraid" "raid" ""
CCTKSetting "Embedded SD Card" "embsdcard" "on" ""
CCTKSetting "Energy Star logo" "energystarlogo" "enable" ""
CCTKSetting "Serial ATA (e-sata) port" "esataport" "auto" ""
CCTKSetting "Express Battery Charge" "expresscharge" "enable" ""
CCTKSetting "Fastboot" "fastboot" "automatic" ""
CCTKSetting "Ready Boost" "flashcachemodule" "enable" ""
CCTKSetting "HDD Acoustic Mode" "hddacousticmode" "performance" ""
CCTKSetting "HDD Protection" "hddprotection" "on" ""
CCTKSetting "HDD Free Fall Protection" "hdfreefallprotect" "enable" ""
CCTKSetting "Hot Docking" "hotdock" "enable" ""
CCTKSetting "WxAN Hotkey" "htkeywxanradio" "enable" ""
CCTKSetting "CPU Hardware Prefetcher" "hwprefetcher" "enable" ""
CCTKSetting "Hardware Prefetcher" "hwswprefetch" "enable" ""
CCTKSetting "CD drive" "idecdrom" "auto" ""
CCTKSetting "Latitude ON" "instanton" "disable" ""
CCTKSetting "Integrated Sound Device" "integratedaudio" "enable" ""
CCTKSetting "Integrated USB Hub" "integratedusbhub" "highspeed" ""
CCTKSetting "Internal Mini PCI Slot" "internalminipci" "enable" ""
CCTKSetting "Internal USB Ports" "internalusb" "on" ""
CCTKSetting "Ultra Wide Band (UWB) Card" "interwirelessuwb" "enable" ""
CCTKSetting "Intel Rapid Start Technology" "intlrapidstart" "enable" ""
CCTKSetting "Intel Smart Connect" "intlsmartconnect" "disable" ""
CCTKSetting "Keyboard Click Sound" "keyboardclick" "enable" ""
CCTKSetting "Keyboard Illumination" "keyboardillumination" "auto" ""
CCTKSetting "Booting to Latitude ON" "latitudeon" "disable" ""
CCTKSetting "Ability to boot to the Latitude ON" "latitudeonflash" "disable" ""
CCTKSetting "Limit Maximum CPUID Function" "limitcpuidvalue" "off" ""
CCTKSetting "Hyper Threading" "logicproc" "enable" ""
CCTKSetting "Microphone" "microphone" "enable" ""
CCTKSetting "Multiple CPU Cores" "multicpucore" "enable" ""
CCTKSetting "Multiple Displays" "multidisplay" "enable" ""
CCTKSetting "Number Lock" "numlock" "on" ""
CCTKSetting "Onboard 1394 Controller" "onboard1394" "enable" ""
CCTKSetting "Onboard Modem" "onboardmodem" "enable" ""
CCTKSetting "Onreader" "onreader" "disable" ""
CCTKSetting "PCI Slots" "pcislots" "enable" ""
CCTKSetting "<F12> boot menu" "postf12key" "enable" ""
CCTKSetting "<F2> boot menu" "postf2key" "enable" ""
CCTKSetting "MEBx hotkey" "postmebxkey" "on" ""
CCTKSetting "Power Button" "powerbutton" "enable" ""
CCTKSetting "Primary Battery Charging" "primarybatterycfg" "express" ""
CCTKSetting "Primary IDE Master Channel" "primidemast" "auto" ""
CCTKSetting "Primary Parallel IDE Slave Channel" "primideslav" "auto" ""
CCTKSetting "Rear Single USB Ports" "rearsingleusb" "on" ""
CCTKSetting "Report Keyboard Errors" "rptkeyerr" "enable" ""
CCTKSetting "Selective USB feature" "safeusb" "disable" ""
CCTKSetting "SATA port 0" "sata0" "auto" ""
CCTKSetting "SATA port 1" "sata1" "auto" ""
CCTKSetting "SATA port 2" "sata2" "auto" ""
CCTKSetting "SATA port 3" "sata3" "auto" ""
CCTKSetting "SATA port 4" "sata4" "auto" ""
CCTKSetting "SATA port 5" "sata5" "auto" ""
CCTKSetting "SATA port 6" "sata6" "auto" ""
CCTKSetting "SATA port 7" "sata7" "auto" ""
CCTKSetting "SATA Controllers" "satactrl" "enable" ""
CCTKSetting "Serial Port 1" "serial1" "auto" ""
CCTKSetting "Serial Port 2" "serial2" "auto" ""
CCTKSetting "Serial Port Communication" "serialcomm" "on" ""
CCTKSetting "Smart Card Reader" "smartcardreader" "enable" ""
CCTKSetting "SMART Errors" "smarterrors" "enable" ""
CCTKSetting "Built-In Speaker" "speakervol" "enable" ""
CCTKSetting "Speedstep" "speedstep" "automatic" ""
CCTKSetting "POST Splash Screen" "splashscreen" "enable" ""
CCTKSetting "ACPI Standby State" "standbystate" "s3" ""
CCTKSetting "Tablet Buttons" "tabletbuttons" "enable" ""
CCTKSetting "Trusted Execution" "trustexecution" "off" ""
CCTKSetting "Intel Turbo Boost" "turbomode" "enable" ""
CCTKSetting "USB 3.0" "usb30" "enable" ""
CCTKSetting "USB port 00" "usbport00" "enable" ""
CCTKSetting "USB port 01" "usbport01" "enable" ""
CCTKSetting "USB port 02" "usbport02" "enable" ""
CCTKSetting "USB port 03" "usbport03" "enable" ""
CCTKSetting "USB port 04" "usbport04" "enable" ""
CCTKSetting "USB port 05" "usbport05" "enable" ""
CCTKSetting "USB port 06" "usbport06" "enable" ""
CCTKSetting "USB port 07" "usbport07" "enable" ""
CCTKSetting "USB port 08" "usbport08" "enable" ""
CCTKSetting "USB port 09" "usbport09" "enable" ""
CCTKSetting "USB port 10" "usbport10" "enable" ""
CCTKSetting "USB port 11" "usbport11" "enable" ""
CCTKSetting "USB port 12" "usbport12" "enable" ""
CCTKSetting "USB port 13" "usbport13" "enable" ""
CCTKSetting "USB port 14" "usbport14" "enable" ""
CCTKSetting "USB port 15" "usbport15" "enable" ""
CCTKSetting "User Accessible USB ports" "usbports" "enable" ""
CCTKSetting "External USB Ports" "usbportsexternal" "enable" ""
CCTKSetting "Front USB Ports" "usbportsfront" "enable" ""
CCTKSetting "USB PowerShare" "usbpowershare" "enable" ""
CCTKSetting "USB Rear Dual Stack" "usbreardual" "on" ""
CCTKSetting "USB Second Rear Dual Stack" "usbreardual2stack" "on" ""
CCTKSetting "USB Rear Quad Ports" "usbrearquad" "on" ""
CCTKSetting "USB Wake" "usbwake" "disable" ""
CCTKSetting "Virtualization" "virtualization" "enable" ""
CCTKSetting "Virtualization Technology for Direct I/O" "vtfordirectio" "on" ""
CCTKSetting "Wake-on-LAN" "wakeonlan" "lanorwlan" ""
CCTKSetting "WiFi Locator" "wifilocator" "enable" ""
CCTKSetting "Wireless Adapter" "wirelessadapter" "enable" ""
CCTKSetting "Wireless LAN Module" "wirelesslan" "enable" ""
CCTKSetting "Ultra Wide Band (UWB) Switch" "wirelessuwb" "enable" ""
CCTKSetting "Bluetooth Control Switch" "wirelesswitchbluetoothctrl" "enable" ""
CCTKSetting "Cellular Control Switch" "wirelesswitchcellularctrl" "enable" ""
CCTKSetting "Wireless Gigabit Switch" "wirelesswitchwigigctrl" "enable" ""
CCTKSetting "Disable Floppy" "bootorder" "disabledevice" "floppy"
CCTKSetting "Boot Order" "bootorder" "sequence" "hdd.1,hdd.2,cdrom,usbdev,embnic"
ProcessLogFile
Start-Sleep -Seconds 10

10 April 2014

How to remove shortcuts during an MSI installation

It is very easy to stop shortcuts from being installed during an MSI installation. The first thing you will need is ORCA or Super ORCA. These applications will allow you to open up and edit the contents of the MSI. Once you have the MSI opened up in either app, go to the shortcut table as shown in the pic below. Once there, right-click on each row and click drop-row. That is all that is to preventing shortcuts from being installed.


07 April 2014

Message containing password has been suppressed error

In my experience, this error was caused by me manually editing the unattend.xml file associated with an imported operating system. Specifically, I had manually entered the UnattendedJoin credentials within the unattend.xml file. Apparently when you manually enter the credentials in there, and they are in plain text, this error will occur when you override those credentials in the customsettings.ini file. To fix this, either re-import the operating system image or make sure the plain text credentials match in both the customsettings.ini and the unattend.xml files.

13 March 2014

Get list of installed printers

This function will get the list of printers installed for a user. It will also get the Default Printer. It outputs the list to Printers.txt, located at the location where the script is executed.

You can download the script here.


Function GetRelativePath {
    $Global:RelativePath=(split-path $SCRIPT:MyInvocation.MyCommand.Path -parent)+"\"
}

Function GetPrinterList {

    #Declare Local Memory
    Set-Variable -Name Count -Scope Local -Force
    Set-Variable -Name DefaultPrinter -Scope Local -Force
    Set-Variable -Name Printers -Scope Local -Force
    Set-Variable -Name Temp -Scope Local -Force
    
    If (Test-Path -Path $Global:RelativePath"Printers.txt") {
        Remove-Item -Path $Global:RelativePath"Printers.txt" -Force
    }
    $DefaultPrinter = Get-WmiObject -Query " SELECT * FROM Win32_Printer WHERE Default=$true"
    $DefaultPrinter = $DefaultPrinter.ToString()
    $DefaultPrinter = $DefaultPrinter -replace [char]34,""
    $DefaultPrinter = $DefaultPrinter -replace "\\\\","\"
    $DefaultPrinter = $DefaultPrinter.split("=")
    $Temp = "Default Printer: "+$DefaultPrinter[$DefaultPrinter.Length-1]
    $Temp | Add-Content -Path $Global:RelativePath"Printers.txt"
    $Printers = Get-WmiObject -Query " SELECT * FROM Win32_Printer WHERE Default=$false"
    For ($Count=0; $Count -lt $Printers.Length; $Count++) {
        $Temp = $Printers[$Count]
        $Temp = $Temp.ToString()
        $Temp = $Temp -replace [char]34,""
        $Temp = $Temp -replace "\\\\","\"
        $Temp = $Temp.split("=")
        $Temp = "Printer: "+$Temp[1]
        $Temp | Add-Content -Path $Global:RelativePath"Printers.txt"
        Write-Host $Temp
    }
    
    #Cleanup Local Memory
    Remove-Variable -Name Count -Scope Local -Force
    Remove-Variable -Name DefaultPrinter -Scope Local -Force
    Remove-Variable -Name Printers -Scope Local -Force
    Remove-Variable -Name Temp -Scope Local -Force
    
}

06 March 2014

Creating Active Setup Registry Key

Here is a script I just wrote that will create an active setup registry key. It prompts you for the title, description, command line execution string, and version. It generates a unique GUID to name the registry key. It then generates the registry key file and places it in the same directory as the script was executed from.

You can download the script from here.

<#
     Author: Mick Pletcher
       Date: 06 March 2014
   Synopsis: This will generate the active setup registry key to
             deploy to machines so it iterates through every user that
             logs onto a machine.
Description: This will prompt for the title, brief description, version, and
             command line execution string. It then generates the .reg file
             and places it in the same directory as the script was executed from.
#>

Function GetRelativePath{  

    #Declare Local Memory
    Set-Variable -Name RelativePath -Scope Local -Force
    
    $RelativePath = (split-path $SCRIPT:MyInvocation.MyCommand.Path -parent)+"\"
    Return $RelativePath
    
    #Cleanup Local Memory
    Remove-Variable -Name RelativePath -Scope Local -Force
    
}
 
Function GenerateGUID {

    #Declare Local Memory
    Set-Variable -Name GetGUID -Scope Local -Force
    
    $GetGUID = [guid]::NewGuid()
    $GetGUID = $GetGUID.ToString().ToUpper()
    
    return $GetGUID

    #Cleanup Local Memory
    Remove-Variable -Name GetGUID -Scope Local -Force
    
}

Function GetKeyInfo {

    #Declare Local Memory
    Set-Variable -Name ComponentID -Scope Local -Force
    Set-Variable -Name Description -Scope Local -Force
    Set-Variable -Name StubPath -Scope Local -Force
    Set-Variable -Name Version -Scope Local -Force
    
    $ComponentID = Read-Host "Enter the title"
    $Description = Read-Host "Enter brief description"
    $Version = Read-Host "Enter the version number"
    $StubPath = Read-Host "Enter the command line execution string"
    $StubPath = $StubPath -replace '\\','\\'
    Return $ComponentID, $Description, $Version, $StubPath
    
    #Cleanup Local Memory
    Remove-Variable -Name ComponentID -Scope Local -Force
    Remove-Variable -Name Description -Scope Local -Force
    Remove-Variable -Name StubPath -Scope Local -Force
    Remove-Variable -Name Version -Scope Local -Force
    
}

Function GenerateRegKey ($RelativePath, $GUID, $KeyInfo) {

    #Declare Local Memory
    Set-Variable -Name File -Scope Local -Force
    Set-Variable -Name Text -Scope Local -Force
    
    $File = $RelativePath+"ActiveSetup.reg"
    If (Test-Path $File) {
        Remove-Item -Path $File -Force
    }
    New-Item -Name ActiveSetup.reg -Path $RelativePath -ItemType file -Force
    $Text = "Windows Registry Editor Version 5.00"
    Add-Content -Path $File -Value $Text -Force
    $Text = [char]13
    Add-Content -Path $File -Value $Text -Force
    $Text = "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\{"+$GUID+"}]"
    Add-Content -Path $File -Value $Text -Force
    $Text = "@="+[char]34+$KeyInfo[1]+[char]34
    Add-Content -Path $File -Value $Text -Force
    $Text = [char]34+"ComponentID"+[char]34+"="+[char]34+$KeyInfo[0]+[char]34
    Add-Content -Path $File -Value $Text -Force
    $Text = [char]34+"StubPath"+[char]34+"="+[char]34+$KeyInfo[3]+[char]34
    Add-Content -Path $File -Value $Text -Force
    $Text = [char]34+"Version"+[char]34+"="+[char]34+$KeyInfo[2]+[char]34
    Add-Content -Path $File -Value $Text -Force

    #Cleanup Local Memory
    Remove-Variable -Name File -Scope Local -Force
    Remove-Variable -Name Text -Scope Local -Force

}

#Declare Global Memory
Set-Variable -Name GUID -Scope Local -Force
Set-Variable -Name KeyInfo -Scope Local -Force
Set-Variable -Name RelativePath -Scope Local -Force

cls
$RelativePath = GetRelativePath
$GUID = GenerateGUID
$KeyInfo = GetKeyInfo
GenerateRegKey $RelativePath $GUID $KeyInfo

#Cleanup Global Memory
Remove-Variable -Name GUID -Scope Local -Force
Remove-Variable -Name KeyInfo -Scope Local -Force

26 January 2014

How to clean up your Facebook profile of old posts, messages, pictures, and videos

All of us have posts that we want to clean up from the past. They may be posts that are now embarrassing, posts with exes that we want gone off of our profile, or maybe you are interviewing for a job that you know asks for your credentials and you want to make sure your profile looks good. Facebook does not allow the average user to be able to easily see posts from a long time ago. If you are a geek and know how to use Facebook's FQL, you can query all previous posts for specific keywords. There are a couple of options:

  1. You can go into the general account setting and click on Download a copy of your Facebook data. This will download all of your facebook data divided up into separate files for each section of your profile, including all of your pictures and videos. Once you have the download, you can then open up the wall.htm file in Excel. It contains all of your wall posts from the beginning of your profile. In order to use this, you can search the spreadsheet for keywords. The results will have the exact date/time it was posted. You can then go to your Facebook profile and find that exact post by clicking on the year first, then the month, and finally scrolling through all posts in that month to find the specific post. You can then click on the drop-down and select Delete.
  2. There is a Facebook app called Search My Posts. This app will allow you to enter keywords and will parse through your profile and find all posts with that keyword. For posts on your profile, this will allow you to click on the Link to Post to take you directly to the post. You can then click on the drop-down and select Delete. This app will also list posts you did on other people's profiles, but does not have a link to the post. You will have to note the date/time, go to the user's profile, and then click on the year/month to parse through all posts for that month until you find your post. At that point, you can delete your post. The same goes for posts you made in groups.
As for recommendations, this solution pertains to both of the above posts. You cannot remove a recommendation from Facebook. You must go to the web page that you clicked on the Facebook recommendation. The way to do this is to click on the link to the Facebook post, if you are using option 2, or go to the date it was posted for option 1, and then click on the link in the Facebook post to take you to the page that was recommended. It is there that you can now click on the Facebook recommend again to remove the recommendation. Once you remove the recommendation, the post disappears off of Facebook.

As far as Facebook messages goes, Facebook has archived the messages in the past, meaning they were not deleted. When you go into your messages box, there is an archive box that you can click on. It is there that you will find all of the messages from the past that were archived. They can now be deleted. You first click on the message. Next, you click on actions and click Delete Conversation. That will permanently delete the message from your Facebook profile. 

For your pictures and videos, I suggest using the first option, or manually parsing through them on your profile. 

Keeping your Facebook profile safe and out of trouble in civil court, criminal court, work, and home life is wise. I would leave out alcohol, guns, sex, violence, and topics of controversy off of Facebook. These topics can cause you to lose your job, lose your family, be sued, or incriminate you in a criminal court system. If you have any of these topics on Facebook, I suggest cleaning them off. I am not a criminal/civil/psychology expert, but common sense will tell you these things, especially in today's digital world. Information is magnified and misconstrued by many because the reader injects their own emotion into the text, not yours, thereby possibly leading to ramifications. 

How to search all of your Youtube comments

If you have been trying to find a way to search through all of your Youtube comments you have ever posted, there is a way. Youtube does not seem to have a feature that allows for you to see all of your comments, but you can use their parent company, Google, to find them. Go to google.com and enter the line below. Change the <Youtube Account Name> to your Youtube account name and then hit <enter>. All of your Youtube comments will pop up.

site:youtube.com/all_comments "<Youtube Account Name>"

19 January 2014

How to exclude a directory on the destination while using the mirror switch in a Robocopy

I ran into a situation where we had to mirror our local DFS to all of the remote DFS locations. The problem was that there was one directory in each of the remote shares that was unique to that location and had to remain untouched. The first thing I thought of was to have powershell parse through the base directory trees and perform a recursive robocopy on each base. There were 177 with thousands of subdirectories under each one. That was just too much. I finally figured out to make sure there was also a directory in the source DFS named the same as the one in the destination that is to remain unchanged. Once that directory was in the source, I was able to exclude the directory from the source and it left the directory in the destination untouched. 

16 January 2014

Deploying enormous packages across a WAN

As many of you might know, deploying huge packages through SCCM can be a challenge. The first question you might ask is, define enormous. IMO, anything over the default 5GB client cache size is enormous. Working in the architecture/engineering industry, I encounter this issue quite often with Bentley, Autodesk, and Adobe applications. There are several options to address this.

  1. You can increase the cache sizes to accommodate the size, but when you are talking about packages that are 40+ gigs in size, that is really not an option, especially when you are using SSD drives, where you're sacrificing space for speed. The issue is that you now need double the space on a system to perform the install. Another issue is pushing the package to the distribution points. If you do it across your LAN, it's going to take a LONG time, even with 10 meg links. You could use the option of exporting the package to a thumb drive from SCCM, and mailing it to the locations to update the distribution points. You will also need to re-size the cache size on all machines before and after the deployment. 
  2. You can create a package in SCCM that points to a network share and runs from it. To use this option, you need a network share in all remote locations. This is the option I use to facilitate enormous packages. We keep our remote network shares updated via robocopy from our home office share. This not only lets us distribute from SCCM, but it also provides a copy of the package in remote locations in the case we need to run a repair or install a single copy. 
If you choose option 2, here is a guide to how we implement this.


  1. Create a single application deployment in SCCM
  2. Under the Deployment Types, create a deployment type for each location that has a OU. This will allow for you to make the deployment type specific to that site. I name the deployment type by the name of our office location (i.e. Nashville, Atlanta, etc.)
  3. Under the content tab, leave content location blank.
  4. Under the programs tab, enter the installation and uninstall programs, making sure you populate the start in fields beneath them with the location of the install source within the OU specified.
  5. Once you have all of the tabs completed, go back to the Requirements tab, click add. Under Category, select device and under condition, select organizational unit. Click add and select Browse to select the OU for this specific location. 
  6. Repeat steps 1 through 3 until you have created a deployment type for all of your remote locations.
That is all that is to pointing a deployment package to the install source and not using the distribution points. 

NOTE: In order to make this work, you will need a network share at each OU, otherwise the install will take place across the WAN. Also, the remote network shares will need the package robocopied to them first. 

15 January 2014

Adding environmental variables across all profiles without a reboot

This can be done without having to reboot the machine. You want to use setx.exe to create the new variable. The format to do this is:


  • setx.exe <environmental variable name> <value> /m 
  • i.e. setx.exe MIG_IGNORE_PROFILE_MISSING 1 /m
In order to not have to reboot the machine, go to task manager and end the process tree of explorer.exe. Open explorer.exe back up and the new environmental variable is now present. Ending the process of just explorer.exe will not make the environmental variable visible.

13 January 2014

Apply Updates and Hotfixes online

This script is intended to apply updates and hotfixes after the OS has been installed and is online. There are windows updates that cannot be installed offline, as described in this blog. For these updates, I have written a script that will apply the updates using wusa.exe. In order to properly install them, I recommend numbering the filenames so that the script will read them in the correct sequence. I added 01-, 02-, 03-, etc in front of the filename. The script now reads the files in that sequence. The script has been written so that it only reads msu files. You can download this script here.


 #*******************************************************************************  
 #   Author: Mick Pletcher  
 #    Date: 01 January 2014  
 #  
 #   Program: Online Windows Updates Installer  
 #*******************************************************************************  
   
 #Declare Local Memory  
 Set-Variable -Name File -Scope Local -Force  
   
 Function DeclareGlobalMemory {  
   
      Set-Variable -Name Files -Scope Global -Force  
      Set-Variable -Name RelativePath -Scope Global -Force  
   
 }  
   
 Function GlobalMemoryCleanup {  
   
      Remove-Variable -Name Files -Scope Global -Force  
      Remove-Variable -Name RelativePath -Scope Global -Force  
   
 }  
   
 Function RenameWindow ($Title) {  
   
      #Declare Local Memory  
      Set-Variable -Name a -Scope Local -Force  
        
      $a = (Get-Host).UI.RawUI  
      $a.WindowTitle = $Title  
        
      #Cleanup Local Memory  
      Remove-Variable -Name a -Scope Local -Force  
 }  
   
 Function GetRelativePath {  
      $Global:RelativePath=(split-path $SCRIPT:MyInvocation.MyCommand.Path -parent)+"\"  
 }  
   
 Function GetFiles {  
   
      $Global:Files = Get-ChildItem -Path $Global:RelativePath  
   
 }  
   
 Function CreateTempFolder ($FolderName) {  
        
      $FolderName = "c:\temp\"+$FolderName  
      New-Item -Path $FolderName -ItemType Directory -Force  
        
 }  
   
 Function RemoveTempFolder ($FolderName) {  
        
      $FolderName = "c:\temp\"+$FolderName  
      Remove-Item -Path $FolderName -Recurse -Force  
        
 }  
   
 Function ExtractCAB ($Name) {  
   
      #Declare Local Memory  
      Set-Variable -Name arguments -Scope Local -Force  
      Set-Variable -Name Dest -Scope Local -Force  
      Set-Variable -Name Source -Scope Local -Force  
        
      $Source = $Global:RelativePath+$Name  
      $Dest = "c:\temp\"+$Name.Substring(0,$Name.Length-4)  
      $arguments = "–F:*"+[char]32+$Source+[char]32+$Dest  
      Start-Process -FilePath "expand.exe" -ArgumentList $arguments -Wait -PassThru  
   
      #Cleanup Local Memory  
      Remove-Variable -Name arguments -Scope Local -Force  
      Remove-Variable -Name Dest -Scope Local -Force  
      Remove-Variable -Name Source -Scope Local -Force  
 }  
   
 #Function ApplyWindowsUpdate ($Name,$Directory) {  
 #  
 #     #Declare Local Memory  
 #     Set-Variable -Name arguments -Scope Local -Force  
 #       
 #     $Name = $Name.Substring(0,$Name.Length-4)  
 #     $Name = $Name+".cab"  
 #     $arguments = "/Online /Add-Package /PackagePath:"+"c:\temp\"+$Directory+"\"+$Name  
 #     Start-Process -FilePath "DISM.exe" -ArgumentList $arguments -Wait -PassThru  
 #  
 #     #Cleanup Local Memory  
 #     Remove-Variable -Name arguments -Scope Local -Force  
 #  
 #}  
   
 Function ApplyWindowsUpdate ($Name) {  
   
      #Declare Local Memory  
      Set-Variable -Name App -Scope Local -Force  
      Set-Variable -Name arguments -Scope Local -Force  
      Set-Variable -Name index -Scope Local -Force  
      Set-Variable -Name Result -Scope Local -Force  
        
      $App = $Name  
      $index = $App.IndexOf("-KB")+1  
      $App = $App.Substring(0,$App.Length-4)  
      $App = $App.Substring($index)  
      Write-Host "Installing"$App"....." -NoNewline  
      $arguments = $Global:RelativePath+$Name+[char]32+"/quiet /norestart"  
      $Result = (Start-Process -FilePath "wusa.exe" -ArgumentList $arguments -Wait -PassThru).ExitCode  
      If ($Result -eq "3010") {  
           Write-Host "Succeeded" -ForegroundColor Yellow  
      } else {  
           Write-Host "Failed with error code"$Result -ForegroundColor Red  
      }  
   
      #Cleanup Local Memory  
      Remove-Variable -Name App -Scope Local -Force  
      Remove-Variable -Name arguments -Scope Local -Force  
      Remove-Variable -Name index -Scope Local -Force  
      Remove-Variable -Name Result -Scope Local -Force  
   
 }  
   
 cls  
 RenameWindow "Windows Updates"  
 DeclareGlobalMemory  
 GetRelativePath  
 GetFiles  
 foreach ($File in $Files) {  
      if (($File.Attributes -ne "Directory") -and ($File.Name -like "*.msu")) {  
           ApplyWindowsUpdate $File.Name  
      }  
 }  
 GlobalMemoryCleanup  
   
 #Cleanup Local Memory  
 Remove-Variable -Name File -Scope Local -Force  
   

09 January 2014

MDT 2013 and Pentium 4 Systems

My firm is getting the first tablet machines in that will be Windows 8.1. This requires MDT 2013 and ADK 8.1. The problem is that we still have a few machines that are Pentium 4 systems, specifically Dell Precision Workstation 380s. The problem is that the Pentium 4 processor is not compatible with Windows 8.1 and ADK. The system will crash when the Windows 8.1 PE begins to load with the following message:

Your PC needs to restart.
Please hold down the power button.
Error Code:0x0000005D
Parameters:
0x030F0209
0x746E6547
0X49656E69
0X6C65746E

The resolution provided by Microsoft is to either upgrade the processor or downgrade to WAIK and MDT 2012.

There is a slight possibility of a resolution that I am going to work on when I get some time and that is to modify a WIM from MDT 2012 to point to the MDT 2013 server. I do not know if this will work or not. I did go in and replace the winpe.wim files MDT uses to build the boot wims with MDT 2012 winpe.wim files. MDT 2013 instantly failed. For now, the only two resolutions we have until we get the last of the older machines out of service is to have two different MDT servers, one for the old systems and one for the newer, or just create an image for the 380 and use the MDT 2013 for all of the rest.

14 December 2013

Tips on replacing the screen on an iPad 2 and up

I had the not so pleasure of replacing the screen on my wife's iPad 2. There are plenty of videos on Youtube on how to do this. I am providing some tips on what I learned while doing this.
  • It takes about 30 seconds of leaving the hair dryer on high with hot air to soften the adhesive
  • Make sure you keep the hair dryer only on the edge of the iPad blowing away from it. You do not want to overheat the internal parts of it.
  • Make sure you wear glasses or goggles. If the glass shatters, which it is a good possibility if the screen is cracked all the way across, the glass can fly up at your face.
  • Make sure you do this in a room where there is no carpet. If the screen shatters while you are softening the adhesive with the dryer, it will blow some of the glass around the room and there are very, very fine pieces that it breaks up into.
  • Go ahead and purchase the home button, wifi antenna flex cable, and the power switch volume on/off flex cable to replace while doing this. They are very cheap and worth replacing while you have the device open.
  • Use 3M double sided tape. It will be much easier to reopen if you ever have to again.

12 December 2013

Verify SCCM can see Application GUIDs

I was deploying an application through SCCM and it continued to fail every time, although the app was completely installed. I knew it had to be with the verification process. I went through and entered all of the GUIDs for the apps being installed as the verification. I wrote the script below to verify WMI could see the GUIDs and come to find out, they were not registered in the HKCR, but the apps were registered in the HKLM, which makes it show up in the add/remove programs. This resolved my issue of the failure.

Create a text file named GUIDs.txt and enter a series of GUIDs. The script will read these GUIDs and then query WMI to see if they are registered. If they are not registered, nothing appears. If they are registered, all pertinent WMI data is displayed. At the end, it will list all of the GUIDs that WMI could not find. At this point, remove those GUIDs from the SCCM verification and the package should install with no issues.

You can download the script from here.

 #*******************************************************************************  
 #   Author: Mick Pletcher  
 #    Date: 12 December 2013  
 #  
 #   Program: Verify GUIDs  
 #*******************************************************************************  
   
 cls  
 Set-Variable -Name App -Value $null  
 Set-Variable -Name File -Force  
 Set-Variable -Name GUID -Force  
 Set-Variable -Name RelativePath -Scope Global -Force  
   
 $MissingGUIDs = @()  
 Function GetRelativePath {  
      $Global:RelativePath=(split-path $SCRIPT:MyInvocation.MyCommand.Path -parent)+"\"  
 }  
   
 GetRelativePath  
 $File = Import-Csv -Header GUID1 $Global:RelativePath"GUIDs.txt"  
 Foreach ($GUID in $File) {  
      #Write-Host $GUID.GUID1  
      #Get-WmiObject win32_product | Where-Object {$_.IdentifyingNumber -match "{5783F2D7-D004-0409-1102-0060B0CE6BBA}"}  
      $App = Get-WmiObject win32_product | Where-Object {$_.IdentifyingNumber -match $GUID.GUID1}  
      $App  
      If ($App.Name -like "") {  
           $MissingGUIDs += $GUID.GUID1  
      }  
      $App = $null  
 }  
 Write-Host  
 Write-Host "Missing GUIDs"  
 Write-Host "-------------"  
 $MissingGUIDs  
   
 #Cleanup Global Memory  
 Remove-Variable -Name App -Force  
 Remove-Variable -Name File -Force  
 Remove-Variable -Name GUID -Force  
 Remove-Variable -Name MissingGUIDs -Force  
 Remove-Variable -Name RelativePath -Scope Global -Force  
   

09 December 2013

Autodesk 2014 Uninstaller

Here is a script that will uninstall Autodesk 2014. This will uninstall BDS Ultimate, which should cover all Revit 2014 applications. This also uninstalls Civil 3D 2014, but does not cover anything else from the IDSP suite. There are three sections in this script. You can enter the argument at the command line to uninstall architecture, engineering, and Civil 3D. If there is no argument, it defaults the uninstalling BDS Ultimate.

You can download the script here.


 #*******************************************************************************  
 #   Author: Mick Pletcher  
 #    Date: 04 December 2013  
 #  
 #   Program: Autodesk 2014 Uninstaller  
 #*******************************************************************************  
   
 Function RenameWindow ($Title) {  
   
      #Declare Local Memory  
      Set-Variable -Name a -Scope Local -Force  
        
      $a = (Get-Host).UI.RawUI  
      $a.WindowTitle = $Title  
        
      #Cleanup Local Memory  
      Remove-Variable -Name a -Scope Local -Force  
 }  
   
 Function UninstallName($Description) {  
   
      #Declare Local Memory  
      Set-Variable -Name AppName -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
      Set-Variable -Name Result -Scope Local -Force  
      Set-Variable -Name GUID -Scope Local -Force  
      Set-Variable -Name Output -Scope Local -Force  
      Set-Variable -Name Output1 -Scope Local -Force  
        
      #Change '%application%' to whatever app you are calling  
      $Description = [char]34+"description like"+[char]32+[char]39+[char]37+$Description+[char]37+[char]39+[char]34  
      $Output1 = wmic product where $Description get Description  
      $Output1 | ForEach-Object {  
           $_ = $_.Trim()  
        if(($_ -ne "Description")-and($_ -ne "")){  
          $AppName = $_  
        }  
      }  
      If ($AppName -eq $null) {  
           return  
      }  
      Write-Host "Uninstalling"$AppName"....." -NoNewline  
      $Output = wmic product where $Description get IdentifyingNumber  
      $Output | ForEach-Object {  
           $_ = $_.Trim()  
             if(($_ -ne "IdentifyingNumber")-and($_ -ne "")){  
               $GUID = $_  
             }  
      }  
      $Arguments = "/X"+[char]32+$GUID+[char]32+"/qb- /norestart"  
      $Result = (Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      If ($Result -eq 0) {  
           Write-Host "Uninstalled" -ForegroundColor Yellow  
      } else {  
           Write-Host "Failed with error code"$Result -ForegroundColor Red  
      }  
        
      #Cleanup Local Memory  
      Remove-Variable -Name AppName -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
      Remove-Variable -Name Result -Scope Local -Force  
      Remove-Variable -Name GUID -Scope Local -Force  
      Remove-Variable -Name Output -Scope Local -Force  
      Remove-Variable -Name Output1 -Scope Local -Force  
        
 }  
   
 Function UninstallGUID($Application,$GUID) {  
        
      #Declare Local Variables  
      Set-Variable -Name Result -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  
        
      Write-Host $Application"...." -NoNewline  
      $Arguments = "/x "+$GUID+" /qb- /norestart"  
      $Result = (Start-Process -FilePath msiexec.exe -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      If ($Result -eq 0) {  
           Write-Host "Uninstalled" -ForegroundColor Yellow  
      } elseIf ($Result -eq 1605) {  
           Write-Host "Not Installed" -ForegroundColor Yellow  
      } else {  
           Write-Host "Failed with error code"$Result -ForegroundColor Red  
      }  
        
      #Cleanup Local Variables  
      Remove-Variable -Name Result -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  
        
 }  
   
 cls  
 RenameWindow "Autodesk 2014 Uninstaller"  
 #Autodesk Prerequisites  
      #UninstallName "Microsoft Visual C++ 2008 SP1 Redistributable (x64)"  
      #UninstallName "Microsoft Visual C++ 2008 SP1 Redistributable (x64) 9.0.30729.6161"  
      #UninstallName "Microsoft Visual C++ 2005 Redistributable (x86)"  
      #UninstallName "Microsoft Visual C++ 2005 Redistributable (x64)"  
      #UninstallName "Microsoft Visual C++ 2008 SP1 Redistributable (x86)"  
      #UninstallName "Microsoft Visual C++ 2008 SP1 Redistributable (x86) 9.0.30729.6161"  
      #UninstallName "Microsoft Visual C++ 2010 SP1 Redistributable (x86)"  
      #UninstallName "Microsoft Visual C++ 2010 SP1 Redistributable (x64)"  
      #UninstallName "Microsoft Visual C++ 2008 x86 ATL Runtime 9.0.30729"  
      #UninstallName "Microsoft Visual C++ 2008 x86 MFC Runtime 9.0.30729"  
      #UninstallName "Microsoft Visual C++ 2008 x86 CRT Runtime 9.0.30729"  
      #UninstallName "Microsoft Visual C++ 2008 x86 OpenMP Runtime 9.0.30729"  
      #UninstallName "Microsoft Visual C++ 2008 x64 ATL Runtime 9.0.30729"  
      #UninstallName "Microsoft Visual C++ 2008 x64 MFC Runtime 9.0.30729"  
      #UninstallName "Microsoft Visual C++ 2008 x64 CRT Runtime 9.0.30729"  
      #UninstallName "Microsoft Visual C++ 2008 x64 OpenMP Runtime 9.0.30729"  
      #UninstallName "Microsoft Visual C++ 2005 SP1 Redistributable ATL Security Update (x86)"  
      #UninstallName "Microsoft Visual C++ 2005 SP1 Redistributable ATL Security Update (x64)"  
      #UninstallName ".NET Framework Runtime 3.5 SP1"  
      #UninstallName ".NET Framework Runtime 4.5"  
      #UninstallName "DirectX® Runtime"  
      #UninstallName "FARO LS 1.1.501.0 (64bit)"  
      #UninstallName ".NET Framework Runtime 4.0"  
      #UninstallName ".NET Framework Runtime 4.0 KB2468871"  
      #UninstallName "MSXML 6.0 Parser"  
      #UninstallName "Microsoft Windows Media Format 9.5 Series Runtime"  
      #UninstallName "Microsoft WSE 3.0 Runtime"  
      #UninstallName ".NET Framework Runtime 4.0"  
      #UninstallName ".NET Framework Runtime 4.0 KB2468871"  
      #UninstallName "Microsoft Visual Basic for Applications 7.1 (x64)"  
      #UninstallName "Microsoft Visual Basic for Applications 7.1 (x64) English"  
 If ($args -ne $null) {  
      $args = $args.ToLower()  
 }  
 If ($args -eq "architecture") {  
      #Architecture  
      UninstallGUID "Revit 2014" "{7346B4A0-1400-0510-0000-705C0D862004}"  
      UninstallName "Autodesk Workflows 2014"  
      UninstallGUID "Revit 2014 Language Pack - English" "{7346B4A0-1400-0511-0409-705C0D862004}"  
      UninstallGUID "Autodesk Material Library 2014" "{644F9B19-A462-499C-BF4D-300ABC2A28B1}"  
      UninstallGUID "Autodesk Material Library Base Resolution Image Library 2014" "{51BF3210-B825-4092-8E0D-66D689916E02}"  
      UninstallGUID "Autodesk Material Library Low Resolution Image Library 2014" "{5C29CC1F-218F-4C30-948A-11066CAC59FB}"  
      UninstallGUID "Autodesk Content Service" "{62F029AB-85F2-0000-866A-9FC0DD99DDBC}"  
      UninstallGUID "Autodesk Content Service Language Pack" "{62F029AB-85F2-0001-866A-9FC0DD99DDBC}"  
      UninstallGUID "AutoCAD 2014 - English" "{5783F2D7-D001-0000-0102-0060B0CE6BBA}"  
      UninstallGUID "AutoCAD 2014 Language Pack - English" "{5783F2D7-D001-0409-1102-0060B0CE6BBA}"  
      UninstallGUID "AutoCAD 2014 - English" "{5783F2D7-D001-0409-2102-0060B0CE6BBA}"  
      UninstallGUID "Autodesk Navisworks 2014 64 bit Exporter Plug-ins" "{914E5049-303D-5993-9734-CF12636383B4}"  
      UninstallGUID "Autodesk Navisworks 2014 64 bit Exporter Plug-ins English Language Pack" "{914E5049-303D-0409-9734-CF12636383B4}"  
      UninstallGUID "Autodesk Material Library Medium Resolution Image Library 2014" "{A0633D4E-5AF2-4E3E-A70A-FE9C2BD8A958}"  
      UninstallGUID "Autodesk Revit Interoperability for 3ds Max 2014" "{0BB716E0-1400-0610-0000-097DC2F354DF}"  
      UninstallGUID "Autodesk 3ds Max Design 2014" "{52B37EC7-D836-0409-0164-3C24BCED2010}"  
      UninstallName "Autodesk 3ds Max Design 2014 SP2"  
      UninstallGUID "Autodesk 3ds Max Design 2014 64-bit Populate Data" "{2BCAFE22-BE25-4437-815C-54596D630397}"  
      UninstallGUID "Autodesk DirectConnect 2014 64-bit" "{8FC7C2B2-0F64-4B35-AA3D-2B051D009243}"  
      UninstallGUID "Autodesk Inventor Server Engine for 3ds Max Design 2014 64-bit" "{CBC74B06-FE35-482C-89D6-CE95A0289C06}"  
      UninstallGUID "Autodesk Composite 2014" "{5AAB972C-FF31-4B01-8445-50C42860EC02}"  
      UninstallGUID "Autodesk Revit Interoperability for Showcase 2014" "{0BB716E0-1400-0410-0000-097DC2F354DF}"  
      UninstallGUID "AutoCAD Architecture 2014 - English" "{5783F2D7-D004-0000-0102-0060B0CE6BBA}"  
      UninstallGUID "Autodesk 360" "{52B28CAD-F49D-47BA-9FFE-29C2E85F0D0B}"  
      UninstallGUID "Autodesk Showcase 2014 64-bit" "{42FCE681-2220-4EAA-8E39-20B527585547}"  
      UninstallGUID "Autodesk SketchBook Designer 2014" "{4057E6CF-C9AC-45D7-87D4-A8FAE305AAC1}"  
      UninstallGUID "Autodesk SketchBook Designer for AutoCAD 2014" "{8BFDC12D-7F32-4F77-95DE-D1A42BAC91DD}"  
      UninstallName "Autodesk Backburner 2014"  
      UninstallGUID "Autodesk Essential Skills Movies for 3ds Max Design 2014 64-bit" "{280881E4-0E3C-40E6-9B76-E05A865551BB}"  
      UninstallGUID "AutoCAD Architecture 2014 Language Pack - English" "{5783F2D7-D004-0409-1102-0060B0CE6BBA}"  
      UninstallGUID "AutoCAD Architecture 2014 - English" "{5783F2D7-D004-0409-2102-0060B0CE6BBA}"  
      UninstallGUID "SketchUp Import for AutoCAD 2014" "{644E9589-F73A-49A4-AC61-A953B9DE5669}"  
 } elseif ($args -eq "engineering") {  
      #Engineering  
      UninstallGUID "Revit 2014" "{7346B4A0-1400-0510-0000-705C0D862004}"  
      UninstallName "Autodesk Workflows 2014"  
      UninstallGUID "Revit 2014 Language Pack - English" "{7346B4A0-1400-0511-0409-705C0D862004}"  
      UninstallGUID "Autodesk Material Library 2014" "{644F9B19-A462-499C-BF4D-300ABC2A28B1}"  
      UninstallGUID "Autodesk Material Library Base Resolution Image Library 2014" "{51BF3210-B825-4092-8E0D-66D689916E02}"  
      UninstallGUID "Autodesk Material Library Low Resolution Image Library 2014" "{5C29CC1F-218F-4C30-948A-11066CAC59FB}"  
      UninstallGUID "Autodesk Content Service" "{62F029AB-85F2-0000-866A-9FC0DD99DDBC}"  
      UninstallGUID "Autodesk Content Service Language Pack" "{62F029AB-85F2-0001-866A-9FC0DD99DDBC}"  
      UninstallGUID "AutoCAD 2014 - English" "{5783F2D7-D001-0000-0102-0060B0CE6BBA}"  
      UninstallGUID "AutoCAD 2014 Language Pack - English" "{5783F2D7-D001-0409-1102-0060B0CE6BBA}"  
      UninstallGUID "AutoCAD 2014 - English" "{5783F2D7-D001-0409-2102-0060B0CE6BBA}"  
      UninstallGUID "Autodesk 360" "{52B28CAD-F49D-47BA-9FFE-29C2E85F0D0B}"  
      UninstallGUID "SketchUp Import for AutoCAD 2014" "{644E9589-F73A-49A4-AC61-A953B9DE5669}"  
      UninstallGUID "Autodesk Navisworks 2014 64 bit Exporter Plug-ins" "{914E5049-303D-5993-9734-CF12636383B4}"  
      UninstallGUID "Autodesk Navisworks 2014 64 bit Exporter Plug-ins English Language Pack" "{914E5049-303D-0409-9734-CF12636383B4}"  
      UninstallGUID "Autodesk Material Library Medium Resolution Image Library 2014" "{A0633D4E-5AF2-4E3E-A70A-FE9C2BD8A958}"  
      UninstallGUID "Autodesk Revit Interoperability for 3ds Max 2014" "{0BB716E0-1400-0610-0000-097DC2F354DF}"  
      UninstallGUID "Autodesk 3ds Max Design 2014" "{52B37EC7-D836-0409-0164-3C24BCED2010}"  
      UninstallName "Autodesk 3ds Max Design 2014 SP2"  
      UninstallGUID "Autodesk 3ds Max Design 2014 64-bit Populate Data" "{2BCAFE22-BE25-4437-815C-54596D630397}"  
      UninstallGUID "Autodesk DirectConnect 2014 64-bit" "{8FC7C2B2-0F64-4B35-AA3D-2B051D009243}"  
      UninstallGUID "Autodesk Inventor Server Engine for 3ds Max Design 2014 64-bit" "{CBC74B06-FE35-482C-89D6-CE95A0289C06}"  
      UninstallGUID "Autodesk Composite 2014" "{5AAB972C-FF31-4B01-8445-50C42860EC02}"  
      UninstallName "Autodesk® Backburner 2014"  
      UninstallGUID "Autodesk Essential Skills Movies for 3ds Max Design 2014 64-bit" "{280881E4-0E3C-40E6-9B76-E05A865551BB}"  
 } elseif ($args -eq "civil3d") {  
      #Civil3D  
      UninstallGUID "Autodesk Material Library 2014" "{644F9B19-A462-499C-BF4D-300ABC2A28B1}"  
      UninstallGUID "Autodesk Material Library Base Resolution Image Library 2014" "{51BF3210-B825-4092-8E0D-66D689916E02}"  
      UninstallGUID "Autodesk Content Service" "{62F029AB-85F2-0000-866A-9FC0DD99DDBC}"  
      UninstallGUID "Autodesk Content Service Language Pack" "{62F029AB-85F2-0001-866A-9FC0DD99DDBC}"  
      UninstallGUID "Autodesk AutoCAD Civil 3D 2014" "{5783F2D7-D000-0409-0102-0060B0CE6BBA}"  
      UninstallGUID "Autodesk AutoCAD Civil 3D 2014 Language Pack - English" "{5783F2D7-D000-0409-1102-0060B0CE6BBA}"  
      UninstallGUID "Autodesk AutoCAD Civil 3D 2014 - English" "{5783F2D7-D000-0409-2102-0060B0CE6BBA}"  
      UninstallGUID "Autodesk 360" "{52B28CAD-F49D-47BA-9FFE-29C2E85F0D0B}"  
      UninstallGUID "SketchUp Import for AutoCAD 2014" "{644E9589-F73A-49A4-AC61-A953B9DE5669}"  
      UninstallName "Autodesk AutoCAD Civil 3D 2014 64 Bit Object Enabler on Autodesk 360 - Language Neutral"  
      UninstallGUID "Autodesk® Storm and Sanitary Analysis 2014" "{6BBA09C8-6B20-4115-B917-C09D8337AE09}"  
      UninstallGUID "Autodesk® Storm and Sanitary Analysis 2014 x64 Plug-in" "{F49CAD53-8F0F-441A-B974-CA5C3D7D03C1}"  
      UninstallName "Autodesk AutoCAD Civil 3D 2014 32 bit Object Enabler"  
      UninstallGUID "Autodesk ReCap" "{31ABA3F2-0000-1033-0102-111D43815377}"  
      UninstallGUID "Autodesk ReCap Language Pack-English" "{31ABA3F2-0010-1033-0102-111D43815377}"  
      UninstallGUID "Autodesk App Manager" "{C070121A-C8C5-4D52-9A7D-D240631BD433}"  
      UninstallGUID "Autodesk Featured Apps" "{F732FEDA-7713-4428-934B-EF83B8DD65D0}"  
 } else {  
      #BDS Ultimate  
   
      UninstallGUID "Revit 2014" "{7346B4A0-1400-0510-0000-705C0D862004}"  
      UninstallName "Autodesk Workflows 2014"  
      UninstallGUID "Autodesk Material Library 2014" "{644F9B19-A462-499C-BF4D-300ABC2A28B1}"  
      UninstallGUID "Autodesk Material Library Base Resolution Image Library 2014" "{51BF3210-B825-4092-8E0D-66D689916E02}"  
      UninstallGUID "Autodesk Material Library Low Resolution Image Library 2014" "{5C29CC1F-218F-4C30-948A-11066CAC59FB}"  
      UninstallGUID "DWG TrueView 2014" "{5783F2D7-D028-0409-0100-0060B0CE6BBA}"  
      UninstallGUID "Autodesk Content Service" "{62F029AB-85F2-0000-866A-9FC0DD99DDBC}"  
      UninstallGUID "AutoCAD 2014 - English" "{5783F2D7-D001-0000-0102-0060B0CE6BBA}"  
      UninstallGUID "AutoCAD Structural Detailing 2014 - English" "{5783F2D7-D030-0000-0102-0060B0CE6BBA}"  
      UninstallGUID "AutoCAD Architecture 2014 - English" "{5783F2D7-D004-0000-0102-0060B0CE6BBA}"  
      UninstallGUID "AutoCAD MEP 2014 - English" "{5783F2D7-D006-0000-0102-0060B0CE6BBA}"  
      UninstallGUID "Autodesk 360" "{52B28CAD-F49D-47BA-9FFE-29C2E85F0D0B}"  
      UninstallGUID "Autodesk Design Review 2013" "{153DB567-6FF3-49AD-AC4F-86F8A3CCFDFB}"  
      UninstallGUID "Autodesk Revit Interoperability for Inventor 2014" "{0BB716E0-1400-0210-0000-097DC2F354DF}"  
      UninstallGUID "Autodesk Inventor 2014" "{7F4DD591-1864-0001-0000-7107D70F3DB4}"  
      UninstallName "Eco Materials Adviser for Autodesk Inventor 2014 (64-bit)"  
      UninstallName "Microsoft SQL Server 2008 Native Client"  
      UninstallGUID "Revit 2014 Language Pack - English" "{7346B4A0-1400-0511-0409-705C0D862004}"  
      UninstallGUID "Autodesk Content Service Language Pack" "{62F029AB-85F2-0001-866A-9FC0DD99DDBC}"  
      UninstallGUID "AutoCAD 2014 Language Pack - English" "{5783F2D7-D001-0409-1102-0060B0CE6BBA}"  
      UninstallGUID "AutoCAD 2014 - English" "{5783F2D7-D001-0409-2102-0060B0CE6BBA}"  
      UninstallGUID "Autodesk Navisworks Manage 2014" "{22332F6C-46C6-0000-9863-06EE744B0218}"  
      UninstallGUID "Autodesk Navisworks Manage 2014 English Language Pack" "{22332F6C-46C6-0409-9863-06EE744B0218}"  
      UninstallGUID "Autodesk Navisworks Manage 2014 - 2014 DWG File Reader" "{82562ABD-3D6B-4845-9D11-60A649D727F1}"  
      UninstallGUID "Autodesk Navisworks Manage 2014 - 2013 DWG File Reader" "{C877FD20-CB02-42E5-BA97-283260216417}"  
      UninstallGUID "Autodesk Navisworks Manage 2014 - 2012 DWG File Reader" "{CE4E85D0-26F7-40D8-A639-F4F16ED205BC}"  
      UninstallGUID "Autodesk Navisworks Manage 2014 - 2011 DWG File Reader" "{B6DD48B0-1941-4E04-993B-1986CF000735}"  
      UninstallGUID "Autodesk Navisworks Manage 2014 - 2010 DWG File Reader" "{087CA76C-9188-4F47-B08B-22374918AF19}"  
      UninstallGUID "Autodesk Navisworks Manage 2014 - 2009 DWG File Reader" "{80BBD08D-5477-4437-881D-F0D16C13F1B8}"  
      UninstallGUID "Autodesk Navisworks Manage 2014 - 2008 DWG File Reader" "{452519E8-B784-4519-8BEB-CC62D31E5A0D}"  
      UninstallGUID "Autodesk Navisworks 2014 64 bit Exporter Plug-ins" "{914E5049-303D-5993-9734-CF12636383B4}"  
      UninstallGUID "Autodesk Navisworks 2014 64 bit Exporter Plug-ins English Language Pack" "{914E5049-303D-0409-9734-CF12636383B4}"  
      UninstallGUID "Autodesk Robot Structural Analysis Professional 2014" "{A3BD9E70-84AD-4E93-A92F-E6A245CD786C}"  
      UninstallGUID "Autodesk Robot Structural Analysis Professional 2014 - English regional settings" "{F9F0C54F-A993-488C-8CC9-4E74001F83A6}"  
      UninstallName "Autodesk Robot Structural Analysis Professional 2014 Autodesk Robot Structural Analysis Professional 2014 Service Pack 1"  
      UninstallGUID "Autodesk Material Library Medium Resolution Image Library 2014" "{A0633D4E-5AF2-4E3E-A70A-FE9C2BD8A958}"  
      UninstallGUID "Autodesk Revit Interoperability for 3ds Max 2014" "{0BB716E0-1400-0610-0000-097DC2F354DF}"  
      UninstallGUID "Autodesk 3ds Max Design 2014" "{52B37EC7-D836-0409-0164-3C24BCED2010}"  
      UninstallGUID "Autodesk 3ds Max Design 2014 64-bit Populate Data" "{2BCAFE22-BE25-4437-815C-54596D630397}"  
      UninstallGUID "Autodesk DirectConnect 2014 64-bit" "{8FC7C2B2-0F64-4B35-AA3D-2B051D009243}"  
      UninstallGUID "Autodesk Inventor Server Engine for 3ds Max Design 2014 64-bit" "{CBC74B06-FE35-482C-89D6-CE95A0289C06}"  
      UninstallGUID "Autodesk Composite 2014" "{5AAB972C-FF31-4B01-8445-50C42860EC02}"  
      UninstallGUID "Autodesk Revit Interoperability for Showcase 2014" "{0BB716E0-1400-0410-0000-097DC2F354DF}"  
      UninstallGUID "Autodesk Showcase 2014 64-bit" "{42FCE681-2220-4EAA-8E39-20B527585547}"  
      UninstallGUID "AutoCAD Structural Detailing 2014 Language Pack - English" "{5783F2D7-D030-0409-1102-0060B0CE6BBA}"  
      UninstallGUID "AutoCAD Structural Detailing 2014 - English" "{5783F2D7-D030-0409-2102-0060B0CE6BBA}"  
      UninstallGUID "Autodesk SketchBook Designer 2014" "{4057E6CF-C9AC-45D7-87D4-A8FAE305AAC1}"  
      UninstallGUID "Autodesk Inventor 2014 English Language Pack" "{7F4DD591-1864-0001-1033-7107D70F3DB4}"  
      UninstallGUID "Autodesk InfraWorks 2014" "{58E36D07-3001-0000-0102-C854F44898ED}"  
      UninstallName "Autodesk Inventor 2014 Content Libraries"  
      UninstallGUID "Autodesk SketchBook Designer for AutoCAD 2014" "{8BFDC12D-7F32-4F77-95DE-D1A42BAC91DD}"  
      UninstallGUID "Autodesk ReCap" "{31ABA3F2-0000-1033-0102-111D43815377}"  
      UninstallGUID "Autodesk ReCap Language Pack-English" "{31ABA3F2-0010-1033-0102-111D43815377}"  
      UninstallName "Autodesk® Backburner 2014"  
      UninstallGUID "Autodesk Essential Skills Movies for 3ds Max Design 2014 64-bit" "{280881E4-0E3C-40E6-9B76-E05A865551BB}"  
      UninstallGUID "AutoCAD Architecture 2014 Language Pack - English" "{5783F2D7-D004-0409-1102-0060B0CE6BBA}"  
      UninstallGUID "AutoCAD Architecture 2014 - English" "{5783F2D7-D004-0409-2102-0060B0CE6BBA}"  
      UninstallGUID "AutoCAD MEP 2014 Language Pack - English" "{5783F2D7-D006-0409-1102-0060B0CE6BBA}"  
      UninstallGUID "AutoCAD MEP 2014 - English" "{5783F2D7-D006-0409-2102-0060B0CE6BBA}"  
      UninstallGUID "SketchUp Import for AutoCAD 2014" "{644E9589-F73A-49A4-AC61-A953B9DE5669}"  
      UninstallGUID "AutoCAD Raster Design 2014" "{5783F2D7-D031-0409-0102-0060B0CE6BBA}"  
      UninstallName "Autodesk AutoCAD Structural Detailing 2014 Object Enabler"  
 }  

01 December 2013

Get the Software GUID

This script will get the proper software name and associated GUID. I use this script when writing uninstaller powershell scripts. You can use the GUID in an msiexec so that you do not need the source files for the uninstall.

You can download the script from here.

 #*******************************************************************************  
 #   Author: Mick Pletcher  
 #   Date: 30 November 2013  
 #  
 #   Program: Get Software Names and GUID  
 #*******************************************************************************  

 Clear-Host  

 Function RenameWindow ($Title) {  

      #Declare Local Memory  
      Set-Variable -Name a -Scope Local -Force  

      $a = (Get-Host).UI.RawUI  
      $a.WindowTitle = $Title  

      #Cleanup Local Memory  
      Remove-Variable -Name a -Scope Local -Force 
 
 }  

 Function GetProductName($Description) {
  
      #Declare Local Memory  
      Set-Variable -Name AppLocal -Scope Local -Force  
      Set-Variable -Name AppName -Scope Local -Force  
      Set-Variable -Name Desc -Scope Local -Force  
      Set-Variable -Name IDLocal -Scope Local -Force  
      Set-Variable -Name IDNumber -Scope Local -Force  
      Set-Variable -Name Uninstaller -Scope Local -Force
  
      #Change '%application%' to whatever app you are calling  
      $Description = [char]34+"description like"+[char]32+[char]39+[char]37+$Description+[char]37+[char]39+[char]34  
      $Desc = wmic product where $Description get Description  
      $Uninstaller = wmic product where $Description get IdentifyingNumber  
      $Desc | ForEach-Object {  
           $_ = $_.Trim()  
             if(($_ -ne "Description")-and($_ -ne "")){  
               $AppName += $_  
             }  
      }  
      $Uninstaller | ForEach-Object {  
           $_ = $_.Trim()  
             if(($_ -ne "IdentifyingNumber")-and($_ -ne "")){  
               $IDNumber += $_  
             }  
      }  
      $AppLocal = New-Object System.Object  
      $AppLocal | Add-Member -type NoteProperty -name Application -value $AppName  
      If ($AppName -ne $null) {  
           $AppLocal | Add-Member -type NoteProperty -name GUID -value $IDNumber  
      } else {  
           $AppLocal | Add-Member -type NoteProperty -name Status -value "Not Installed"  
      }  
      $AppLocal  

      #Cleanup Local Memory  
      Remove-Variable -Name AppLocal -Scope Local -Force  
      Remove-Variable -Name AppName -Scope Local -Force  
      Remove-Variable -Name Desc -Scope Local -Force  
      Remove-Variable -Name IDLocal -Scope Local -Force  
      Remove-Variable -Name IDNumber -Scope Local -Force  
      Remove-Variable -Name Uninstaller -Scope Local -Force 
 
 } 
 
 RenameWindow "Product Name and GUID"  
 GetProductName "Office Professional Plus"  
 GetProductName "Microsoft Lync 2013"  
 GetProductName "Adobe Reader"  
 GetProductName "Microsoft Visio Professional"  

30 November 2013

Adding a User to the Local Administrators Group with Verification

This script will add a user to the local administrators group. It will also verify if the user is added and write both a registry key for the add/remove programs and a key for the WMI entry so that it will appear in a WMI query. There were already scripts out there to do this function, but I wrote this one for our SCCM build so that there is a verification in the build process that one of the accounts we add to the local admin group is actually there. All you have to do is to add the name of the account to the variable $Member.

You can download the script from here.


 #*******************************************************************************  
 #   Author: Mick Pletcher  
 #    Date: 25 November 2013  
 #  
 #   Program: Add User to Local Administrator Group in Active Directory  
 #*******************************************************************************  

 #Define Global Memory  
 Set-Variable -Name Member -Scope Local -Force  
 Set-Variable -Name Results -Value $false -Scope Global -Force  

 Function AddRemovePrograms($KeyName, $DisplayName, $Version){  

      #Define Local Memory  
      New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT  
      Set-Variable -Name AddRemKey -Scope Local -Force  
      Set-Variable -Name guid -Scope Local -Force  
      Set-Variable -Name ProductsKey -Scope Local -Force  

      If (!(Test-Path c:\windows\GSPBox_Icon.bmp)){  
           Copy-Item -Path \\global.gsp\data\clients\na_clients\Build\Add-ins\GSPBox_Icon.bmp -Destination c:\Windows -Force  
      }  
      $AddRemKey = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"  
      $ProductsKey = "HKCR:\Installer\Products\"  
      New-Item -Path $AddRemKey -Name $KeyName –Force  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name DisplayName -Value $DisplayName -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name DisplayVersion -Value $Version -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name UninstallString -Value " " -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name Publisher -Value "Gresham, Smith and Partners" -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name DisplayIcon -Value "c:\windows\GSPBox_Icon.bmp" -PropertyType String  
      $guid = [guid]::NewGuid().ToString("N")  
      $guid.ToString()  
      $guid = $guid.ToUpper()  
      New-Item -Path $ProductsKey -Name $guid –Force  
      New-ItemProperty -Path $ProductsKey"\"$guid -Name ProductName -Value $DisplayName -PropertyType String -Force  

      #Cleanup Local Memory  
      remove-psdrive -name HKCR  
      Remove-Variable -Name AddRemKey -Scope Local -Force  
      Remove-Variable -Name guid -Scope Local -Force  
      Remove-Variable -Name ProductsKey -Scope Local -Force  

 }  

 Function CheckADForUser ($Member){  

      #Define Local Memory  
      Set-Variable -Name Computer -Scope Local -Force  
      Set-Variable -Name Group -Scope Local -Force  
      Set-Variable -Name LocalGroup -Scope Local -Force  
      Set-Variable -Name User -Scope Local -Force  
      Set-Variable -Name UserNames -Scope Local -Force  
      Set-Variable -Name Users -Scope Local -Force  

      $LocalGroup = "Administrators"  
      $UserNames = @()  
      $Computer = $env:computername  
           $Group= [ADSI]"WinNT://$Computer/$LocalGroup,group"  
           $Users = @($Group.psbase.Invoke("Members"))  
           $Users | ForEach-Object {  
                $UserNames += $_.GetType().InvokeMember("Name", 'GetProperty', $null, $_, $null)  
                Foreach ( $User in $UserNames) {  
                     If ($User -eq $Member) {  
                          $Global:Results = $true  
                          Write-Host $User  
                     }  
                }  
           }  

      #Cleanup Local Memory  
      $UserNames.Clear()  
      Remove-Variable -Name Computer -Scope Local -Force  
      Remove-Variable -Name Group -Scope Local -Force  
      Remove-Variable -Name LocalGroup -Scope Local -Force  
      Remove-Variable -Name User -Scope Local -Force  
      Remove-Variable -Name UserNames -Scope Local -Force  
      Remove-Variable -Name Users -Scope Local -Force  

 }  

 Function AddUserToAD ($Member) {  

      $group = [ADSI]"WinNT://./Administrators,group"  
      $group.Add("WinNT://$Member,user")  

 }  

 cls  
 $Member = ""  
 CheckADForUser $Member  
 If ($Results -eq $true) {  
      AddRemovePrograms $Member $Member "Installed"  
      cls  
      Write-Host $Member" is already in the local administrators group"  
 } else {  
      AddUserToAD $Member  
      CheckADForUser $Member  
      If ($Results -eq $true) {  
           AddRemovePrograms $Member $Member "Installed"  
           cls  
           Write-Host $Member" has been added to the local administrators group"  
      }  
 }  

 #Cleanup Global Memory  
 Remove-Variable -Name Member -Scope Local -Force  
 Remove-Variable -Name Results -Scope Global -Force  

Autodesk 2014 Building Design Suite Ultimate Uninstaller

The Autodesk suite is not the easiest to uninstall because of all the components that the built in uninstaller does not uninstall. I went in and extracted all of the GUIDs for each components and created the powershell script below to uninstall the entire suite. The firm I work for splits up the BDS Ultimate suite into two different disciplines, Architecture and Engineering. I have only tested this on both of these, which neither includes the entire BDS Ultimate.

You can download the script from here.

 #*******************************************************************************  
 #   Author: Mick Pletcher  
 #    Date: 30 November 2013  
 #  
 #   Program: Autodesk BDS Ultimate Uninstaller  
 #*******************************************************************************  

 Function UninstallApplication($Application,$GUID) {  

      #Declare Local Variables  
      Set-Variable -Name Code -Scope Local -Force  
      Set-Variable -Name Arguments -Scope Local -Force  

      Write-Host $Application"...." -NoNewline  
      $Arguments = "/x "+$GUID+" /qb- /norestart"  
      $Code = (Start-Process -FilePath msiexec.exe -ArgumentList $Arguments -Wait -Passthru).ExitCode  
      If ($Code -eq 0) {  
           Write-Host "Uninstalled" -ForegroundColor Yellow  
      } elseIf ($Code -eq 1605) {  
           Write-Host "Not Installed" -ForegroundColor Yellow  
      } else {  
           Write-Host "Failed with error code"$Code -ForegroundColor Red  
      }  

      #Cleanup Local Variables  
      Remove-Variable -Name Code -Scope Local -Force  
      Remove-Variable -Name Arguments -Scope Local -Force  

 }
  
 UninstallApplication "Microsoft Visual C++ 2008 SP1 Redistributable (x64)" "{5FCE6D76-F5DC-37AB-B2B8-22AB8CEDB1D4}"  
 UninstallApplication "Microsoft Visual C++ 2008 SP1 Redistributable (x64)" "{5FCE6D76-F5DC-37AB-B2B8-22AB8CEDB1D4}"  
 UninstallApplication "Microsoft Visual C++ 2008 SP1 Redistributable (x86)" "{9BE518E6-ECC6-35A9-88E4-87755C07200F}"  
 UninstallApplication "Microsoft Visual C++ 2008 SP1 Redistributable (x86)" "{9BE518E6-ECC6-35A9-88E4-87755C07200F}"  
 UninstallApplication "Microsoft Visual C++ 2010 SP1 Redistributable (x86)" "{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}"  
 UninstallApplication "Microsoft Visual C++ 2010 SP1 Redistributable (x64)" "{1D8E6291-B0D5-35EC-8441-6616F567A0F7}"  
 UninstallApplication "Microsoft Visual C++ 2008 x86 ATL Runtime" "{04B34E21-5BEE-3D2B-8D3D-E3E80D253F64}"  
 UninstallApplication "Microsoft Visual C++ 2008 x86 MFC Runtime" "{B42E259C-E4D4-37F1-A1B2-EB9C4FC5A04D}"  
 UninstallApplication "Microsoft Visual C++ 2008 x86 CRT Runtime" "{14866AAD-1F23-39AC-A62B-7091ED1ADE64}"  
 UninstallApplication "Microsoft Visual C++ 2008 x86 OpenMP Runtime" "{4B90093A-5D9C-3956-8ABB-95848BE6EFAD}"  
 UninstallApplication "Microsoft Visual C++ 2008 x64 ATL Runtime" "{C3A57BB3-9AA6-3F6F-9395-6C062BDD5FC4}"  
 UninstallApplication "Microsoft Visual C++ 2008 x64 MFC Runtime" "{6DA2B636-698A-3294-BF4A-B5E11B238CDD}"  
 UninstallApplication "Microsoft Visual C++ 2008 x64 CRT Runtime" "{F6F09DD8-F39B-3A16-ADB9-C9E6B56903F9}"  
 UninstallApplication "Microsoft Visual C++ 2008 x64 OpenMP Runtime" "{8CCEA24C-51AE-3B71-9092-7D0C44DDA2DF}"  
 UninstallApplication "FARO LS" "{8A470330-70B2-49AD-86AF-79885EF9898A}"  
 UninstallApplication "Revit 2014" "{7346B4A0-1400-0510-0000-705C0D862004}"  
 UninstallApplication "Autodesk Workflows 2014" "{11672AB2-3D48-4D38-9123-719E5FF93333}"  
 UninstallApplication "MSXML 6.0 Parser" "{FF59CB23-1800-4047-B40C-E20AE7051491}"  
 UninstallApplication "Revit 2014 Language Pack - English" "{7346B4A0-1400-0511-0409-705C0D862004}"  
 UninstallApplication "Autodesk Material Library 2014" "{644F9B19-A462-499C-BF4D-300ABC2A28B1}"  
 UninstallApplication "Autodesk Material Library Base Resolution Image Library 2014" "{51BF3210-B825-4092-8E0D-66D689916E02}"  
 UninstallApplication "Autodesk Material Library Low Resolution Image Library 2014" "{5C29CC1F-218F-4C30-948A-11066CAC59FB}"  
 UninstallApplication "Autodesk Content Service" "{62F029AB-85F2-0000-866A-9FC0DD99DDBC}"  
 UninstallApplication "Autodesk Content Service Language Pack" "{62F029AB-85F2-0001-866A-9FC0DD99DDBC}"  
 UninstallApplication "AutoCAD 2014 - English" "{5783F2D7-D001-0000-0102-0060B0CE6BBA}"  
 UninstallApplication "AutoCAD 2014 Language Pack - English" "{5783F2D7-D001-0409-1102-0060B0CE6BBA}"  
 UninstallApplication "AutoCAD 2014 - English" "{5783F2D7-D001-0409-2102-0060B0CE6BBA}"  
 UninstallApplication "Autodesk 360" "{52B28CAD-F49D-47BA-9FFE-29C2E85F0D0B}"  
 UninstallApplication "SketchUp Import for AutoCAD 2014" "{644E9589-F73A-49A4-AC61-A953B9DE5669}"  
 UninstallApplication "Autodesk Navisworks 2014 64 bit Exporter Plug-ins" "{914E5049-303D-5993-9734-CF12636383B4}"  
 UninstallApplication "Autodesk Navisworks 2014 64 bit Exporter Plug-ins English Language Pack" "{914E5049-303D-0409-9734-CF12636383B4}"  
 UninstallApplication "Autodesk Material Library Medium Resolution Image Library 2014" "{A0633D4E-5AF2-4E3E-A70A-FE9C2BD8A958}"  
 UninstallApplication "Autodesk Revit Interoperability for 3ds Max 2014" "{0BB716E0-1400-0410-0000-097DC2F354DF}"  
 UninstallApplication "Autodesk 3ds Max Design 2014" "{52B37EC7-D836-0409-0164-3C24BCED2010}"  
 UninstallApplication "Autodesk 3ds Max Design 2014 64-bit Populate Data" "{2BCAFE22-BE25-4437-815C-54596D630397}"  
 UninstallApplication "Autodesk DirectConnect 2014 64-bit" "{8FC7C2B2-0F64-4B35-AA3D-2B051D009243}"  
 UninstallApplication "Autodesk Inventor Server Engine for 3ds Max Design 2014 64-bit" "{CBC74B06-FE35-482C-89D6-CE95A0289C06}"  
 UninstallApplication "Autodesk Composite 2014" "{5AAB972C-FF31-4B01-8445-50C42860EC02}"  
 UninstallApplication "Autodesk® Backburner 2014" "{3D347E6D-5A03-4342-B5BA-6A771885F379}"  
 UninstallApplication "Autodesk Essential Skills Movies for 3ds Max Design 2014 64-bit" "{280881E4-0E3C-40E6-9B76-E05A865551BB}"  
 UninstallApplication "Autodesk Sketchbook Designer 2014" "{4057E6CF-C9AC-45D7-87D4-A8FAE305AAC1}"  
 UninstallApplication "Autodesk SketchBook Designer for AutoCAD 2014" "{8BFDC12D-7F32-4F77-95DE-D1A42BAC91DD}"  
 UninstallApplication "Autodesk Showcase 2014 64-bit" "{42FCE681-2220-4EAA-8E39-20B527585547}"  
 UninstallApplication "Autodesk Revit Interoperability for 3ds Max 2014" "{0BB716E0-1400-0610-0000-097DC2F354DF}"  
 UninstallApplication "AutoCAD Architecture 2014 - English" "{5783F2D7-D004-0000-0102-0060B0CE6BBA}"  

27 November 2013

Disable Windows Media Center

If you are needing to disable Windows Media Center in Windows 7 by command line, here is a script that will do just that. This script will not only disable it, but it will also add an add/remove programs and HKCR entry so that both WMI and SCCM can detect the service was disabled.

You can download the script from here.

 #*******************************************************************************  
 #   Author: Mick Pletcher  
 #    Date: 16 August 2013  
 #  
 #   Program: Windows Media Center  
 #*******************************************************************************  
 cls  

 #Declare Global Memory  
 Set-Variable -Name a -Scope Global -Force  
 Set-Variable -Name Output -Scope Global -Force  

 Function AddRemovePrograms($KeyName, $DisplayName, $Version){  

      #Define Local Memory  
      New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT  
      Set-Variable -Name AddRemKey -Scope Local -Force  
      Set-Variable -Name guid -Scope Local -Force  
      Set-Variable -Name ProductsKey -Scope Local -Force  

      If (!(Test-Path c:\windows\GSPBox_Icon.bmp)){  
           Copy-Item -Path \\global.gsp\data\clients\na_clients\Build\Add-ins\GSPBox_Icon.bmp -Destination c:\Windows -Force  
      }  
      $AddRemKey = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"  
      $ProductsKey = "HKCR:\Installer\Products\"  
      New-Item -Path $AddRemKey -Name $KeyName –Force  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name DisplayName -Value $DisplayName -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name DisplayVersion -Value $Version -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name UninstallString -Value " " -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name Publisher -Value "Gresham, Smith and Partners" -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name DisplayIcon -Value "c:\windows\GSPBox_Icon.bmp" -PropertyType String  
      $guid = [guid]::NewGuid().ToString("N")  
      $guid.ToString()  
      $guid = $guid.ToUpper()  
      New-Item -Path $ProductsKey -Name $guid –Force  
      New-ItemProperty -Path $ProductsKey"\"$guid -Name ProductName -Value $DisplayName -PropertyType String -Force  

      #Cleanup Local Memory  
      remove-psdrive -name HKCR  
      Remove-Variable -Name AddRemKey -Scope Local -Force  
      Remove-Variable -Name guid -Scope Local -Force  
      Remove-Variable -Name ProductsKey -Scope Local -Force  

 }  

 Invoke-Command {dism.exe /online /disable-feature /featurename:MediaCenter /norestart}  
 $a = Invoke-Command {dism.exe /online /get-featureinfo /featurename:MediaCenter}  
 $Output = $a | Select-String "State : Disabled"  
 Write-Host $Output  
 If ($Output -like "State : Disabled"){  
      AddRemovePrograms "MediaCenter" "MediaCenter" "Disabled"  
 }  

 #Cleanup Global Memory  
 Remove-Variable -Name a -Scope Global -Force  
 Remove-Variable -Name Output -Scope Global -Force  

26 November 2013

Add/Remove Program entries

Sometimes it is necessary to add an add/remove programs entry. There are instances where an application is independent and requires not installation and you want to make sure it is copied to the system, or you use add/remove programs to verify a service is enabled/disabled. For whatever reason you need to add an entry you want to also add the registry keys so that a WMI query will also detect the entry. The script below will do just that. It creates a GUID, which is required to write the entry in the HKCR key. This is where the WMI will read from, not from the Uninstall directory.

You can download the script from here.

 Function AddRemovePrograms($KeyName, $DisplayName, $Version){  

      #Define Local Memory  
      New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT  
      Set-Variable -Name AddRemKey -Scope Local -Force  
      Set-Variable -Name guid -Scope Local -Force  
      Set-Variable -Name ProductsKey -Scope Local -Force 
 
      If (!(Test-Path c:\windows\GSPBox_Icon.bmp)){  
           Copy-Item -Path \\global.gsp\data\clients\na_clients\Build\Add-ins\GSPBox_Icon.bmp -Destination c:\Windows -Force  
      }  
      $AddRemKey = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall"  
      $ProductsKey = "HKCR:\Installer\Products\"  
      New-Item -Path $AddRemKey -Name $KeyName –Force  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name DisplayName -Value $DisplayName -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name DisplayVersion -Value $Version -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name UninstallString -Value " " -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name Publisher -Value "Gresham, Smith and Partners" -PropertyType String  
      New-ItemProperty -Path $AddRemKey"\"$KeyName -Name DisplayIcon -Value "c:\windows\GSPBox_Icon.bmp" -PropertyType String  
      $guid = [guid]::NewGuid().ToString("N")  
      $guid.ToString()  
      $guid = $guid.ToUpper()  
      New-Item -Path $ProductsKey -Name $guid –Force  
      New-ItemProperty -Path $ProductsKey"\"$guid -Name ProductName -Value $DisplayName -PropertyType String -Force  

      #Cleanup Local Memory  
      remove-psdrive -name HKCR  
      Remove-Variable -Name AddRemKey -Scope Local -Force  
      Remove-Variable -Name guid -Scope Local -Force  
      Remove-Variable -Name ProductsKey -Scope Local -Force  
 }  

25 November 2013

Verify applications were installed during build process

As many of you have probably experienced, SCCM and MDT do not always install all of the applications that are in the task sequence list, even if it returned an error code 0. This can be rather annoying, especially when it happens in the build process of the golden image. In order to get around this issue, I wrote the PowerShell script below that will use WMI to verify all of the applications were installed during the task sequence process. All that you should have to do to make custom changes for your environment is to open up the script and add your apps. You will see four examples I put in this script, AppInstalled "Adobe Reader"  being one example. The Adobe Reader in parenthesis can be changed to any app, such as Microsoft Office. You do not need to enter the entire application name, as I have written the function to be able to search for just part of the name. I used the Adobe Reader example because your company may have more than one version of reader and this can search any version being just a portion of the name.

In order to properly implement this, I would suggest putting this as a task sequence and then immediately pausing the build so that you can review the output of this and manually install any applications that may have failed before the golden image is generated. To pause the build for MDT, you can initiate the LTISuspend.wsf as a task sequence. SCCM does not have this wsf file, so you can create a simple, one line VBS file that calls the MSGBOX which will wait for you to click OK on. The VBS can also be used in MDT instead of the LTISuspend.wsf.

You can download this script here.

 #*******************************************************************************  
 #   Author: Mick Pletcher  
 #    Date: 25 November 2013  
 #  
 #   Program: Check Build  
 #*******************************************************************************  
 Clear-Host  

 #Declare Global Memory  
 $app = ,@()  
 Set-Variable -Name Count -Scope Global -Value 1 -Force  
 Set-Variable -Name OS -Scope Global -Force  
 Set-Variable -Name RelativePath -Scope Global -Force  

 Function RenameWindow ($Title) {  

      #Declare Local Memory  
      Set-Variable -Name a -Scope Local -Force
  
      $a = (Get-Host).UI.RawUI  
      $a.WindowTitle = $Title  

      #Cleanup Local Memory  
      Remove-Variable -Name a -Scope Local -Force
  
 }  

 Function AppInstalled($Description) {
  
      #Declare Local Memory  
      Set-Variable -Name AppName -Scope Local -Force  
      Set-Variable -Name AppLocal -Scope Local -Force  
      Set-Variable -Name Desc -Scope Local -Force  
      Set-Variable -Name Output -Scope Local -Force
  
      $object = New-Object -TypeName PSObject  
      #Change '%application%' to whatever app you are calling  
      $Desc = [char]34+"description like"+[char]32+[char]39+[char]37+$Description+[char]37+[char]39+[char]34  
      $Output = wmic product where $Desc get Description  
      $Output | ForEach-Object {  
           $_ = $_.Trim()  
             if(($_ -ne "Description")-and($_ -ne "")){  
                $AppName = $_  
             }  
      }  
      $AppLocal = New-Object System.Object  
      $AppLocal | Add-Member -type NoteProperty -name Application -value $Description  
      If ($AppName -ne $null) {  
           #$Global:app+=,@($Description,"Installed")  
           $AppLocal | Add-Member -type NoteProperty -name Status -value "Installed"  
      } else {  
           #$Global:app+=,@($Description,"Not Installed")  
           $AppLocal | Add-Member -type NoteProperty -name Status -value "Not Installed"  
      }  
      $Global:app += $AppLocal  
      $AppLocal | Select Application  
      $Global:Count++  

      #Cleanup Local Memory  
      Remove-Variable -Name AppName -Scope Local -Force  
      Remove-Variable -Name AppLocal -Scope Local -Force  
      Remove-Variable -Name Desc -Scope Local -Force  
      Remove-Variable -Name Output -Scope Local -Force
  
 }  

 cls  
 Write-Host "Processing Applications"  
 Write-Host  
 RenameWindow "Check Build Installs"  
 AppInstalled "Dell Client System Update"  
 AppInstalled "Adobe Reader"  
 AppInstalled "Microsoft Lync"  
 cls  
 Write-Host "Installation Report"  
 Write-Host  
 $app | Format-Table
  
 #Cleanup Global Memory  
 $app.Clear()  
 Remove-Variable -Name Count -Scope Global -Force  
 Remove-Variable -Name OS -Scope Global -Force  
 Remove-Variable -Name RelativePath -Scope Global -Force