DavidHobbs

Scripted remote SMACC install

Discussion created by DavidHobbs Advocate on Jun 7, 2019
Latest reply on Jun 16, 2019 by snowtom

Hi,

 

There's an article by Detlev here about installing the SMACC on remote computers.  It's very useful, but it's quite a tedious manual process which needs to be repeated each time there are updates.  So I decided to write a powershell script which does it automatically.  When Snow updates, all I need to do is run the script again.  I thought that I'd share it in case anybody wants to do the same.

 

Note: I have not tested this *exact* version of the script, because our servers don't all have the Snow software installed on the C:\ drives.  This version below assumes that everything is installed on C:\, which I think is the default. You'll need to enter your server names where shown at the start of the script.

 

Warning: the usual disclaimers apply! Don't blame me if the script does anything wrong.  Please check through the code before you try it on your environment.

 

But please let me know if it's useful (and if it works for you).  I've pasted the script below...

 

Regards, David

 

<#
  Remote SMACC install/update for Snow
  Author: David Hobbs
  Updated: 2019-06-07
#>

 

# NOTE: Enter your server names below:
#
$invServer = "YOUR_INVENTORY_SERVER_NAME";
$slmServer = "YOUR_SLM_SERVER_NAME";
#
# END NOTE

 

Function Copy-WithProgress
{
  [CmdletBinding()]
  Param(
    [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true, Position=0)] $Source,
    [Parameter(Mandatory=$true, ValueFromPipelineByPropertyName=$true, Position=1)] $Destination,
    [Parameter(Mandatory=$false, ValueFromPipelineByPropertyName=$true, Position=2)] $Clean = $true
  )
  $Filelist = Get-Childitem "$Source" –Recurse;
  $Total = $Filelist.Count;
  $Position = 0;
  $Source = $Source.ToLower();

 

  if (!(test-path $Destination)) {
    New-Item -ItemType Directory -Force -Path $Destination;
  } elseif ($Clean) {
    # (optionally) remove any old files before copying the new ones
    Remove-Item "$Destination\*" -Recurse -Force;
  }

  foreach ($File in $Filelist) {
    $FileOnly = Split-Path $File.Fullname -Leaf;
    $PathOnly = (Split-Path -Path $File.Fullname).ToLower();
    $FileLowerPath = Join-Path -Path "$PathOnly" -ChildPath "$FileOnly";

    If ($FileLowerPath.StartsWith($Source)) {
      $Filename = $FileLowerPath.Remove(0, $Source.Length);
    }

    $DestinationFile = Join-Path -Path "$Destination" -ChildPath "$Filename";
    Write-Progress -Activity "Copying data from '$Source' to '$Destination'" -Status "Copying File $Filename" -PercentComplete (($Position / $total) * 100);

    Copy-Item $File.FullName -Destination $DestinationFile -Force;
    $Position++;
  }
}

 

function Copy-FromInv($path, $invServerDrive, $clean = $true) {
  $remote = "\\$invServer\$invServerDrive$\$path";
  $local = "C:\$path";
  Copy-WithProgress -Source $remote -Destination $local -Clean $clean;
}

 

function Copy-FromSlm($path, $slmServerDrive, $clean = $true) {
  $remote = "\\$slmServer\$slmServerDrive$\$path";
  $local = "C:\$path";
  Copy-WithProgress -Source $remote -Destination $local -Clean $clean;
}

 

# step 1
Copy-FromInv "Program Files\Snow Software\Snow Management and Configuration Center" "C";

 

# step 2
Copy-FromInv "Program Files\Snow Software\Snow Inventory\InventorySMACCPlugin" "C";

 

# step 3
Copy-FromSlm "Program Files\Snow Software\Snow License Manager\Tools\SmaccPlugin" "C";

 

# step 4
Copy-FromInv "ProgramData\SnowSoftware\SnowMACC\RegisteredPlugins" "C";
Copy-FromSlm "ProgramData\SnowSoftware\SnowMACC\RegisteredPlugins" "C" $false; # don't clean the directory this time

 

# step 5 - TEST IT :-)
# You can try to run "C:\Program Files\Snow Software\Snow Management and Configuration Center\SnowMACC.exe"

Outcomes