Skip to content

Instantly share code, notes, and snippets.

@quonic
Last active April 29, 2022 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quonic/0805ccfb7e03bde06b71f43e2bcdfec6 to your computer and use it in GitHub Desktop.
Save quonic/0805ccfb7e03bde06b71f43e2bcdfec6 to your computer and use it in GitHub Desktop.
Get Input Voltage measurements from IPP's database for a single Eaton 5P UPS.

Example Output

Date                  Voltage
----                  -------
4/29/2022 9:49:47 AM  119.5
4/29/2022 10:10:20 AM 123.6
4/29/2022 10:10:26 AM 120.7
4/29/2022 11:10:49 AM 113.9
4/29/2022 11:10:55 AM 119.5
4/29/2022 11:33:18 AM 121.5
4/29/2022 11:40:18 AM 119.3
Import-Module SimplySql
# To allow acces from any user
# Remove Users deny permissons from C:\Program Files (x86)\Eaton\IntelligentPowerProtector\db\mc2.db
$ConfigFolderPath = "C:\Program Files (x86)\Eaton\IntelligentPowerProtector\db"
$ConfigPath = "$ConfigFolderPath\mc2.db"
$TempPath = "$env:TEMP\mc2_tmp.db"
Copy-Item -Path $ConfigPath -Destination $TempPath -Force
Open-SQLiteConnection -DataSource $TempPath -ConnectionName "eaton"
$Query = @"
SELECT
m.date,d.name,m.value
FROM
measures m
INNER JOIN
dictionnary d
ON
d.ID=m.objectID
WHERE
d.ID=9;
"@
Invoke-SqlQuery -Query $Query -ConnectionName "eaton" | ForEach-Object {
[PSCustomObject]@{
Date = [DateTime]::new(0).AddMilliseconds($($_.date)).AddYears(1969).ToLocalTime()
Voltage = $_.value
}
}
Close-SqlConnection -ConnectionName "eaton"
Remove-Item $TempPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment