Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Download SysInternals with PowerShell

Posted on October 29, 2013

sysinternals Like many IT Pros, I'm a big fan of the utilities that make up the Sysinternals suite. A number of years ago, Microsoft created a "live" web directory (http:\\live.sysinternals.com\tools) that allowed you direct access to each utility. While this is very handy, personally I prefer to keep a local version. I used to periodically check the site and update my local folder, but now I can use PowerShell.

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!
#requires -version 3.0

<#
Download Sysinternals tools from web to a local folder.

  ****************************************************************
  * DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED *
  * THOROUGHLY IN A LAB ENVIRONMENT. USE AT YOUR OWN RISK.  IF   *
  * YOU DO NOT UNDERSTAND WHAT THIS SCRIPT DOES OR HOW IT WORKS, *
  * DO NOT USE IT OUTSIDE OF A SECURE, TEST SETTING.             *
  ****************************************************************
#>

[cmdletbinding(SupportsShouldProcess)]

Param(
[Parameter(Position=0)]
[ValidateScript({Test-Path -Path $_})]
[string]$Destination = "G:\SysInternals"
)

#start the WebClient service if it is not running
if ((Get-Service WebClient).Status -eq 'Stopped') {
     Write-Verbose "Starting WebClient"
     #always start the webclient service even if using -Whatif
     Start-Service WebClient -WhatIf:$false
     $Stopped = $True
}
else {
    <#
     Define a variable to indicate service was already running
     so that we don't stop it. Making an assumption that the
     service is already running for a reason.
    #>
    $Stopped = $False
}

#get current files in destination
$current = dir -Path $Destination -File

Write-Host "Updating Sysinternals tools from \\live.sysinternals.com\tools to $destination" -ForegroundColor Cyan

foreach ($file in $current) {
  #construct a path to the live web version and compare dates
  $online = Join-Path -path \\live.sysinternals.com\tools -ChildPath $file.name
  Write-Verbose "Testing $online"
  if ((Get-Item -Path $online).LastWriteTime.Date -ge $file.LastWriteTime.Date) {
    Copy-Item $online -Destination $Destination -PassThru
  }
}

Write-Host "Testing for online files not in $destination" -ForegroundColor Green

#test for files online but not in the destination and copy them
dir -path \\live.sysinternals.com\tools -file | 
Where {$current.name -notcontains $_.name} |
Copy-Item -Destination $Destination -PassThru

<#
alternative but this might still copy files that haven't
really changed
Robocopy \\live.sysinternals.com\tools $destination /MIR
#>

if ( $Stopped ) {
    Write-Verbose "Stopping web client"
    #always stop the service even if using -Whatif
    Stop-Service WebClient -WhatIf:$False
}

Write-Host "Sysinternals Update Complete" -ForegroundColor Cyan
#end of script

My version requires PowerShell 3.0. You need to have the WebClient service running in order to list the Internet files. My script has code to start and stop the service as needed. Although if it detects the service is already running, the script won't stop it under the assumption that you probably had it running for a reason.

The logic behind the script is pretty simple, if the date of the online version is greater than the local version, copy the file. One thing I ran into though is that there can be a discrepancy with the time stamps due to time zones and/or daylight savings time. I couldn't find an easy way to take those things into account so I opted to simply test the date and ignore the time.

The next thing I should do is set up a PowerShell scheduled job to run the script on a monthly basis. I hope you'll let me know how this works out for you.


Behind the PowerShell Pipeline

Share this:

  • Share on X (Opens in new window) X
  • Share on Facebook (Opens in new window) Facebook
  • Share on Mastodon (Opens in new window) Mastodon
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Reddit (Opens in new window) Reddit
  • Print (Opens in new window) Print
  • Email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

16 thoughts on “Download SysInternals with PowerShell”

  1. Jeffery Hicks says:
    October 29, 2013 at 1:36 pm

    An alternative is to use Chocolatey: http://chocolatey.org/packages/sysinternals. Thanks to Stefan Stranger (@sstranger) for pointing this out.

  2. Pat Richard (@patrichard) says:
    October 29, 2013 at 3:53 pm

    If you don’t have the WebClient service installed (such as in Windows Server 2012), you need to install the Desktop Experience. Also need to have the destination folder created in advance.

    1. Jeffery Hicks says:
      October 29, 2013 at 3:55 pm

      Yes on all counts. I never think about running the tools on a server so I didn’t think about that. And the script does in fact test for the existence of the folder. Of course, you could easily modify the script to create it for you should you so wish.

  3. CrazyDave says:
    October 30, 2013 at 9:11 am

    for a long time I’ve just been using “robocopy /xo /s /z \\live.sysinternals.com/tools $dest” but I’ve found that many times robocopy can’t find that UNC path…

    1. Jeffery Hicks says:
      October 30, 2013 at 9:38 am

      Robocopy also needs the Webclient service running. If it fails or stops that would explain your problem.

  4. Patrick says:
    October 30, 2013 at 9:27 am

    I like the idea of doing the update with powershell. Its also a good excersice! I used the following.

    wget.exe -N -nd -np -l 1 -r -w 3 http://live.sysinternals.com/

    I’m giving this powershell thing a try

    1. Jeffery Hicks says:
      October 30, 2013 at 9:39 am

      Certainly there are a number of ways to download items from the Internet. I’m not sure in this particular scenario if one technique is better than any others.

  5. Prasad says:
    October 31, 2013 at 12:02 am

    Thanks for sharing great stuff.

  6. Pingback: Download SysInternals with PowerShell | Welcome To Prasad Linux Blog
  7. Pingback: Zajímavé novinky ze světa IT z 44. týdne 2013 | Igorovo
  8. Pingback: Microsoft Most Valuable Professional (MVP) – Best Posts of the Week around Windows Server, Exchange, SystemCenter and more – #53 - Flo's Datacenter Report
  9. Pingback: Microsoft Most Valuable Professional (MVP) – Best Posts of the Week around Windows Server, Exchange, SystemCenter and more – #53 - TechCenter - Blog - TechCenter - Dell Community
  10. Pingback: Dell’s Digest for November 4, 2013 | ServerKing
  11. Stuart Pike says:
    January 4, 2014 at 5:05 pm

    Could you have the script update the OS environment variables path so when typing the system will automatically find the tools instead of remembering to type the full path?

    1. Jeffery Hicks says:
      January 5, 2014 at 7:29 am

      I don’t have anything specifically for that. If you want a permanent change, you could use PowerShell to modify the path settings in the registry. If you need help with that, I recommend the forums at PowerShell.org. A much better place to work on a problem than via blog comments.

  12. Pingback: Using Disk2VHD for Hyper-V P2V (Physical to Virtual) Conversions

Comments are closed.

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2026 The Lonely Administrator | Powered by SuperbThemes!
%d