TROUBLESHOOTING: Upload a Specified File or Folder - Windows (1.0) - superseded
Log In or Register to download the BES file, and more.

0 Votes

Versioning - This is an older version.

1TROUBLESHOOTING: Upload a Specified File or Folder - Windows (1.0)11/17/2022 8:06:59 AM
2TROUBLESHOOTING: Upload a Specified File or Folder - Windows (1.0)11/17/2022 8:40:05 AM
3TROUBLESHOOTING: Upload a Specified File or Folder - Windows (1.0)11/17/2022 8:42:36 AM
4TROUBLESHOOTING: Upload a Specified File or Folder - Windows (1.0)11/17/2022 10:58:44 AM
5TROUBLESHOOTING: Upload a Specified File or Folder - Windows (1.0)11/17/2022 12:23:14 PM

Description

TROUBLESHOOTING:  Upload a Specified File or Folder - Windows (1.0)

Description

This task will compress the file or folder with the built-in windows makecab.exe utility on Windows machines.  It will then upload the resulting compressed file to the Bigfix server. 

IMPORTANT: To specify a folder, leave a trailing slash on the file name prompt.  To upload the logs from the Bigfix client folder on a Windows machine, for instance, use this:

  • C:\Program Files (x86)\BigFix Enterprise\BES Client\__BESData\__Global\Logs\

A single file needs a full path, this sample will upload the logfile.txt (relay log) file from a WIndows-based relay server:

  • C:\Program Files (x86)\BigFix Enterprise\BES Relay\logfile.txt

Deployment Notes

  • Run this only when needed.
  • This fixlet will exit with code 413 if the combined file size of the target files is over 100MB and will exist with a code 404 if the file or folder does not exist on the endpoint.  .
  • To locate the compressed files, you must have access to the file system of the Bigfix root server and know the computer ID of the computer that you want to find the files for.  The filename ends in fileupload.cab or fileupload.tar.gz and the path for each computer ID will look like this:

<Bigfix server install folder>\UploadManagerData\BufferDir\sha1\<last two digits of computer ID>\<full computer ID>

  • As an alternative to digging into the UploadManagerData folder structure, there is an accompanying task named "TROUBLESHOOTING: File or Folder Uploads Monitor" which can be used to monitor for file uploads on the root server that are a result of this task and then move them to a specific folder for easier consumption.
  • This fixlet has a hardcoded secure parameter to prevent targeting endpoints by property, this reduces the risk of an unintentional DDoS on your infrastructure.  To disable this behavior, make a copy of this fixlet and remove the script element below this text.

Supported Platforms

All versions of Windows supported by the BigFix client.


Version and Release Info

1.0.0 -- Initial Version


Property Details

ID26970
StatusQA - Ready for Production Level Testing
TitleTROUBLESHOOTING: Upload a Specified File or Folder - Windows (1.0)
DomainBESC
CategoryBigFix AVP
SourceInternal
Source Release Date11/17/2022 12:00:00 AM
KeywordsTroubleshooting, upload manager, archive manager, file uploads, actionscript, secure parameter
Is TaskTrue
Added by on 11/17/2022 8:42:36 AM
Last Modified by on 11/17/2022 8:42:36 AM
Counters 1048 Views / 3 Downloads
User Rating 1 star 2 star 3 star 4 star 5 star * Average over 0 ratings. ** Log In or Register to add your rating.

Relevance

Used in 5 fixlets   * Results in a true/false
Show indented relevance
/* WINDOWS ENDPOINT */ windows of operating system

Actions

Action 1 (default)

Action Link Click here to deploy this action.
Script Type BigFix Action Script
action log all

//* ====================================================================================================>
//*
//* DESCRIPTION AND NOTES
//*
//* - This task will upload speciifed Windows files or folders to the root server.
//*
//* ====================================================================================================>


//* ====================================================================================================>
//*
//* SET SOME PARAMETERS
//*
//* - These parameters can be used to control the behavior of the action
//*
//* ====================================================================================================>

action parameter query "FilePath" with description "Please enter full path to a file or folder. Leave a trailing \ to indicate folder upload mode."
parameter "Exportfolder" = "{data folder of client as string & ("\FileUploader\")}"
parameter "maximumfilesizeMB" = "100"

// This is to allow uploading files from the "Program Files" folder, etc.
action uses wow64 redirection false

// Create working directory
folder create "{parameter "Exportfolder"}"

