12 February, 2024

APC by Schneider - Change battery date - Clear battery error.

Looks like newer firmware added a way to do this in the GUI as follows:

(see the last  bit below the FTP stuff - For a PowerShell method)

Log into the Web interface / GUI (duh!)

Navigate to:

Configuration > General > User Config file:

'Uploading Configuration INI File'

Download the Config.ini: [Download]

Edit the dates on these two lines:

(line number 368): BatteryDate=05/30/2025

(line number 378): BatteryPack1CartridgeAInstallDate=05/30/2025

Save the file...

Note: You may need to log back into the device (sessions do time out quickly)

Configuration > General > User Config file:

'Uploading Configuration INI File'

[Browse] to and select the file you saved.

[Apply]

The emails:
Expect to see a bunch of 'Informational - Configuration file warning: Invalid value on line ###'

On the 'home' tab you should see:
'UPS: Battery measured life near end cleared'

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Previously (older firmware versions (I think) this has to be done via telnet and ftp as follows:

You may find that ftp first needs to be enabled on the UPS...

Explaining the telnet and ftp enablement bit is the longest part really...
If you already have FTP enabled - and don't care how to do it via CLI...

Scroll down to: 'Here is how to update the 'Battery Date'

#########################################
Check to to see that ftp is enabled first - here:

Enable FTP...

Log into the Web interface / GUI (duh!)

Navigate to:

Configuration > Network > FTP Server: 'Enable' (checkbox) [Apply]

NOTE: You will return to this page to later DISABLE FTP - It is seen as a security risk - Don't leave it enabled

Disable FTP...

Configuration > Network > FTP Server: 'Enable' (uncheck) [Apply]

It can also be enabled via telnet... In fact, all of this can be done via CLI...

~~~~~~~~~~~~~~~~~~~~~~~~~~

Note: This command will enable telnet - (needed if you get an error about 'telnet' not being a recognized command):

At an elevated command prompt type: pkgmgr /iu:"TelnetClient"

This enables telnet...
~~~~~~~~~~~~~~~~~~~~~~~~~~

How to get telnet connected - Open a CMD prompt and:

telnet <UPS IP address> 23 (port 23 is the default telnet port)

User Name: apc (the default)

Password: apc (this is the default password - you should change this)

Once logged in, type: ? <and hit enter>

(this just lists all available commands)

Type: ftp <and hit enter>

apc>ftp
E000: Success
Service:        disabled
Ftp Port:       21

apc>ftp ?

Usage: ftp --  Configuration Options
    ftp [-p <port-number>] (21 and 5001-32768)
        [-S <enable | disable>]

NOTE: The '-S' is case sensitive - it is an uppercase letter

ftp -S enable <and hit enter>

apc>ftp -S enable
E002: Success
Reboot required for change to take effect.

Use the reboot command -

apc>reboot <and hit enter>

apc>reboot
E000: Success
Reboot Management Interface
Enter 'YES' to continue or <ENTER> to cancel :

(You do have to reopen the telnet and log back in after a reboot.)

Conversely (once you are done using ftp)...

ftp -S disable <and hit enter>

apc>ftp -S disable
E002: Success
Reboot required for change to take effect.

apc>reboot <and hit enter>

apc>reboot
E000: Success
Reboot Management Interface
Enter 'YES' to continue or <ENTER> to cancel :

OK - With THAT part explained - 

Here is how to update the 'Battery Date'

Take note of the current directory shown at the command prompt - THIS is where the 'config.ini' is going to be sent / saved to.

At the command prompt:

ftp <UPS IP address>

Log in as prompted...

Type THIS command:

get config.ini 

Once that completes (it takes a few seconds)...

Locate 'config.ini' as noted above -
Open it on Notepad (or other text editor - I don't care - I'm not your mom!)

Search for (Ctrl+F) 'Battery' in this file...

(line number 368): BatteryDate=05/30/2025

(line number 378): BatteryPack1CartridgeAInstallDate=05/30/2025

Edit the correct date value in this format: mm/dd/yyyy

Save the file and close it.

At the ftp prompt type: 'put ' (note the space after 'put' - include that space)

Then drag and drop that 'config.ini' file into the ftp window (or type in the full path... But drag and drop is way easier, tho)

put C:\Users\Yourself\config.ini <and hit enter>

Allow that to complete...

To end the ftp session type: bye <and hit enter>

If you have notifications set up... 

Processing the new config is going to generate about twenty something emails...

One of those emails will include: 'Informational - UPS: Battery life exceeded cleared.'

REMEMBER TO DISABLE FTP
(as explained above)

Finally got around to putting together a Powershell method for this...
NOTE: FTP does still have to be enabled on the device beforehand.
Enabling FTP is explained above.

$NewDate = "06/02/2025"

####### You do still have to enable FTP ###########
########### Download a file via FTP ###################

$Username = "admin"
$Password = "<passwords>"
$LocalFile = "C:\Users\<user>\Downloads\UPSConfig.ini" # The folder location, and the name you want the downloaded file to have.
$RemoteFile = "ftp://192.168.48.132/config.ini"

Write-Host "Downloading 'config.ini'..." -F 10
# Create a FTPWebRequest
$FTPRequest = [System.Net.FtpWebRequest]::Create($RemoteFile)
$FTPRequest.Credentials = New-Object System.Net.NetworkCredential($Username,$Password)
$FTPRequest.Method = [System.Net.WebRequestMethods+Ftp]::DownloadFile
$FTPRequest.UseBinary = $true
$FTPRequest.KeepAlive = $false
# Send the ftp request
$FTPResponse = $FTPRequest.GetResponse()
# Get a download stream from the server response
$ResponseStream = $FTPResponse.GetResponseStream()
# Create the target file on the local system and the download buffer
$LocalFileFile = New-Object IO.FileStream ($LocalFile,[IO.FileMode]::Create)
[byte[]]$ReadBuffer = New-Object byte[] 1024
# Loop through the download
do {
$ReadLength = $ResponseStream.Read($ReadBuffer,0,1024)
$LocalFileFile.Write($ReadBuffer,0,$ReadLength)
}
while ($ReadLength -ne 0)

$LocalFileFile.Close()

################## Modify the lines to change the battery replacement date ###################
Write-Host "Changing the dates in the 'config.ini'..." -F 10
$UPSConfig = gc $LocalFile

$00 = @('BatteryDate=','BatteryPack1CartridgeAInstallDate=')

$BatteryDate = $UPSConfig.IndexOf( ( $UPSConfig | ? { $_ -match $00[0] } ) ) # Should be line 367
$BP1CartDate = $UPSConfig.IndexOf( ( $UPSConfig | ? { $_ -match $00[1] } ) ) # Should be line 377

If ( $BatteryDate -ne 367 -or $BP1CartDate -ne 377 ) { 
Write-Host "Check the file... look for extra lines at the end..." -F 14 -B 5
Write-Host "  '" -F 14 -B 1 -N; Write-Host "$($00[0])" -F 12 -B 1 -N;Write-Host "' index value: $BatteryDate" -F 14 -B 1
Write-Host "  '" -F 14 -B 1 -N; Write-Host "$($00[1])" -F 12 -B 1 -N;Write-Host "' index value: $BP1CartDate" -F 14 -B 1
& notepad $LocalFile 
Return; Break
}

Write-Host "Lines ($BatteryDate and $BP1CartDate) before:" -F 11
$UPSConfig | ? { $_ -match "BatteryDate=|BatteryPack1CartridgeAInstallDate=" }

$UPSConfig[$BatteryDate] = "$($00[0])$NewDate"
$UPSConfig[$BP1CartDate] = "$($00[1])$NewDate"

<# 
By default, 'Out-File' encoding is utf16 -- utf16 will not work for this config file
The downloaded file is utf8 without BOM - So the 'ASCII' encoding is what is needed.
utf8 is is the encoding that shows in Notepad when viewing the file.
When using '-Encoding ASCII'... reading the encoding (see below) reports: 
BodyName          : iso-8859-1
EncodingName      : Western European (Windows)
HeaderName        : Windows-1252
#>

($UPSConfig | Out-String).TrimEnd() | Out-File -Force $LocalFile -Encoding ASCII

$UPSConfig = gc $LocalFile

# Confirm the dates:
''
Write-Host "Lines ($BatteryDate and $BP1CartDate) after:" -F 10
$UPSConfig | ? { $_ -match "BatteryDate=|BatteryPack1CartridgeAInstallDate=" }

$Choice = ('y','n','x')
Do {
Write-Host "Update the config ? ( Y / N [or 'x']): " -Fore 11 -No; $DoEeeet = Read-host
} Until ($Choice -contains $DoEeeet)

If ($DoEeeet -ne "y") {
Write-Host "Stopping..." -F 14 -B 4
Return; Break
}
################## Push the file back to the device via FTP ###################

$request = [System.Net.FtpWebRequest]::Create($RemoteFile)
$request.Credentials = New-Object System.Net.NetworkCredential($Username, $Password)
$request.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile
$request.UsePassive = $true
$fileStream = [System.IO.File]::OpenRead($LocalFile)
$ftpStream = $request.GetRequestStream()
$fileStream.CopyTo($ftpStream)
$ftpStream.Dispose()
$fileStream.Dispose()

Return; Break
##################################################################
# Read the encoding of a file: $reader = [System.IO.StreamReader]::new($LocalFile,[System.Text.Encoding]::default,$true) $peek = $reader.Peek() $encoding = $reader.currentencoding #.EncodingName $reader.close() $encoding ##################################################################