Long time, no posts.. been out for re:invent for over a week following Christmas Eve weeks what in overall kept me busy. I still have some great thoughts on my recently started marathon of episodes around free tier. Promise to return to this task on the following holidays.
Working with service providers and large IT departments here at CloudBerry Lab we constantly receive interesting cases. On one of my project with very well known company from US together with IT guys we’ve been working on product deployment automation. The goal was to enable CB Backup (Windows build) on large number of endpoints with further bulk configuration deployment. I’ve made some research and done some boilerplates earlier, but that was specifically for case with AWS EC2 instances and specifically for new instances. The idea of bulk product deployment for Windows and Linux machines was based on Advanced User Data (pre-launch script). We later introduced support for existing instances making the logic even harder (used lambdas with tagging and certain keys where we pushed agents into instance or left it with no changes). That was interesting work, but this it is Amazon instance. As been said earlier now we face large number of Windows (desktop) boxes and we need to deploy agents remotely. Apparently we ended up with psexec since it gives great capabilities and does not require lots of changes and experts engagement.
PsExec bulk deployment highlights
PsExec is a light-weight telnet-replacement that lets you execute processes on other systems, complete with full interactivity for console applications, without having to manually install client software. PsExec's most powerful uses include launching interactive command-prompts on remote systems and remote-enabling tools like IpConfig that otherwise do not have the ability to show information about remote systems. At the time of this article it is available here and it is available in version 2.2 (Dec, 2017). We are going to use this tool with regular powershell in order to do the following:
- Download personal product build for CB Backup agent from AWS bucket (or from network share within company network);
- Create tiny script on remote machine (client where we want CB Backup installed);
- Trigger using PsExec remote script that makes some further logic (we will talk about it in few minutes).
We will also make this in automation manner for multiple computers. For that we are going to keep list of computer names (or IP addresses) in either text file or as array variable right in our powershell script on “server” machine (where we are going to initiate this bulk deployment).
So we are going to work with the following:

Server “initiator" configuration
First of all, we need PsExec. You can get it from here. Basically the package contains number of other great tools. You can place PsExec.exe
into the working directory or export into executable path (environment variables or other ways you know). For the sake of simplicity I put into the working directory, so I can get rid of it any time I don’t need it any longer.
Secondly, we need the following tiny script in place (this is going to be our powershell on "server side”):
cd c:\remote\
$computers = @(“192.168.1.1”. “192.168.1.2”)
for ($I=0, $I -lt $computers.Length; $I++) {
.\PsExec.exe \\$($computers[$I]) -u $username -p $password cmd.exe /c ‘echo . | powershell -file “c:\remote\deployer.ps1"'
}
This script has array of computers (to keep it simply I have only two computers in my array: 192.168.1.1 and 192.168.1.2). Line three iterates through the array and executes remote deployer.ps1 script. You may want to replace $username and $password with your personal or invoke two variables or keep them in array or make it even harder implement fetch method from AD / other directory service.
Client configuration
On the client side we need the following logic:
- Download build;
- Install build;
- Sign in build with MBS profile;
- Clean up.
Just create c:\remote\deployer.ps1
file and drop the following content into it:
$temp = "C:\temp"
$link = "your_exec_file_path_in_aws_s3_bucket"
$file = "cloudberry-backup.exe"
$silent = "/S"
$sleep = 30
# MBS related variables
$company = "Backup"
$product = "Backup"
$product_path = "${env:ProgramFiles(x86)}\$company\$product"
$email = "user@domain.com"
$password = "Pa$$w0rd"
New-Item $temp -ItemType directory
cd $temp
Invoke-WebRequest -Uri $link -OutFile $file
Start-Sleep -s $sleep
Start-Process -FilePath $file -ArgumentList $silent
Start-Sleep -s $sleep
# Sign in!
cd $product_path
./cbb editAccount -e $email -p $password
# Clean up
Start-Sleep -s $sleep
Remove-Item $temp -Force -Recurse
This script contains some variables, so you need to change them accordingly (IE $temp
, $link
, $file
). Feel free to adjust $sleep
if you feel your connection is slow to get the build binaries within 30 seconds before it jumps to the next step..
Test drive
Make sure you have correct array of computers listed on the step with “initiator” configuration. Launch your script and see the output!
Used resources
CloudBerry Managed Backup Service - https://www.cloudberrylab.com/managed-backup/signup.aspx
PsExec v2.2 - https://docs.microsoft.com/en-us/sysinternals/downloads/psexec
Amazon (AWS) S3 - https://aws.amazon.com/s3/