// Enter multiple file copy and manifest creation
if {(character (length of it - 1) of it) of parameter "FilePath" = "\"}
    if {sum of sizes of files of folder (parameter "FilePath")|0/1024/1024 > parameter "maximumfilesizeMB" as integer}
        exit 413
    elseif {not exists x64 folder (parameter "FilePath")}
        exit 404
    endif

    folder delete "{parameter "Exportfolder" & "temp"}"
    waithidden cmd.exe /C xcopy /Y /I /E /H "{preceding texts of last "\" of parameter "FilePath"}" "{parameter "Exportfolder" & "temp"}"
    appendfile {("%22" & it & "%22%0d%0a") of (pathnames of files of folder (parameter "ExportFolder" & "temp"))}
    
// Enter single file copy and compression
else
    if {size of file (parameter "FilePath")|0/1024/1024 > parameter "maximumfilesizeMB" as integer}
        exit 413
    elseif {not exists file (parameter "FilePath")}
        exit 404
    endif

    folder delete "{parameter "Exportfolder" & "temp"}"
    folder create "{parameter "Exportfolder" & "temp"}"
// Echo f handles cases where the file does not have an extension (ex. the hosts file)
    waithidden cmd.exe /C echo f | xcopy /Y /I /H "{parameter "FilePath"}" "{parameter "Exportfolder" & "temp"}"
    appendfile {("%22" & it & "%22%0d%0a") of (pathnames of files of folder (parameter "ExportFolder" & "temp"))}

endif

delete "{parameter "Exportfolder" & "files.txt"}"
move __appendfile "{parameter "Exportfolder" & "files.txt"}"

// Compress listed files
waithidden cmd.exe /C makecab /d CabinetName1="{(computer name as lowercase & "_" & (((month of it as two digits & "-" & day_of_month of it as two digits & "-" & year of it as string) of date(local time zone) of it & "_" & (two digit hour of it as string & two digit minute of it as string) of time (local time zone) of it) of now) & "_fileupload.cab")}" /d MaxDiskSize=0 /D CompressionType=LZX /D DiskDirectoryTemplate="{preceding texts of last "\" of parameter "Exportfolder"}" /f "{parameter "Exportfolder" & "files.txt"}"

// Save existing ArchiveManager settings
parameter "prevOperatingMode" = "{if (exists setting whose (name of it = "_BESClient_ArchiveManager_OperatingMode" and exists value of it) of client) then value of setting "_BESClient_ArchiveManager_OperatingMode" of client else "0"}"
parameter "prevMaxArchiveSize" = "{if (exists setting whose (name of it = "_BESClient_ArchiveManager_MaxArchiveSize" and exists value of it) of client) then value of setting "_BESClient_ArchiveManager_MaxArchiveSize" of client else "52428800"}"

// Limit upload results to 100MB and start the upload asap.
setting "_BESClient_ArchiveManager_MaxArchiveSize"="109715200" on "{parameter "action issue date" of action}" for client
setting "_BESClient_ArchiveManager_OperatingMode"="2" on "{parameter "action issue date" of action}" for client
setting "_BESClient_ArchiveManager_FileSet-AVPFileUpload"="{parameter "Exportfolder"}{computer name as lowercase & "_" & (((month of it as two digits & "-" & day_of_month of it as two digits & "-" & year of it as string) of date(local time zone) of it & "_" & (two digit hour of it as string & two digit minute of it as string) of time (local time zone) of it) of now & "_fileupload.cab")}" on "{parameter "action issue date" of action}" for client

archive now

// Restore previous ArchiveManager settings
setting "_BESClient_ArchiveManager_OperatingMode"="{parameter "prevOperatingMode"}" on "{parameter "action issue date" of action}" for client
setting "_BESClient_ArchiveManager_MaxArchiveSize"="{parameter "prevMaxArchiveSize"}" on "{parameter "action issue date" of action}" for client

//cleanup after ourselves
folder delete "{parameter "Exportfolder" & "temp"}"
delete "{parameter "Exportfolder"}{computer name as lowercase & "_" & (((month of it as two digits & "-" & day_of_month of it as two digits & "-" & year of it as string) of date(local time zone) of it & "_" & (two digit hour of it as string & two digit minute of it as string) of time (local time zone) of it) of now & "_fileupload.cab")}"
Success Criteria

This action will be considered successful when the applicability relevance evaluates to false.


Sharing

Social Media:
Share this page on Yammer

Comments

Log In or Register to leave comments!