GithubHelp home page GithubHelp logo

dchiavari / bkuser Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 3.54 MB

bkuser script - create a system environmental variable (last logged on user) in a list of computers, to be used in Veeam backup policy definition

Visual Basic 100.00%
veeam veeam-backup veeam-agent

bkuser's Introduction

"bkuser" script

Author: Danilo Chiavari (www.danilochiavari.com) Date: June 9th, 2019

This script was born to facilitate backup policy creations for workstations in Veeam Backup & Replication / Veeam Agent for Windows.

The script (bkuser.vbs) does the following:

  • Parses a list of computers (hostnames or IPs) from a CSV file (list.csv, newline-delimited), then for each of them:
    • Retrieves the last logged on user name from the Windows registry
    • Sets an environmental variable ("bkuser") in the system context, with the last logged on user name as value

After doing this, it is easy to leverage the bkuser environmental variable when creating a backup policy from within Veeam Backup & Replication (or standalone Veeam Agent as well).

For example: in order to back up only the 'Desktop' folders, C:\Users\%bkuser%\Desktop can be used.

In order to run the script, you need to have administrative privileges on the machine you are running the script from and on all target workstations.

USAGE: open an elevated Command Prompt (Run as Administrator) and run the script directly: C:\scripts\bkuser\bkuser.vbs

Running the script using cscript is recommended, as all "logging" (wscript.echo) output would be written to console (command prompt window) rather than pop-up boxes.

EXAMPLE: cscript C:\scripts\bkuser\bkuser.vbs


script execution from the backup server Script execution from the backup server

policy definition using the variable Policy definition using the variable

file-level recovery from a backup File-level recovery from a backup


NOTE: Of course, this is very crude and very far from perfect.

Limitations:

  • Multi-user machines cannot be properly protected this way. Best approach would be just using a policy where "Personal files" (that is, "C:\Users") checkbox is ticked
  • There might be corner cases where the user who last logged on is not the "main" user (e.g. a technician). In this case you should manually re-run the script or manually adjust the variable accordingly
  • Error handling is more or less non-existent

Possible future improvements:

  • Implement an option to parse not only machine names/IPs, but also user names from a CSV. This way you can be sure the variable will always be set to the correct user name

bkuser's People

Contributors

dchiavari avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.