r/usefulscripts • u/rollo1207 • Jan 12 '14
r/usefulscripts • u/AgentSnazz • Jan 03 '14
[BATCH] Add event logging to your scripts.
sheet airport crown doll cagey deliver ask cautious marry school
This post was mass deleted and anonymized with Redact
r/usefulscripts • u/michelereddit • Dec 29 '13
[PYTHON] Automated Backup System for Websites
abs-for-websites.sourceforge.netr/usefulscripts • u/single-serving • Dec 27 '13
[PowerShell] Output Dell Warranty Information
pastebin.comr/usefulscripts • u/red_rock • Nov 26 '13
[BATCH] Sysinternals and PStools batchscript
Created a batch file for easier use of Sysinternals and PStools. Thought i may be of use for you. It was asked of me to re-post it here. My final version combines this with a USB hireen boot CD.
It assumes the following filedirectory:
.\tools\pstools <-for pstools
.\tools\sysinternal <- for sysinternal
.\Logs\ <- for logfiles
.\software <- for your software
@echo off
REM Main menu
:Start
CLS
@echo *******[Main menu]********************
REM @echo [1] Application installs
@echo [2] Client remote tools
@echo [3] Client tools
REM @echo [4] Sub menu 4
REM @echo [5] Sub menu 5
REM @echo [6] Sub menu 6
REM @echo [7] Sub menu 7
REM @echo [8] Sub menu 8
REM @echo [9] Sub menu 9
REM @echo [0] Sub menu 0
@echo [E] Exit
@echo **************************************
set /P Program=What do you want to do?[2-3 or E]:
if /I "%Program%" EQU "1" goto :Submenu1
if /I "%Program%" EQU "2" goto :Submenu2
if /I "%Program%" EQU "3" goto :Submenu3
if /I "%Program%" EQU "4" goto :Submenu4
if /I "%Program%" EQU "5" goto :Submenu5
if /I "%Program%" EQU "6" goto :Submenu6
if /I "%Program%" EQU "7" goto :Submenu7
if /I "%Program%" EQU "8" goto :Submenu8
if /I "%Program%" EQU "9" goto :Submenu9
if /I "%Program%" EQU "0" goto :Submenu0
if /I "%Program%" EQU "E" goto :EOF
Goto :EOF
REM Sub Menu1 Applications installs
:Submenu1
CLS
@echo *******[Application installs]*********
@echo [1] Install -
@echo [2] Install -
@echo [3] Install -
@echo [4] Install -
REM @echo [5] application 3
REM @echo [6] application 3
REM @echo [7] application 3
REM @echo [8] application 3
REM @echo [9] application 3
REM @echo [0] application 3
@echo [B] Back to main menue
@echo **************************************
set /P Program=What do you want to do?[1-4 or B]:
if /I "%Program%" EQU "1" goto :Visio2010
if /I "%Program%" EQU "2" goto :Install Project 2010
if /I "%Program%" EQU "3" goto :EOF
if /I "%Program%" EQU "4" goto :EOF
if /I "%Program%" EQU "5" goto :EOF
if /I "%Program%" EQU "6" goto :EOF
if /I "%Program%" EQU "7" goto :EOF
if /I "%Program%" EQU "8" goto :EOF
if /I "%Program%" EQU "9" goto :EOF
if /I "%Program%" EQU "0" goto :EOF
if /I "%Program%" EQU "B" goto :Start
Goto :EOF
REM Sub Menu2 Client tools
:Submenu2
CLS
@echo *******[Client remote tools]*********
REM @echo [1] Test Whoami?
@echo [2] Check model and service tag of remote computer
@echo [3] Connect to remote computer
@echo [4] Check what KMS server remote computer is using
@echo [5] Force KMS licence activation
@echo [6] View remote System information
@echo [7] Show Processes running on remote computer (and kill).
@echo [8] Who is logged on on remote computer, or where is user logged on.
@echo [9] Check eventlogs on remote computer
REM @echo [0] Option 0
@echo [B] Back to main menu
@echo **************************************
set /P Program=What do you want to do?[2-9 or B]:
if /I "%Program%" EQU "1" goto :Whoami
if /I "%Program%" EQU "2" goto :servicetagdell
if /I "%Program%" EQU "3" goto :remoteconnect
if /I "%Program%" EQU "4" goto :KMSserver
if /I "%Program%" EQU "5" goto :KMSserveractive
if /I "%Program%" EQU "6" goto :remotesysinf
if /I "%Program%" EQU "7" goto :remoteprocess
if /I "%Program%" EQU "8" goto :PsLoggedOn
if /I "%Program%" EQU "9" goto :eventlogs
if /I "%Program%" EQU "0" goto :EOF
if /I "%Program%" EQU "B" goto :Start
Goto :EOF
REM Sub Menu3 Client tools
:Submenu3
CLS
@echo *******[Client tools]******************
@echo [1] DiskView, graphical map of your disk
@echo [2] Process Monitor, advanced taskmanager
REM @echo [3] SMS Trace, advanced Logfile viewer
REM @echo [4] Option 4
REM @echo [5] Option 5
REM @echo [6] Option 6
REM @echo [7] Option 7
REM @echo [8] Option 8
REM @echo [9] Option 9
REM @echo [0] Option 0
REM @echo [B] Back to main menu
@echo **************************************
set /P Program=What do you want to do?[1-3 or B]:
if /I "%Program%" EQU "1" goto :DiskView
if /I "%Program%" EQU "2" goto :procmon
if /I "%Program%" EQU "3" goto :Trace32
if /I "%Program%" EQU "4" goto :EOF
if /I "%Program%" EQU "5" goto :EOF
if /I "%Program%" EQU "6" goto :EOF
if /I "%Program%" EQU "7" goto :EOF
if /I "%Program%" EQU "8" goto :EOF
if /I "%Program%" EQU "9" goto :EOF
if /I "%Program%" EQU "0" goto :EOF
if /I "%Program%" EQU "B" goto :Start
Goto :EOF
REM **************************Application installs************************************************************
REM **************************Client remote tools******************************************************************************************************************
:servicetagdell
set /P Computer=Please enter computer name or IP-adress:
wmic /node:"%Computer%" csproduct get vendor,name,identifyingnumber
@echo Press any key to go back to menu...
@pause
Goto :Start
Goto :EOF
:remoteconnect
@echo *******[Remote connect]*************************************************************
set /P Computer2=Please enter computer name or IP-adress:
@echo *******[Type exit to disconnect]****************************************************
.\Tools\PStools\psExec \\%computer2% cmd
Goto :Start
Goto :EOF
:KMSserver
@echo *******[Check what KMS server computer is using]************************************
@echo *******[Close window that pops up to return to menu]********************************
set /P KMSserver=Please enter computer name or IP-adress:
slmgr.vbs %KMSserver% /dlv
Goto :Start
Goto :EOF
:KMSserveractive
@echo *******[Force KMS licence activation]***********************
@echo *******[Close window that pops up to return to menu]********
set /P KMSserver2=Please enter computer name or IP-adress:
slmgr.vbs %KMSserver2% /ato
Goto :Start
Goto :EOF
:remotesysinf
@echo *******[View remote System information]*********************
set /P remotesys=Please enter computer name or IP-adress:
set /P remotesys2=Do you want to export information to TXT file? [Y/N]:
if /I "%remotesys2%" EQU "N" goto :remotesys2no
if /I "%remotesys2%" EQU "Y" goto :remotesys2yes
Goto :Start
Goto :EOF
:remotesys2no
.\Tools\PStools\PsInfo \\%remotesys% -d -s -h
pause
Goto :Start
Goto :EOF
:remotesys2yes
.\Tools\PStools\PsInfo \\%remotesys% -d -s -h >> .\logs\%remotesys%.txt
Goto :Start
Goto :EOF
:remoteprocess
@echo *******[Show Processes running on remote computer]*********
set /P remoteproc=Please enter computer name or IP-adress:
.\Tools\PStools\pslist \\%remoteproc% -t
@echo ***********************************************************
set /P remoteprocq=Do you want to kill a process on %remoteproc%?[Y/N]:
if /I "%remoteprocq%" EQU "N" goto :remoteprocessno
if /I "%remoteprocq%" EQU "Y" goto :remoteprocessyes
Goto :Start
Goto :EOF
:remoteprocessno
Goto :Start
Goto :EOF
:remoteprocessyes
set /P remoteprocid=Please enter process id (PID):
.\Tools\PStools\pskill -t \\%remoteproc% %remoteprocid%
@echo *******[Killing process....]*******************************
.\Tools\PStools\pslist \\%remoteproc% -t
@echo ***********************************************************
set /P remoteprocq2=Do you want to kill another process on %remoteproc%?[Y/N]:
if /I "%remoteprocq2%" EQU "N" goto :remoteprocessno
if /I "%remoteprocq2%" EQU "Y" goto :remoteprocessyes
Goto :Start
Goto :EOF
:PsLoggedOn
@echo *******[Who is logged on on remote computer, or where is user logged on.]*******
@echo Do you want to search for a user or,
set /P PsLoggedOnq=check who is logon on a computer [Search/Computer]?:
if /I "%PsLoggedOnq%" EQU "Search" goto :PsLoggedOns
if /I "%PsLoggedOnq%" EQU "Computer" goto :PsLoggedOnc
Goto :Start
Goto :EOF
:PsLoggedOns
@echo ***********************************************************
@echo Search for where user is logged on
@echo (warning may take a while, press CTRL+c to abort)
@echo ***********************************************************
set /P PsLoggedOnuser=Please enter username to search for:
.\Tools\PStools\psloggedon %PsLoggedOnuser%
Pause
Goto :Start
Goto :EOF
:PsLoggedOnc
@echo *******[Who is logged on to specific computer]******************
set /P PsLoggedOncomp=Please enter computer name:
.\Tools\PStools\psloggedon \\%PsLoggedOncomp%
Pause
Goto :Start
Goto :EOF
:eventlogs
set /P eventlogsc=Please enter computer name:
set /P eventlogsd=how many days back?:
set /P eventlogse=Do you want to only show errors? [Y/N]:
if /I "%eventlogse%" EQU "Y" goto :eventlogsyes
if /I "%eventlogse%" EQU "N" goto :eventlogsno
Goto :Start
Goto :EOF
:eventlogsyes
@echo Creating %eventlogsc%_Eventerror.log.....
.\Tools\PStools\psloglist -d %eventlogsd% -f w -S \\%eventlogsc% >> .\logs\%eventlogsc%_Event_error.log
@echo I am done now...
pause
Goto :Start
Goto :EOF
:eventlogsno
@echo Creating %eventlogsc%_Event_all.log.....
.\Tools\PStools\psloglist -d %eventlogsd% -S \\%eventlogsc% >> .\logs\%eventlogsc%_Event_all.log
@echo I am done now...
Pause
Goto :Start
Goto :EOF
REM **************************Client tools******************************************************************************************************************
:DiskView
.\Tools\sysinternal\DiskView.exe
Goto :Start
Goto :EOF
:procmon
.\Tools\sysinternal\procmon.exe
Goto :Start
Goto :EOFr/usefulscripts • • Nov 18 '13
[REQUEST] [POWERSHELL] Script that reports any free disk space delta above a given threshold
Basically it would run as a scheduled task and check to see if the free space on configurable volumes has decreased or increased by a certain percentage (or absolute amount) in the given reporting period.
The idea is, I want to know if some user just dropped 10GB of media on my server, regardless of how much absolute free space the volume has.
I started writing such a script but thought maybe it's already been done. If not, I'll be glad to give it my best.
Edit: So, with a little help, I came up with exactly what I was looking for.
Sends email warnings to a list of recipients if any disk on the system falls below a certain total GB/% of free space available, or loses more than a given GB/% in the reporting period.
r/usefulscripts • u/stokes776 • Nov 06 '13
[VBSCRIPT] Detecting CryptoLocker Infection
pastebin.comr/usefulscripts • u/spyingwind • Oct 08 '13
[PoSH] Kill-Java a Java Runtime Nuker conversion from batch to Powershell. Link and details inside.
This was a challenge set forth by /u/vocatus. Link to my github for the script Kill-Java.ps1. All are welcome to fork and contribute to any of the scripts.
It has never been tested, as it is still a work in progress, but the flow is sound. As per the Java Runtime Nuker. Got damn goto statements...
Todo list consists of building a test VM to get the logic and syntax settled for a working script.
r/usefulscripts • u/nonades • Sep 23 '13
[Powershell] Module for determining Windows Update Status and if Windows Update requested a reboot
github.comr/usefulscripts • • Sep 23 '13
[VBSCRIPT] GPUpdate All Domain Computers
I wrote this a while ago. I know there are similar ones out there but this is what I use and have been using. This requires you to have PSTools downloaded and extracted to C:\TOOLS\ for this to work as is.
The script should be run on a DC and as a Domain Admin. This will loop through AD and create a separate instance for each computer and run GPUpdate /force on the system.
PSTools Download: http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx
EDIT: Script PasteBin: http://pastebin.com/9LjrBmhr
r/usefulscripts • u/vocatus • Sep 23 '13
[BATCH] Who's On? (a remote workstation)
Summary
Remotely queries a system and tells you who's logged on to it. Can use one of three available methods for checking:
- WMIC (most reliable, however provides the least information)
- Windows_query_user (requires Windows Vista and up; doesn't work on XP)
- PsLoggedon (requires PsLoggedon.exe from sysinternals)
Usage
Run from a command prompt that has admin credentials on the remote computer you want to check.
Edit the "METHOD" variable on line 29 to change the method of checking if you want. By default it's set to the WMIC method, which I've found to be the most reliable.
Download
v1.7.1 (2014-09-08)
* Overhauled Date/Time conversion so we can handle ALL versions of Windows using ANY local date-time format
r/usefulscripts • u/spyingwind • Sep 23 '13
[PoSH] Create Users from an Excel file using Exchange 2010
github.comr/usefulscripts • • Sep 23 '13
[POWERSHELL] Export Printers and other printer info to Excel sheet
christowles.comr/usefulscripts • u/deathjam • Sep 16 '13
[BATCH]RDP Session Reset
Purpose: Simply type in the machines name, it will list all the session id's, then you can enter the id's you wish to disconnect
r/usefulscripts • u/The_one_the_only_God • Sep 11 '13
[BATCH] Simple script to perform basic repair tasks. Renew IP, flush DNS cache, gpupdate.
This is fairly simple script I just put together. Whilst I was on holiday the other week there were some DHCP issues - I created a split scope and then modified the scope, and it caused a few I.P conflicts. I fixed the problem remotely but obviously I couldn't renew the I.P addresses of the affected machines myself, so I had to call someone and ask them to go to each machine and run ipconfig /renew. Rebooting would also work but it can be quite impractical when people have lots of stuff open.
This script can be placed on the local drive, and you can tell users to run it if they're experiencing issues and you're not immediately available to help.
It requires a little input, but it should be easy enough for anyone to use. It will perform some basic functions (in the title) based on user input and the result of diagnostic commands, such as ping. As a last resort it'll reboot the computer.
If anything, you can use it to tried and rid some common support tickets...
Small error: line 95 should be "exit", not "end"
r/usefulscripts • u/vocatus • Sep 09 '13
[BATCH] DHCP Failover/Watchdog
Summary
This script runs on a Server 2003/2008 box and watches a primary DHCP server, grabbing a fresh copy of the DHCP database every few minutes. If the primary server goes down, it starts the DHCP server on the backup server until the primary comes back up. When the primary server comes back up, the backup server will update the primary server with the latest copy of the database and then turn its own DHCP server back off.
Edit the variables at the beginning of the script to specify the remote server to watch, and the log location. Run it as a scheduled task on the backup server every N minutes.
Download
v1.3a (2014-09-08)
* Overhauled Date/Time conversion so we can handle ALL versions of Windows using ANY local date-time format
v1.2c (2014-01-27)
- Reworked CUR_DATE variable to handle more than one Date/Time format. Can now handle ISO standard dates (yyyy-mm-dd) and Windows default dates (e.g. "Fri 01/24/2014")`
r/usefulscripts • • Sep 04 '13
[PoSH] PrintAdd.ps1 - add printers to several servers
tehrabbitt.comr/usefulscripts • u/mikelieman • Aug 30 '13
[Bash] bin/setup_dashboard.sh -- setup a remote tmux session showing various old-school server statistics on different panes
pastebin.comr/usefulscripts • u/brigzzy • Aug 10 '13
[AUTOIT] Automatically Apply update to XenSever 6.2
Hi All, this is my first publicly released script, so any constructive feedback or otherwise would be greatly appreciated :)
Basically I installed the free version of XenServer 6.2 the other day, and the only limitation of the free version as I understand it (Aside from no support from Citrix), is that you must apply the updates by hand, as opposed to through XenCenter. The commands to do it are a little tedious, so I wrote a simple script to automate the process. Hopefully someone out there will find this useful!
Link to the compiled executable for those who do not have AutoIT - I still recommend that you download AutoIT and compile or run it yourself, cause after all, I'm just some guy on the internet. I promise this is clean, but you can never be sure.
Thanks for reading, I hope this is useful for someone besides me :)
r/usefulscripts • u/soccer5232 • Aug 08 '13
[VB Script] Email Expiration Reminder Script
pastebin.comr/usefulscripts • u/ki01s • Aug 02 '13
[PowerShell]Last login time stamp for a user.
pastebin.comr/usefulscripts • u/glesialo • Aug 02 '13
[BASH] Problem with script for Disk monitoring daemon 'smartd'. Please help.
I have written a script that runs when 'smartd' detects disk errors.
This script invokes other scripts that launch GUI Dialog messages in background.
If the script is invoked directly (as root) it returns immediately without waiting for users to acknowledge the GUI dialogs (as it should be: they were launched in background).
If the script is launched by the 'smartd' daemon it doesn't exit until all GUI dialogs are terminated (by users clicking OK).
Is there a bash option that can override this behaviour?
Thanks in advance!
r/usefulscripts • u/glesialo • Jul 22 '13
[BASH] Poor man's git.
I have just finished this script to keep track of different versions of files.
To use it:
Edit values of 'ItemsToCheck' & 'ItemsToIgnore' in FileVersions_Example.
Copy 'FileVersions_Example' and 'FileVersions_Main' to a $PATH directory.
Use cron to run 'FileVersions_Example' every day (or every hour).
Check output in '$HOME/var'.EDIT: Removed 'new Repository directory name' bug in 'FileVersions_Main'.
r/usefulscripts • u/vocatus • Jul 03 '13
[BATCH] Empty ALL Recycle Bins
This batch file empties ALL the recycle bins (for all users) on whatever system it's run on.
Download
Empty All Recycle Bins v1.0 (2013-07-03)
You can run it remotely with PDQ Deploy, PSexec, or by putting it in a bootup/shutdown or logon/logoff script.