John Bartow
jbartow at winhaven.net
Fri Apr 25 10:57:11 CDT 2014
Hi Paul, That was exactly the problem. Thanks! John B -----Original Message----- From: dba-tech-bounces at databaseadvisors.com [mailto:dba-tech-bounces at databaseadvisors.com] On Behalf Of Paul Hartland Sent: Thursday, April 24, 2014 11:47 PM To: Discussion of Hardware and Software issues Subject: Re: [dba-Tech] Powershel script help John, Was intrigued by powershell a while back but never done anything with it so I am probably wrong here or you may of already tried. You say that if you replace the $remaining with 272 it works, have you tried converting the $remaining to an int before the If ($remaining -gt 45) like below $xml = [xml](get-content C:\ProgramData\VIPRE\RegistrationConfig.xml) #C:\Programdata\GFI Software\Antimalware\RegistrationConfig.xml $remaining = $xml.RegistrationConfig.DaysRemaining #days until expiration - currently evaluates to 272 $expires = $xml.RegistrationConfig.ExpireDate #date of expiration $remainingint = $remaining -as [int] If ($remainingint -gt 45) It may not work as only had a quick look and had to refresh my memory with the help of good old google, but may be worth a try. Paul On 25 April 2014 02:08, John Bartow <jbartow at winhaven.net> wrote: > Hi all, > Any ideas as to why this doesn't work? If I replace: > "$remaining = $xml.RegistrationConfig.DaysRemaining " > With $remaining = 272 > Then it works correctly. Otherwise it works inversely in regards to > the -gt operator. > > Code ------------------------------------------------- > # Display Vipre license expiration date # Runs on Windows 7 Try { > $xml = [xml](get-content > C:\ProgramData\VIPRE\RegistrationConfig.xml) > #C:\Programdata\GFI Software\Antimalware\RegistrationConfig.xml > $remaining = $xml.RegistrationConfig.DaysRemaining #days until > expiration - currently evaluates to 272 > $expires = $xml.RegistrationConfig.ExpireDate #date of expiration > > If ($remaining -gt 45) > { > Write-Host "Vipre License expires in" $remaining "days on" > "{0:dd/MM/yyyy}" -f [datetime]$expires > Write-Host "Successfully passed" > exit 0 > } > else > { > Write-Host "Vipre License expires in" $remaining "days on" > "{0:dd/MM/yyyy}" -f [datetime]$expires > Write-Host "Vipre License is Expiring Soon!" > exit 1001 > } > } > Catch { > Write-Host "Failure" > exit 1001 > } > End Code ------------------------------------------------- > > TIA > John B > > _______________________________________________ > dba-Tech mailing list > dba-Tech at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/dba-tech > Website: http://www.databaseadvisors.com > -- Paul Hartland paul.hartland at googlemail.com _______________________________________________ dba-Tech mailing list dba-Tech at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/dba-tech Website: http://www.databaseadvisors.com