Everyone uses Mark Russinovich’s and Bryce Cogswell’s excellent Sysinternals Tools. Tools like Process Explorer and Process Monitor have helped solve some of the toughest bugs I’ve ever worked on. I’ve been surprised how many people didn’t know that all the tools available in a single download: the Sysinternals Suite.
Whenever I see that one of the tools is updated, I find it easiest to grab the Suite .ZIP file and unzip it to my utility directory. After having done the manual updating a couple of times, I wrote a PowerShell script to do the download and unzipping automatically. I thought others might find it useful. Note that you’ll need the excellent and free 7z archive tool in your path.
As I’m still a PowerShell novice, please don’t be afraid to point out anything I can do better.
##################################################################
# Get-SysInternalsSuite.ps1 – John Robbins – john@training.atmosera.com
#
# Note that this script requires the excellent 7Z.EXE in the
# PATH environment variable. You can get 7Z.EXE, which is free,
# at http://www.7-zip.org/.
#################################################################
param ( [string] $Extract ,
[string] $Save )
# Always make sure all variables are defined.
Set-PSDebug -Strict
function Usage
{
“”
“Downloads and extracts all the tools from Sysinternals”
“”
“Usage: Get-SysInternalsSuite -extract <directory>”
” [-save <directory>]”
“Required Parameter :”
” -extract <directory> : The directory where the SysinternalsSuite.zip”
” tools are extracted.”
“Optional Parameters :”
” -save <directory> : Saves SysinternalsSuite.zip to the specified”
” directory. If not specified, the .ZIP file ”
” is not saved.”
” -? : Display this usage information”
“”
“”
exit
}
function CreateDirectoryIfNeeded ( [string] $directory )
{
if ( ! ( Test-Path $directory -type “Container” ) )
{
New-Item -type directory -Path $directory > $null
}
}
##################################################################
# Main execution starts here.
# Check for the help request.
if ( ( $Args -eq ‘-?’) -or ( ! $Extract ) )
{
Usage
}
$paramLog = @”
Param Extract = $Extract
Param Save = $Save
“@
Write-Debug $paramLog
[string]$sevenZName = “7Z.EXE”
# Verify I can find UNZIP.EXE in the path.
[string]$sevenZPath = $(Get-Command $sevenZName).Definition
if ( $sevenZPath.Length -eq 0 )
{
Write-Error “Unable to find $sevenZName in the path.”
exit
}
# If the extract directory does not exist, create it.
CreateDirectoryIfNeeded ( $Extract )
# If there’s a save directory set, us that otherwise, use the %TEMP% directory.
[Boolean]$deleteZipFile = $TRUE
[String]$downloadFile = “”
if ( $Save.Length -gt 0 )
{
CreateDirectoryIfNeeded ( $Save )
$downloadFile = $Save
$deleteZipFile = $FALSE
}
else
{
# Use the %TEMP% path for the user.
$downloadFile = $env:temp
}
# Build up the full location and filename.
$downloadFile = $(Get-item $downloadFile).FullName
$downloadFile = Join-Path -path $downloadFile -childpath “SysinternalsSuite.zip”
# Let the download begin!
Write-Output “Starting download of the Sysinternals Suite”
$webClient = New-Object System.Net.WebClient
$webClient.DownloadFile(“http://download.sysinternals.com/Files/SysinternalsSuite.zip” ,
$downloadFile)
Write-Output “Sysinternals suite downloaded to $downloadFile”
# I don’t like to see all the output from 7z unless there’s a problem so I’ll
# redirect to a temporary file and if there’s any problems, I’ll show it.
$temp7zOutput = [System.IO.Path]::GetTempFileName()
# Since the -o option to 7Z.EXE cannot have a space between it and the
# directory there’s a bit of a problem. PowerShell does not expand the
# line -o$Extract if passed directly on the command line.
$outputOption = “-o$Extract”
Write-Output “Extracting files into $Extract”
&$sevenZPath x -y $outputOption $downloadFile > $temp7zOutput
if ( $LASTEXITCODE -ne 0 )
{
# There was a problem extracting.
Get-Content $temp7zOutput
# Don’t delete the download file.
$deleteZipFile = $FALSE
Write-Error “Error extracting the .ZIP file”
Write-Error “The downloaded .ZIP file is at $downloadFile and will not be deleted.”
}
# Delete the file that held the extraction output.
del $temp7zOutput
# Delete the downloaded .ZIP file if I’m supposed to.
if ( $deleteZipFile -eq $TRUE )
{
Remove-Item $downloadFile
}
Microsoft Azure and Amazon Web Services (AWS) are two of the most popular cloud platforms.…
Cloud management is difficult to do manually, especially if you work with multiple cloud…
Azure’s scalable infrastructure is often cited as one of the primary reasons why it's the…
https://www.youtube.com/watch?v=wDzCN0d8SeA Watch our "Unlocking the Power of AI in your Software Development Life Cycle (SDLC)"…
FinOps is a strategic approach to managing cloud costs. It combines financial management best practices…
Using Kubernetes with Azure combines the power of Kubernetes container orchestration and the cloud capabilities…
View Comments
In times before there was a ZIP package I created a simple .bat + some free command line utilities to do the same.
http://vidmar.net/weblog/archive/2007/05/19/GetSysinternals-1.2.aspx
Mine only downloads updated .zip files so you can run it every night and always have fresh stuff.
But I stopped updating the utilities list so I think I'll switch to your version.
You've been kicked (a good thing) - Trackback from DotNetKicks.com
To make it work from behind proxy add these lines before the call to $webClient.DownloadFile(.....)
$netCred = New-Object System.Net.NetworkCredential
$netCred.Domain="YOURDOMAIN"
$netCred.UserName="YOUNAME"
$netCred.Password="PASSWORD"
$webClient.Proxy.Credentials=$netCred
Improvising the script to accept proxy credentials on cmd line remains :)
Les indispensables outils Sysinternals sont maintenant accessibles directement en ligne via un répertoire
To Narasimha's point, another way of authenticating thru a proxy is to use the current user's credentials:$webClient = New-Object System.Net.WebClient$webClient.UseDefaultCredentials = $TRUE