r/usefulscripts • • Oct 21 '16

[REQUEST] Batch script to apply recent registry changes.

15 Upvotes

As it stands now, I have a batch file that runs every time a user logs on to edit their registry to change HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer so that their notifications bar is always shown.

The issue with this is that it does not apply immediately and requires that user to log out and then back in to apply. Is there a way in this batch file to apply this change immediately after running, or is it something my users are forced to deal with the first time they log in to a new machine?


r/usefulscripts • • Oct 21 '16

[REQUEST] Script to export DHCP scope pool ranges to a readable file.

15 Upvotes

I'm trying to export a list of the DHCP scope pool ranges on our 3 DHCP servers.

We have an application that I need to add the IP scopes into so it can scan certain IP ranges.

 

I've been searching for a way to script/automate this all morning but nothing is quite working. I was able to dump the contents of each server to a text file using netsh but that's not exactly what I need. I'd rather not go through the DHCP scopes one-by-one and copy down the IP ranges...

 

For what it's worth, I'm dealing with two different server OS's too.

  • 2x Windows Server SE 2003 SP2

  • 1x Windows Server Standard 2012 R2

 

Any ideas of what I could use?


r/usefulscripts • • Jun 20 '16

[Powershell] Setup services for a VDI environment

15 Upvotes

So we needed a script to set multiple services for VDI. I wanted something that I could scale for extension and safety. The script was generated from this Microsoft PDF https://download.microsoft.com/download/6/0/1/601D7797-A063-4FA7-A2E5-74519B57C2B4/Windows_8_VDI_Image_Client_Tuning_Guide.pdf titled Windows 8 Virtual Desktop Infrastructure image client tuning guide. The script is here http://pastebin.com/Kjss9e6K


r/usefulscripts • • Jan 14 '16

[PowerShell] Connect-ExchangeOnline

15 Upvotes

I'm sure many of us have written something similar, but I didn't see any posted when I searched. This is a short cmdlet to simplify connecting to Exchange Online for those of us on O365. It also includes a check parameter so you can quickly add a one liner to any other script working with Exchange cmdlets to see if the current session is already connected or not and offer to connect in case you've forgotten (I know I have).

http://pastebin.com/qthm29RG


r/usefulscripts • • Jan 14 '16

[CSV File] FCC Telemarketer and RoboCall Blacklist for Google Contacts 01/11/2016

Thumbnail
pastebin.com
15 Upvotes

r/usefulscripts • • Nov 21 '15

[BASH] Mac OS X Development Environment Setup

Thumbnail
gist.github.com
15 Upvotes

r/usefulscripts • • Oct 01 '15

[Powershell] Checking the existence of a folder or file on all domain machines

Thumbnail cablespaghetti.github.io
15 Upvotes

r/usefulscripts • • Sep 22 '15

[POWERSHELL]All User Temp File Cleanup With Email Report

15 Upvotes

How this script works.

This script searches through the C:\Users Directory for all of the sub directories then creates a list of all of the users on the computer. It will then Delete all of the files from the temp file locations within the users directories. It also will delete temps from Windows and C:\Temp. The script checks disk usage before and after the script is run, and will then email a report.

http://pastebin.com/mh3sdwsw


r/usefulscripts • • Feb 05 '15

[POWERSHELL] Get-MailboxReport.ps1 – PowerShell Script to Generate Mailbox Reports

Thumbnail
exchangeserverpro.com
15 Upvotes

r/usefulscripts • • Jan 31 '15

[BASH] Downloaders for pururin and fakku

15 Upvotes

i have written two version of each script, one that generates a list of URL in a text file, and, a more useful/automated one, creates a folder, makes a list then automatically downloads all the images and text file to the folder. (using curl instead of wget to read the list, as some *nix machines use curl instead of wget)

Fakku

Simple

To operate, after hitting enter, paste in part of the URL, like so

doujinshi/china-comi-english

or

manga/explicit-girlfriend-english

 #!/bin/bash
 read Media
 FILE=`echo ${Media} | sed 's/.*\///g'`
 curl -# "https://www.fakku.net/${Media}/read" | grep 'window.params.thumbs ='| tr '"' '\n' | grep fakku | sed 's/\\//g' | sed 's/^/https:/g'  | sed 's/thumbs/images/g' | sed 's/\.thumb//g' >> "${FILE}.txt"

Fakku

