Created
June 5, 2012 10:13
-
-
Save xoner/2874161 to your computer and use it in GitHub Desktop.
PowerShell module to update the sysinternals suite taking as reference the utilites published in \\live.sysinternals\tools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Set-StrictMode -Version 2.0 | |
function Sysinternals-Updater | |
{ | |
Param | |
( | |
[Parameter(Mandatory=$false)] | |
[Switch] | |
$checkOnly = $false, | |
[Parameter(Mandatory=$false)] | |
[String] | |
$localSysinternals = '****Change with the path to the sysinternals suite folder in your machine****', | |
[Parameter(Mandatory=$false)] | |
[String] | |
$remoteSysinternals = '\\live.sysinternals.com\tools' | |
) | |
foreach($localUtil in ls $localsysInternals -Filter '*.exe') | |
{ | |
$remoteUtilPath = [System.IO.Path]::Combine($remoteSysinternals, $localUtil.Name).ToString() | |
if(Test-Path $remoteUtilPath) | |
{ | |
$remoteUtil = ls $remoteUtilPath | |
if($localUtil.VersionInfo.ProductVersion -ne $remoteUtil.VersionInfo.ProductVersion) | |
{ | |
Write-Host -ForegroundColor Red $localUtil.Name` | |
+ ', local ver.: ' + $localUtil.VersionInfo.ProductVersion ` | |
+ 'remote ver.: ' + $remoteUtil.VersionInfo.ProductVersion | |
if(!$checkOnly) | |
{ | |
Write-Host -ForegroundColor DarkRed "`t updating " + $localUtil.Name + " to the last version..." | |
Copy-Item $remoteUtilPath $localSysinternals | |
Write-Host -ForegroundColor DarkGreen "`t " + $localUtil.Name + " updated" | |
} | |
} | |
else | |
{ | |
$lMessage = [string]::Format("{0} is up to date, local ver. {1}, remote ver. {1}", ` | |
$localUtil.Name, $localUtil.VersionInfo.ProductVersion, ` | |
$remoteUtil.VersionInfo.ProductVersion) | |
Write-Host -ForegroundColor Green $message | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment