PsExec powershell and CloudBerry Backup agent deployment

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:

How to do PsExec and powershell remote software installation

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/


In short, this is about:
#aws s3
#psexec
#cloudberrylab

Start discussion:
Related articles:
Cloudberry 1.8 for Mac OS X is now live! Impressive list of features and storage platforms support! S3 compatible, new UI and etc. ... more
over 2 years#cloudberrylab #mac
Asterisk IP PBX comes with embedded MixMonitor, that allows us to to record and place those recordings somewhere. ... more
Amazon Web Services (AWS) has its own AWS Linux AMI (also free tier). There are several reasons you want to use this AMI for your projects. ... more
Working with customers is great experience and you always learn or invent something new. I've been working on the case with files portioning ... more
In this article you'll learn how to protect your data against hardware and software failures according to the 3-2-1 rule. ... more
Since FullAccess is disabled even for Administrator's account in Exchange (including 2010) CloudBerry Backup for Exchange can't restore using Administrator's username and password pair for item level restore of any mailbox. Let's fix it. ... more
In CloudBerry Lab we help people to move data offsite to the cloud either with backup or file management solution. Sometimes I need sample files, a lot of sample files. ... more
Launching AWS EC2 can be supplied by something what is known as "user data" and it helps to have things ready before you access it. ... more
How to pre-deploy App using user data script for Windows OS with powershell powered script in EC2? Example inside. ... more
Looking for free option to backup your data? No issues, - have a look at various options available with AWS S3, AWS CLI or 3d parties for your sensitive data. ... more
about 1 year#aws s3 #backup
Here at CloudBerry, where one of the goal I have is to help partners decide, pick and build right configurations for dealing with computers data when they need backup solution. FTP, SCP, WebDav and some other proprietary protocols have been here forever, where simplicity and flexibility made them number one in data protection and management fields as primary target configurations. But, there is big BUT... ... more