Purpose:
You wish to save or restore the command history used in the Inventory Toolbar > Tools > Run Command (or Ctrl+Alt+C). This is useful to ensure you have a copy of the command history in case of accidental deletion. This is also useful if you wish to copy the command history from one console to another or to create a custom Remote Command list and import that into PDQ Inventory.
Note: the command history is not machine dependent, meaning that the command history is all commands issued remotely regardless of which machine(s) the commands were run against. This makes running remote commands across multiple machines much easier than copy/paste or manual entry methods.
Resolution:
Warning | Precaucion | Auchtung | Mise en garde | Attenzione
Directly modifying the SQLite database should be performed only as needed. Modifying the SQLite database in an incorrect manner may result in unintended consequences up to and including irrecoverable data loss; a corrupt database requiring the complete uninstall and reinstall of the program; and existential dread associated with being alone in an uncaring, meaningless and indifferent universe. It is strongly recommended you stop the PDQ Inventory service and make a backup of the the .db* files located in %programdata%\Admin Arsenal\PDQ Inventory before accessing the SQLite console.
Save Remote Command History:
To save the Remote Command history to a .csv file, perform the following:
1. In PDQ Inventory, go to Options > Preferences > Database and click on the SQLite Console button. Note - To use the "SQLite Console" button you must be performing this action from the PDQ Console on the server that the database is located.
2. The SQLite console will open in a new window. You will want to type the following, hitting the enter key at the end of each line.
.mode csv
.output name_of_output_file.csv
select command from RemoteCommandHistory;
.output stdout
3. The CSV file is located in %programfiles(x86)%\Admin Arsenal\PDQ Inventory\
Restore Remote Command History:
If you should accidentally delete your command history or wish to import it to another console, or to restore (or append) the Remote Command history from a .csv file, perform the following:
1. In PDQ Inventory, go to Options > Preferences > Database and click on the SQLite Console button.
2. The SQLite console will open in a new window. You will want to type the following, hitting the enter key at the end of each line. Note: the CSV file from which you wish to restore from must be located in %programfiles(x86)%\Admin Arsenal\PDQ Inventory\
.mode csv
create table TempHistory (command);
.import name_of_file.csv TempHistory
insert into RemoteCommandHistory (Command) select command from TempHistory ;
drop table TempHistory;
NOTE: Should you decide to clear your history for whatever reason, you can do that within the Remote Command window:
Or through the SQLite console:
Special thanks to Shane and Chase for providing their SQL skills to this article.