Install the latest version of Sysinternals Suite tools without any source files using SCCM (System Center Configuration Manager) and Powershell

Introduction

It’s an unusual and kind of off topic subject to me, but it might be useful to someone anyway. At least I think it’s different and creative 🙂

The Sysinternals Suite can be downloaded like any other bunch of tools and distributed with whatever method you prefer (download the latest version here: https://docs.microsoft.com/en-us/sysinternals/downloads/sysinternals-suite), but what if you always want the latest and greatest version, but don’t have the interest or resources to keep track of dates and versions? Read on. This is how you always install the latest version using System Center Configuration Manager and a Powershell script.

Requirement

For this to work, there’s a single requirement in having an active Internet connection at the time of installing. It almost goes without saying, but we don’t use any local source files in this scenario and we therefore download them directly from the Sysinternals file share.

Powershell

I’ve tried my best (almost) to explain along the lines what the script does.

The script comes with 2 options: Install and Uninstall (Install-SysInternalsSuite.ps1 -Install and Install-SysInternalsSuite.ps1 -Uninstall)

-Install

  • Check for an active Internet connection
  • Checks for access to \\live.sysinternals.com\Tools
    • If access, checks for version of the tools available online
  • Checks if the tools are installed locally
    • If they are installed, checks for version installed
  • Compare the versions. If the versions match, nothing will be installed
  • If the tools aren’t installed locally, or if there’s a mismatch in versions, new files will be copied/installed

-Uninstall

  • Removes the Sysinternals folder including content
<#
.DESCRIPTION
    Installs Sysinternals Suite tools directly from the online file share. Will check for latest version, and if version does not match the online version, new files will be copied down locally.

.EXAMPLES
    .\Install-SysInternalsSuite.ps1 -Install
        Installs the most recent version of the SysInternals Tools directly from the online fileshare

    .\Install-SysInternalsSuite.ps1 -Uninstall
        Uninstalls (deletes) the entire directory
 
.NOTES
    FileName:    Install-SysInternalsSuite.ps1
    Author:      Martin Bengtsson
    Created:     16-05-2018
#>

[CmdletBinding()]
param(
    [parameter(Mandatory=$false)]
    [ValidateNotNullOrEmpty()]
    [switch]$Install,

    [parameter(Mandatory=$false)]
    [ValidateNotNullOrEmpty()]
    [switch]$Uninstall

 )


# Check for Internet access. Will return True if Internet is available.
$Internet = [Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet 

# If Internet access, continue script
if ($PSBoundParameters["Install"]) {

    if ($Internet -eq "True") {
    
        Write-Host -ForegroundColor Green "Internet OK"

        $Source = "\\live.sysinternals.com\Tools"
        # Installation destination for all the tools included in Sysinternals Suite
        $Destination = "$env:ProgramFiles\SysinternalsSuite"
    
        # If access to the source, get the version of the source content
        if (Test-Path $Source) {
       
            $SourcePSVersion = Get-Content -Path $Source\psversion.txt
            Write-Host -ForegroundColor Yellow "Source:" $SourcePSVersion
        }   
    
        # If destination already exist, get version of destination content
        if (Test-Path $Destination) {
             
            $InstalledPSVersion = Get-Content -Path $Destination\psversion.txt
            Write-Host -ForegroundColor Yellow "Destination:" $InstalledPSVersion
        }
    
        # If the installed version matches the source version, do nothing
        if ($InstalledPSVersion -eq $SourcePSVersion) {
            Write-Host -ForegroundColor Green "Destination version matches source version - nothing to update"
            break
        }
    
        else {
        
            Write-Host -ForegroundColor Red "Destination does not match source - will copy files"

            # Create Destination folder if doesn't exist already
            if (-Not(Test-Path $Destination)) {
                Write-Host -ForegroundColor Green "Creating destination folder:" $Destination
                New-Item -ItemType Directory -Path $Destination
                }
        
            # Verify if $Source is accessible - continue if it is
            if (Test-Path $Source) {
            
                # Try copying files         
                try {
                    robocopy $Source $Destination /s /xo /r:0 /w:0
                   }

                catch {
                    Write-Host -ForegroundColor Red "Cannot robocopy"
                    }
            }

            else {
                Write-Host -ForegroundColor Red "No Access to the Source at " $Source
                break
                }
        }
    }
    # Exit if no Internet access
    else {
        Write-Host -ForegroundColor Red "No Internet Access"
        break
        }
}

if ($PSBoundParameters["Uninstall"]) {
    
    $Destination = "$env:ProgramFiles\SysinternalsSuite"
    if (Test-Path $Destination) {
        Remove-Item $Destination -Force -Recurse
        }
}

Configuration Manager

You have two options in leveraging Configuration Manager here. Applications or packages. For this particular installation, I’m preferring a package. Primary reason being the need to rerun on demand, when I want to check for a new version of the tools. So here goes the exact steps of creating the package in the Configuration Manager console.

  • In the Configuration Manager console in the Software Library workspace, expand Application Management and create a new Package
    • Fill out a name as a minimum
    • The Powershell script from above. Save it in your content library and use it as source folder (I know, not completely without source files, but the PS script has to come from somewhere)

  • Select a Standard program

  • Fill out a name
  • Command line: powershell.exe -ExecutionPolicy Bypass -File .\Install-SysInternalsSuite.ps1 -Install
  • Program can run: Whether or nor a user is logged on (My script requires local admin rights and as such this runs as SYSTEM)
  • Allow users to view and interact with the program installation: I’m having this selected to see the progress

  • Fill out requirements as needed and click Next

  • Finish the wizard on Next and Close. Distribute the package to your distribution points and be ready for deployment

Deployment

  • I’m deploying the program of the package as available to a collection of computers

End-user experience

  • Installing / Reinstalling the program

  • If the folder doesn’t exist, or if this is the first time running the installation ever, the running Powershell windows will look similar to this:

  • If the version locally match the one available on the online file share, the Powershell windows will provide a message similar to this:

Final note

This idea originally came from the possibility to actually map a drive in Windows to the Sysinternals file share:

NET USE z: \\live.sysinternals.com\Tools\

Hope this was useful and please like and share where possible. 🙂

Note: It just came to my attention, that the script doesn’t fully work unless you manually have been entering the sysinternals share. (in all my testing, that was of course the case, so I’m gonna redo the script as soon as possible. Until then, the idea is there 🙂

2 thoughts on “Install the latest version of Sysinternals Suite tools without any source files using SCCM (System Center Configuration Manager) and Powershell”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.