You can make it shorter by making your lines longer. But then they are harder 
to read and 6 months from now when you want to debug it, you'll just say WTF?

This looks just fine to me.

From: [email protected] [mailto:[email protected]] On 
Behalf Of James Rankin
Sent: Thursday, April 3, 2014 3:00 PM
To: [email protected]
Subject: [NTSysADM] PowerShell tidy-up

I did this quick bit of PS to check a file version number and then launch a 
patching process if it isn't at a certain level. It works OK but I am sure 
there is a much cleaner and more elegant way to do this. Any pointers?
Here's the script

$1 = (Get-Command "C:\Program Files\AppSense\Environment 
Manager\Agent\EMCoreService.exe").FileVersionInfo.FileVersion

$2 = $1.replace(".","")


IF ($2 -lt 844950)
{
 Start-Process -FilePath "$env:systemroot\system32\msiexec.exe" -ArgumentList 
"/p 
\\DC\FileStore\AppSense\EnvironmentManagerAgent64.msp<file:///\\DC\FileStore\AppSense\EnvironmentManagerAgent64.msp>
 /qn" -Wait
}
ELSE
{
 exit 0
}
I'm sure I could do this much better....please aid my development.... :-)

Cheers,


--
James Rankin
---------------------
RCL - Senior Technical Consultant (ACA, CCA, MCTS) | The Virtualization 
Practice Analyst - Desktop Virtualization
http://appsensebigot.blogspot.co.uk

Reply via email to