[dba-Tech] Powershel script help

Jim Lawrence accessd at shaw.ca
Fri Apr 25 11:13:11 CDT 2014


Hi John:

So what does the variable $xml.RegistrationConfig.DaysRemaining look like? Does it retrieve a value?

Does:
$remaining = 0
$remaining = $xml.RegistrationConfig.DaysRemaining 

...or

$remaining = $xml.RegistrationConfig.DaysRemaining + 0 

produce a result?

Jim

----- Original Message -----
From: "John Bartow" <jbartow at winhaven.net>
To: "DBA-Tech" <dba-tech at databaseadvisors.com>
Sent: Thursday, April 24, 2014 6:08:30 PM
Subject: [dba-Tech] Powershel script help

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


More information about the dba-Tech mailing list