Archive now policy action strange behavior

I created a daily policy action that executes a PowerShell script, dumps the output to a specified location, and then uploads the files using the Archive Now function.

The issue I’m facing is that the action works perfectly the first time it runs. However, from the second execution onward, no files are uploaded. Strangely, if I create a custom copy of the action without any changes, the file upload works every time. Similarly, if I reinitiate the policy action, it uploads files on the first attempt but fails on subsequent runs.

I have never used the Archive Now functionality in a policy action before, so I haven’t encountered this behavior. I also raised a case with HCL Support, but since this is custom content and Archive Now functions correctly when tested separately, hence no luck. I am unsure whether this is due to a functionality restriction when using Archive Now in a policy action or if something else is preventing it from working consistently.

Could you suggest or provide any insights into what might be causing this issue? I am sharing my action script below—please let me know if you spot anything unusual that I may have overlooked.

delete __createfile
delete "__Download\bfx_winsrvr.ps1"
waithidden cmd.exe /C rmdir /S /Q "C:\temp\BFX_WinSRVR"

if {not exists folder "C:\temp\BFX_WinSRVR"}
folder create "C:\temp\BFX_WinSRVR"
endif

createfile until EOF
# Get the domain FQDN by querying the Active Directory domain
$domainFQDN = (Get-ADDomain).DNSRoot

# Get the current date and time formatted as yyyy-MM-dd_HH-mm-ss
$currentDateTime = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"

# Construct the file path using domain name, current date, and time
$filePath = "C:\temp\BFX_WinSRVR\$domainFQDN-$currentDateTime.csv"

# Get AD users and process them
Get-ADUser -Filter * -Properties samaccountname, displayname, enabled, passwordlastset, manager, whenCreated, DistinguishedName | 
    Select-Object samaccountname, displayname, enabled, passwordlastset, manager, whenCreated, DistinguishedName |
    ForEach-Object {{
        # Extract the domain part from samaccountname (if it's present)
        $domain = if ($_.samaccountname.Contains('\')) {{ $_.samaccountname.Split('\')[0] } else {{ 'No domain available' }

        # Extract the OU location from the DistinguishedName for the user
        $ouLocation = ($_.DistinguishedName -split ',', 2)[1] -replace '^OU=', ''

        # Check if manager exists and resolve their display name (only display name, no OU path for manager)
        $managerDisplayName = if ($_.manager) {{
            $manager = Get-ADUser -Identity $_.manager -Properties displayname
            $manager.displayname
        } else {{
            $null
        }

        # Add the FQDN, OU location for the user, and manager display name as properties
        $_ | Add-Member -MemberType NoteProperty -Name DomainFQDN -Value $domainFQDN
        $_ | Add-Member -MemberType NoteProperty -Name OULocation -Value $ouLocation
        $_ | Add-Member -MemberType NoteProperty -Name ManagerDisplayName -Value $managerDisplayName
        $_ | Select samaccountname,displayname,domainfqdn,enabled,passwordlastset,managerdisplayname,whencreated,OUlocation
    } |
    # Export the results to a CSV file with domain name, current date, and time
    Export-Csv -Path $filePath -NoTypeInformation -Force

Write-Host "CSV file saved to: $filePath"
EOF

move __createfile "__Download\bfx_winsrvr.ps1"

waithidden {pathname of regapp "powershell.exe"} -ExecutionPolicy Bypass -NoProfile -file "__Download\bfx_winsrvr.ps1"

if {not exists files whose (name of it as string as lowercase contains "csv" as lowercase) of folder "C:\temp\BFX_WinSRVR"}
exit 10
endif

setting "_BESClient_ArchiveManager_FileSet-{computer name}"="C:\temp\BFX_WinSRVR\*.csv" on "{parameter "action issue date" of action}" for client
setting "_BESClient_ArchiveManager_SendAll"="0" on "{now}" for client
setting "_BESClient_ArchiveManager_MaxArchiveSize"="100000000" on "{parameter "action issue date" of action}" for client 
setting "_BESClient_ArchiveManager_OperatingMode"="2" on "{now}" for client 
archive now
setting delete "_BESClient_ArchiveManager_FileSet-{computer name}" on "{now}" for client

You need to change SendAll to 1 - https://support.bigfix.com/product/documents/Upload_Archive_Manager_80_101211.pdf

The default behavior of SendAll is that if the HASH of the current archive is the same as the previous one - it will not be uploaded again

2 Likes

Great catch @orbiton ! :slight_smile:

Rather than continuing to struggle with it, I implemented an alternative approach by automatically re-creating the same action using the REST API as a workaround. :laughing: