Recently Added

Notes & Bookmarks

  1. Quasars; power and metrics beyond all comprehension. Staggeringly beautiful information... and very well written.
  2. "I'm sorry. I can't come in today. Religious holiday. The feast of...Maximum Occupancy."
  3. Verifying myself: I am sgnls on UJa01G4v3YRJYB1LFjDRSf1Nh0bh1sOykCbq /
  4. Be sure to take care of your own infrastructure(s); purge dumps, tunnel and lock-down egress transit, encrypt and permission CORRECTLY!
  5. It really doesn't matter what else gets released; Sikth's 'The Future in Whose Eyes?' is THE album of 2017. #albumoftheyear

Remote Installation of Binary with Powershell & WMI v2

Updated : 16:20:37pm, 22nd Mar 2016

Below is an improved approach to something previously detailed.

As then, the intention of this script was to deploy an AEM agent to remote workstations using -searchbase scopes, with logging. Progress notification (i.e. bar) and a more efficient foreach are on the cards, but this can be easily tweaked to allow deployment of any other silent binary, such as a Bomgar agent;

The most up-to-date version will always be on Github.

## Install Bombar Agent v1.0

## globals
$log_file = "c:\log\bomgar_install.txt"
$log_file_off = "c:\log\bomgar_install-offline.txt"
$bomgar_src = "\\src\bomgar$"
$bomgar_dir = "c$\ProgramData\bomgar-scc-cb"
$bomgar_temp = "bgtemp"
$bomgar_file_x86 = "x86\bomgar-scc-w0408c90.exe"
$bomgar_file_x64 = "x64\bomgar-scc-w0408c90.exe"

## machine scope(s)
$comps_ind = "workstation01"
# $comps_offline = get-content "$log_file_off"
$comps_all_ws = get-adcomputer -searchbase "dc=domain,dc=com" -filter {(OperatingSystem -notlike "*Server*") -and (enabled -eq $True)} | select Name -expandproperty Name | sort-object -descending
$comps_all_srv = get-adcomputer -searchbase "dc=domain,dc=com" -filter {(OperatingSystem -like "*Server*") -and (enabled -eq $True)} | select Name -expandproperty Name | sort-object -descending

## install cycle
foreach($comp in $comps_all_ws){

	## check machine is online, else ignore
	if(test-connection $comp -count 1 -quiet){
		## check if application is already installed, else install
		if(!(test-path -path "\\$comp\$bomgar_dir")){
			write-host "Copying Bomgar installation file to $comp... `n"
			add-content "$log_file" "Copying Bomgar installation file to $comp... `n"
			## create target dir, copy file and install x86 or x64 depending on architecture
			write-host "Preparing to install Bomgar on $comp..."
			add-content "$log_file" "Preparing to install Bomgar on $comp...`n"	
			$get_arch = (get-wmiobject win32_processor -computer $comp | where-object {$_.deviceID -eq "CPU0"}).AddressWidth
			if($get_arch -eq "64"){
				new-item "\\$comp\c$\$bomgar_temp\x64" -type directory -force | out-null
				copy-item "$bomgar_src\$bomgar_file_x64" "\\$comp\c$\$bomgar_temp\x64\" | out-null
				$bomgar_install = "cmd.exe /c c:\$bomgar_temp\$bomgar_file_x64"
				([WMICLASS]"\\$comp\ROOT\CIMV2:win32_process").create($bomgar_install) | out-null 
				new-item "\\$comp\c$\$bomgar_temp\x86" -type directory -force | out-null
				copy-item "$bomgar_src\$bomgar_file_x86" "\\$comp\c$\$bomgar_temp\x86\" | out-null
				$bomgar_install = "cmd.exe /c c:\$bomgar_temp\$bomgar_file_x86"
				([WMICLASS]"\\$comp\ROOT\CIMV2:win32_process").create($bomgar_install) | out-null 
			## wait and test for installation path population
			sleep 10			
			if(!(test-path -path "\\$comp\$bomgar_dir")){
				write-host "Bomgar is now installed on $comp. `n"
				add-content "$log_file" "Bomgar is now installed on $comp. `n"
				write-host "Bomgar is not installed on $comp; installation has failed. `n"
				add-content "$log_file" "Bomgar is not installed on $comp; installation has failed. `n"
			write-host "Bomgar is already installed on $comp. `n"
			add-content "$log_file" "Bomgar is already installed on $comp. `n"
		write-host "$comp is offline. `n"
		add-content "$log_file_off" "$comp is offline. `n"

} © 2006-2017

Comments, submissions and errors to desk[at]

Material and content adheres to the Creative Commons (NC-SA 4.0) license.