Keep in-sync with SysInternals tools
As you already know, all SysInternals utilities are available as a file share. Meaning you can run the tools directly from the Internet (e.g http://blogs.microsoft.co.il/controlpanel/blogs/$live.sysinternals.com\<toolName>), navigate to them with your browser or even map a drive on your local computer.
The SysInternals tools suite is a must have on any sysadmin machine. On my computer I keep them in a special directory (c:\sysint). From time to time the tools get updated or new tools get published and you might not know when it happens.
This is where Get-SysInternals comes into place. It lists the file share and compares each file's last modified date to the corresponding file on the local directory (if exists). If the 'live' file is newer, it is copied to the local directory and a yellow message in echoed to the console, new tools are painted in green. A log file is also generated into the specified directory by the name of changes.log.
At first I thought to compare the utilities file version info, but as you can see from the below, not all files have a version so I used the last modified date (lastWriteTime) instead.
PS > dir \\live.sysinternals.com\Tools -filter *.exe | select -expand vrsionInfo | ft @{l="Name";e={split-path $_.fileName -leaf}},FileVersion -auto
Name FileVersion
---- -----------
accesschk.exe 4.20
AccessEnum.exe 1.32
accvio.EXE
ADExplorer.exe 1.01
ADInsight.exe 1.01
adrestore.exe
Autologon.exe 2.10
autoruns.exe 9.33
autorunsc.exe 9.33
Bginfo.exe 4, 14, 0, 0
Cacheset.exe
Clockres.exe
Contig.exe 1.54
ctrl2cap.exe
Dbgview.exe 4.75
DEFRAG.EXE
Desktops.exe 1.00
diskext.exe 1.1
Diskmnt.exe
Diskmon.exe 2.01
DiskView.exe
du.exe 1.31
efsdump.exe
Filemon.exe 7.04
handle.exe 3.41
...
The default local destination directory for the files is 'c:\sysint' and it will be created automatically if it doesn't exist. If you want another directory of your choice then simply run it like so: 'Get-SysInternals D:\otherDirName'
function Get-SysInternals {
param ( $sysIntDir="c:\sysint" )
if(!(Test-Path -Path $sysIntDir -PathType Container))
{
$null = New-Item -Type Directory -Path $sysIntDir -Force
}
$log = join-path $sysIntDir "changes.log"
Add-Content -force $log -value "`n`n[$(get-date)]SysInternals sync has been started"
dir \\live.sysinternals.com\tools -recurse | foreach {
$fileName = $_.name
$localFile = join-path $sysIntDir $_.name
$exist = test-path $localFile
$msgNew = "new utility found: $fileName , downloading..."
$msgUpdate = "file : $fileName is newer, updating..."
$msgNoChange = "nothing changed for: $fileName"
if($exist){
if($_.lastWriteTime -gt (Get-Item $localFile).lastWriteTime)
{
Copy-Item $_.fullname $sysIntDir -force
Write-Host $msgUpdate -fore yellow
Add-Content -force $log -value $msgUpdate
}
else
{
Add-Content $log -force -value $msgNoChange
Write-Host $msgNoChange
}
}
else
{
if($_.extension -eq ".exe")
{
Write-Host $msgNew -fore green
Add-Content -force $log -value $msgNew
}
Copy-Item $_.fullname $sysIntDir -force
}
}
}
And a sample output
PS > Get-SysInternals
File: accesschk.exe is newer, updating...
File: AccessEnum.exe is newer, updating...
New utility found: accvio.EXE, downloading...
File: AdExplorer.chm is newer, updating...
File: ADExplorer.exe is newer, updating...
File: ADInsight.chm is newer, updating...
File: ADInsight.exe is newer, updating...
File: adrestore.exe is newer, updating...
File: Autologon.exe is newer, updating...
File: autoruns.chm is newer, updating...
File: autoruns.exe is newer, updating...
File: autorunsc.exe is newer, updating...
File: Bginfo.exe is newer, updating...
File: Cacheset.exe is newer, updating...
File: Clockres.exe is newer, updating...
File: Contig.exe is newer, updating...
File: ctrl2cap.amd.sys is newer, updating...
File: ctrl2cap.exe is newer, updating...
File: ctrl2cap.nt4.sys is newer, updating...
File: ctrl2cap.nt5.sys is newer, updating...
File: dbgview.chm is newer, updating...
File: Dbgview.exe is newer, updating...
New utility found: DEFRAG.EXE, downloading...
New utility found: Desktops.exe, downloading...
File: diskext.exe is newer, updating...
File: Diskmnt.exe is newer, updating...
File: Diskmnt.hlp is newer, updating...
File: Diskmon.exe is newer, updating...
...
Now all that is left to do is run it once in a while (I run it on every Sunday) and see if there were any changes to the live share. This is what I use to *schedule* it, put it in your PowerShell profile and wait for next Sunday ;-):
if( (get-date -f dddd) -eq "sunday") { Get-SysInternals }