#########################################################################################################
#Script Name: Deploy VMware PowerCLI 6.3 Silently #
#Script Author: SCCMOG - Richie Schuster 16/12/2016 WWW.SCCMOG.COM #
#########################################################################################################
#Script Usage: "Deploy_PowerCLI_Silent.ps1 -Mode Install" to install and "-Mode Uninstall" to uninstall.#
#########################################################################################################
#Install Mode Parameter
PARAM (
[string]$MODE
)
#If entery is input run script
If ($mode -ne $null){
#If Mode input is Install run install.
If ($MODE -eq "Install"){
#Install VMware PowerCLI 6.3 Silently and Remote Console silently
Start-Process "$PSScriptRoot\VMware-PowerCLI-6.3.0-3737840.exe" -ArgumentList '/b"C:\Windows\Temp" /VADDLOCAL=ALL /S /V"/qn ALLUSERS=1 REBOOT=ReallySuppress' -wait -NoNewWindow
}
#If Mode input uninstall run uninstall
ElseIf ($MODE -eq "Uninstall"){
##Get all Applications in SMS namespace
$InstalledProducts = Get-WmiObject -Namespace 'root\cimv2\sms' -Class SMS_InstalledSoftware
#Grab PowerCLI related
$RemConsole = $InstalledProducts | where { $_.ARPDisplayName -eq "VMware Remote Console Plug-in 5.1" }
$PowerCLI = $InstalledProducts | where { $_.ARPDisplayName -eq "VMware vSphere PowerCLI" }
#Get store local msi for uninstall arguements
$REMCLP = $RemConsole.LocalPackage
$PCLILP = $PowerCLI.LocalPackage
#Get process that must be killed to uninstall silently
$Running = Get-Process -Name vmware-usbarbitrator64 -ErrorAction SilentlyContinue
#Check if process is running
If ($Running -ne $null){
#Kill process if it is
Stop-Process -Name vmware-usbarbitrator64 -Force
#Start Removal of VMware Remote Console Plug-in 5.1
Start-Process "msiexec.exe" -ArgumentList "/x $REMCLP /qn /L*v $env:windir\temp\Uninstall_VMwareREMConsolePlg5.1.log /norestart" -wait -NoNewWindow
#Start Removal of VMware vSphere PowerCLI
Start-Process "msiexec.exe" -ArgumentList "/x $PCLILP /qn /L*v $env:windir\temp\Uninstall_VMwarevSpherePowerCLI.log /norestart" -wait -NoNewWindow
}
Else{
#Start Removal of VMware Remote Console Plug-in 5.1
Start-Process "msiexec.exe" -ArgumentList "/x $REMCLP /qn /L*v $env:windir\temp\Uninstall_VMwareREMConsolePlg5.1.log /norestart" -wait -NoNewWindow
#Start Removal of VMware vSphere PowerCLI
Start-Process "msiexec.exe" -ArgumentList "/x $PCLILP /qn /L*v $env:windir\temp\Uninstall_VMwarevSpherePowerCLI.log /norestart" -wait -NoNewWindow
}
}
#If mode input does not match inform user.
Else{
Write-host 'Incorrect Params please format this way: "Deploy_PowerCLI_Silent.ps1 -Mode Install" to install and "-Mode Uninstall" to uninstall.'
}
}
#If params are not specified then inform.
Else{
Write-host 'Script Params must be used : "Deploy_PowerCLI_Silent.ps1 -Mode Install" to install and "-Mode Uninstall" to uninstall.'
}
#########################################################################################################