Automated (operated the same way)

   #!/bin/bash
   read Media
   FILE=`echo ${Media} | sed 's/.*\///g'`
   mkdir "${FILE}"
   cd "${FILE}"
   curl -# "https://www.fakku.net/${Media}/read" | grep 'window.params.thumbs ='| tr '"' '\n' | grep fakku | sed 's/\\//g' | sed 's/^/https:/g'  | sed 's/thumbs/images/g' | sed 's/\.thumb//g' >> "${FILE}.txt"
   linkNum=`cat ${FILE}.txt | wc -l`
   linkNum=$(( $linkNum + 1 ))
   n=1
   while [ $n != $linkNum ]
   do sed -n "$n{p;q;}" ${FILE}.txt | xargs curl --retry 8 -g -# -O; n=$(( $n + 1 ))
   done
   cd ..

Pururin

Simple

To operate, after hitting enter, paste in part of the URL, like so

16905/moshi-rito-darkness.html

or

6159/unlove-s.html

#!/bin/bash
read URL
SITE="http://pururin.com"
File=`echo ${URL} | sed 's/.*.\///g' | sed 's/\..*//g'`
curl -# "${SITE}/thumbs/${URL}" | grep '<li class="I0"' | tr '" ' '\n' | grep ^/view/ | awk -v Z=$SITE '{print 'Z' $0}' | tr '\n' ' ' | xargs curl -#  | grep '<img class="b" src="' | tr '"' '\n' | grep '/f/' | awk -v Z=$SITE '{print 'Z' $0}' >> "${File}.txt";

Pururin

Automated (operated the same way)

#!/bin/bash
read URL
SITE="http://pururin.com"
File=`echo ${URL} | sed 's/.*.\///g' | sed 's/\..*//g'`
mkdir "${File}"
cd "${File}"
curl -# "${SITE}/thumbs/${URL}" | grep '<li class="I0"' | tr '" ' '\n' | grep ^/view/ | awk -v Z=$SITE '{print 'Z' $0}' | tr '\n' ' ' | xargs curl -#  | grep '<img class="b" src="' | tr '"' '\n' | grep '/f/' | awk -v Z=$SITE '{print 'Z' $0}' >>"${File}.txt"
linkNum=`cat ${File}.txt | wc -l`
linkNum=$(( $linkNum + 1 ))
n=1
while [ $n != $linkNum ]
do sed -n "$n{p;q;}" ${File}.txt | xargs curl --retry 8 -g -# -O; n=$(( $n + 1 ))
done
cd ..

http://pastebin.com/Ertmp7uZ


r/usefulscripts • • Oct 08 '13

[PoSH] Kill-Java a Java Runtime Nuker conversion from batch to Powershell. Link and details inside.

15 Upvotes

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 • • Sep 16 '13

[BATCH]RDP Session Reset

15 Upvotes

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

http://pastebin.com/PnfC8sHh


r/usefulscripts • • Sep 11 '13

[BATCH] Simple script to perform basic repair tasks. Renew IP, flush DNS cache, gpupdate.

15 Upvotes

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...

http://pastebin.com/5KiMGAzW

Small error: line 95 should be "exit", not "end"


r/usefulscripts • • Nov 19 '12

[DOS BATCH] Open a new daily notes text file, date it. w/ Backup & Search.

15 Upvotes

This one is a very simple but useful script for me. I'm sharing it because it's DOS BATCH and not everyone is very batch file savvy (took me a bunch of Googling and tries).

Background: I take daily notes, and I want to keep them archived so they are on a cloud storage service (dropbox/Gdrive). I also need to occasionally dig through these files quickly for a certain fact or detail.

Here's the script DailyNotes.bat:

@echo off
Set mm=%DATE:~4,2%
Set dd=%DATE:~7,2%
Set yyyy=%DATE:~10,4%
if not exist %yyyy%-%mm%-%dd%.txt copy /b _sample %yyyy%-%mm%-%dd%.txt
start %yyyy%-%mm%-%dd%.txt
exit

Basically it sets the month, date, year in the syntax I'm looking for, then it creates a new file with the date as a name like today: 2012-11-19.txt, it creates it based off an empty file called "_sample", sometimes I change the contents of this to a template, if for example I have some important information to stay persistent across a week or something. Finally it opens the file by invoking the filename itself.

The nice thing is, if it does exist, as in I created it already that day, it will skip coping over the file and open the existing one directly.

Pretty basic but very useful for me. I then made a shortcut and set the attribute on the shortcut to minimize the command prompt that executes this. If there is a cleaner way to suppress the command prompt after the text editor is running that'd be wonderful. I haven't figured that out yet (help?). Props to user: hngovr for solving this in the comments!

As for indexing and search, I use AgentRansack: http://www.mythicsoft.com/page.aspx?page=download&type=agentransack

Hope you enjoy the basic script. I have some cooler ones to share but this is most recent!

Conversation: Does anyone handle this differently or better in their opinion, I'm always looking for good ideas!

Edit: Mods: Sorry about the prefix not matching the defined ones, there's nothing for [BATCH]...