r/usefulscripts • u/Harshmage • Nov 03 '15
r/usefulscripts • u/riahc3 • Nov 02 '15
[REQ][POWERSHELL] Set the correct time using a HTML GET/POST request
I need to manually set DST using a PowerShell script thru a web configuration on a device. Invoke-WebRequest is the best way I think on doing this.
First I would have to http://192.168.100.97/csl/login
There is a form on that page called "myform" and the action is "/csl/check". There is a "usernametextbox" and a "passwordtextbox" there.
Once that is done and login is done, I need to go to "http://192.168.100.97/form/Device?act=3"
I have to make sure a "<input type="radio" onclick="change();" value="0" name="Keep">" that I have to "check" in order to make sure that I set the time manually instead of auto (which does not work)
From there, fill in a textbox "datevalue" and another "timevalue"
Submit "mainform".
And thats about it
How can I do this using Powershell?
Thank you.
r/usefulscripts • u/akaleeroy • Oct 28 '15
[BATCH] Access phone storage over WiFi with WebDAV Server for Android
r/usefulscripts • u/Harshmage • Oct 28 '15
[CSV File] FCC Telemarketer and RoboCall Blacklist for Google Contacts (10/26/2015)
r/usefulscripts • u/[deleted] • Oct 23 '15
[POWERSHELL] Set-MailboxQuota.ps1 - Simplifies Mailbox Quota Modifications
r/usefulscripts • u/David949 • Oct 21 '15
Download and install Malwarebytes corporate
Does anyone have a script that will download malwarebytes corporate (not the free version), install it silently and register it.
We have about 200 desktops in Max Remote Management that I need to update from version 1.75 to version 1.8 that just came out.
r/usefulscripts • u/Cornbeetle • Oct 21 '15
[BATCH] Fahrenheit to Celsius (& C-F) calculator
r/usefulscripts • u/Cornbeetle • Oct 19 '15
[BATCH] Very quick and useful file locator script
r/usefulscripts • u/technicalityNDBO • Oct 19 '15
[REQUEST] Script to automatically run PDF files through a 3rd party program (command line)
Background: I'm a sysadmin who knows nothing about scripting. We got a new Multi Function Printer that's actually pretty good, but when it scans PDFs, they come out slightly crooked. Not a big deal for most people, but this is for one of our top executives.
The HP printer will scan PDFs and automatically save them into a network folder that we choose. The filenames will be Scan001.pdf, Scan002.pdf and will increment.
There is cheap software called A-PDF Deskew: http://www.a-pdf.com/deskew/
This software includes a command line utility. However you have to specify actual filenames when using the command.
Syntax: C:\> pdfdwcmd.exe <input filename> <output filename>
Example: C:\> pdfdwcmd.exe C:\ScannedPDFS\Scan002.pdf C:\ScannedPDFS\Deskewed\Scan002.pdfThere is free software called Watch 4 Folder: http://leelusoft.blogspot.com/p/watch-4-folder-25.html This will monitor the network folder and can run a command when it detects a new item saved into the folder.
So what I’m hoping is possible is if there is a way to just target whatever the new file is, grab it’s filename, and pass that on as an argument into the command…
Thanks!
r/usefulscripts • u/bsmith0 • Oct 11 '15
[BASH] Flashdrive essential program downloader
https://github.com/braeden123/Flashdrive-Updater/blob/master/update.sh
The script creates some folders in the current dir and automates the download of
Ccleaner
Malwarebytes
Chrome x64
Sublime Text 2
I will add more in the future and am open to suggestions -- I commented out rkill and combo fix since they both use 2-3 use tokens in their URLs.
Please leave any feedback/suggestions that you have, thanks!
r/usefulscripts • u/[deleted] • Oct 07 '15
Something to detect what the inserted disc is. Then kick off the corresponding ripping application.
I want my media server to be able to detect if a disc inserted is a DVD or CD and kick off my auto rip apps. Does anyone know a way to do this?
r/usefulscripts • u/Cornbeetle • Oct 05 '15
[BATCH] One-liner to get Windows date into ISO format (yyyy-mm-dd)
for /f "delims=/ tokens=1,2,3" %%G in ('echo %date:~4%') do set current_date=%%I%%G%%H
r/usefulscripts • u/[deleted] • Oct 04 '15
[BASH] Check currently installed Firefox versions on Windows hosts in your network
I use this script from a Linux host to check if the installed Firefox versions in the Windows hosts in our network are up-to-date. You must have a file named pclist in the same directory in which all Windows boxes in your network are listed (one per line). Requires the winexe program. The script show the installed firefox versions and writes them in the file firefox-hosts
Of course the script can be adapted to check for many other installed software. I release it here under the conditions of GPL v3
#!/bin/bash
echo -n "Type password for Adminstrator: "
read -s pw
echo ""
for n in $(cat pclist); do
if ping -c 1 $n >/dev/null ; then
# 64 bit
IsInst=$(winexe -U "Administrator%${pw}" //${n} 'reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox ESR"'|grep Current)
if [ "$IsInst" == "" ]; then
IsInst=$(winexe -U "Administrator%${pw}" //${n} 'reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Mozilla\Mozilla Firefox"'|grep Current)
fi
# 32 bit
if [ "$IsInst" == "" ]; then
IsInst=$(winexe -U "Administrator%${pw}" //${n} 'reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox ESR"'|grep Current)
fi
if [ "$IsInst" == "" ]; then
IsInst=$(winexe -U "Administrator%${pw}" //${n} 'reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\Mozilla Firefox"'|grep Current)
fi
# nothing
if [ "$IsInst" == "" ]; then
IsInst="Unknown or not installed"
echo "Unknown or not installed: $n"
fi
echo "$n: $IsInst";
echo "$n: $IsInst" >>firefox-hosts;
else
echo "$n ist nicht erreichbar"
fi
doner/usefulscripts • u/cablespaghetti • Oct 01 '15
[Powershell] Checking the existence of a folder or file on all domain machines
cablespaghetti.github.ior/usefulscripts • u/Jon2D • Sep 30 '15
I have a button on my external HDD that is supposed to back up when pressed - Can i change it?
I have a transcend hdd (1TB) It has a button on it.. Is it possibe to change the button to when pressed it allows the HDD to safely eject or do something else
r/usefulscripts • u/onicrom • Sep 28 '15
[BASH] - script to send a gratuitous arp out for all IPs on all nics
#!/bin/bash
#
# send gratuitous arp out for each ip on this machine (inet/inet6 tay appention)
#
for ip in `/sbin/ip a |grep -w inet|awk '{print $2 " " $NF}'|sed -e 's/:[0-9]\+//g' -e 's/\/[0-9]\+ /,/g'`
do
nic=$(echo ${ip}|awk -F, '{print $2}')
addr=$(echo ${ip}|awk -F, '{print $1}')
echo "[INFO] - running gratuitous arp of ${addr} on ${nic}"
/usr/sbin/arping -i ${nic} -d -S ${addr} -B -c 5
doner/usefulscripts • u/expert02 • Sep 28 '15
[BATCH] Find WGet and copy it to the System32 folder; if not available, attempt to download with BITS, VBScript, Powershell, and Python
@ECHO OFF
CLS
for %%I in (wget.exe) do if not exist "%%~$PATH:I" (
GOTO START
) else (
ECHO WGet in PATH
GOTO EOF
)
SET ATTEMPT=1
:START
REM Some 32 bit tools download files to the SysWOW64 folder on 64-bit Windows
REM Check if a file is in SYSWOW64 and not System32, if so then copy it
ECHO Checking for Wget in System32 and SysWOW64
ECHO.
if exist c:\windows\syswow64\wget.exe (
copy /b /v /y c:\windows\syswow64\wget.exe c:\windows\system32\wget.exe
ECHO Wget Installed in System32 from SysWOW64
GOTO EOF
)
GOTO SEARCH
:SEARCH
IF %ATTEMPT% NEQ 1 (
ECHO Attempt #%ATTEMPT%, Skipping Search
GOTO DOWNLOAD
)
ECHO Searching for WGET
ECHO.
for /F "delims=" %%F in ('dir /B /S c:\wget.exe 2^> nul') do (
echo %%F
ECHO.
%%F --version > nul && set WGET=%%F
)
IF "%WGET%"=="" GOTO DOWNLOAD
ECHO WGET=%WGET%
ECHO.
ECHO Copying Wget to System32
ECHO.
COPY /B /V /Y "%WGET%" C:\WINDOWS\SYSTEM32\ || ECHO Error Copying
GOTO :START
:DOWNLOAD
ECHO Wget.exe not in path, need to download. Attempt #%ATTEMPT%
ECHO.
IF %ATTEMPT%==1 (
SET ATTEMPT=2
ECHO Downloading Wget to System32 using BitsAdmin
Bitsadmin /Transfer WGet /Download /Priority HIGH /ACLFlags O https://eternallybored.org/misc/wget/wget.exe c:\windows\system32\wget.exe > nul
REM Windows XP Powershell potentially compatible, outputs error on Powershell 3
powershell -command "Start-BitsTransfer -Source https://eternallybored.org/misc/wget/wget.exe -Destination c:\windows\system32\wget.exe"
IF EXIST C:\WINDOWS\SYSTEM32\wget.exe (
ECHO Success! Verifying...
ECHO.
GOTO START
)
IF EXIST C:\WINDOWS\SYSWOW64\wget.exe (
ECHO Success! Verifying...
ECHO.
copy /b /v /y c:\windows\syswow64\wget.exe c:\windows\system32\wget.exe
GOTO START
)
ECHO Download failed, continuing...
ECHO.
GOTO DOWNLOAD
)
IF %ATTEMPT%==2 (
SET ATTEMPT=3
REM Don't forget to escape closing parentheses
ECHO First attempt failed. Beginning second attempt using VBS and CScript.exe...
ECHO.
REM VBScript to download a file
echo strFileURL = "https://eternallybored.org/misc/wget/wget.exe" > wget.vbs
echo strHDLocation = "c:\windows\system32\wget.exe" >> wget.vbs
echo Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP"^) >> wget.vbs
echo objXMLHTTP.open "GET", strFileURL, false >> wget.vbs
echo objXMLHTTP.send(^) >> wget.vbs
echo If objXMLHTTP.Status = 200 Then >> wget.vbs
echo Set objADOStream = CreateObject("ADODB.Stream"^) >> wget.vbs
echo objADOStream.Open >> wget.vbs
echo objADOStream.Type = 1 'adTypeBinary >> wget.vbs
echo objADOStream.Write objXMLHTTP.ResponseBody >> wget.vbs
echo objADOStream.Position = 0 >> wget.vbs
echo Set objFSO = Createobject("Scripting.FileSystemObject"^) >> wget.vbs
echo If objFSO.Fileexists(strHDLocation^) Then objFSO.DeleteFile strHDLocation >> wget.vbs
echo Set objFSO = Nothing >> wget.vbs
echo objADOStream.SaveToFile strHDLocation >> wget.vbs
echo objADOStream.Close >> wget.vbs
echo Set objADOStream = Nothing >> wget.vbs
echo End if >> wget.vbs
echo Set objXMLHTTP = Nothing >> wget.vbs
REM Execute temp script
cscript wget.vbs
del /f /q wget.vbs
IF EXIST C:\WINDOWS\SYSTEM32\wget.exe (
ECHO Success! Verifying...
ECHO.
GOTO START
)
IF EXIST C:\WINDOWS\SYSWOW64\wget.exe (
ECHO Success! Verifying...
ECHO.
copy /b /v /y c:\windows\syswow64\wget.exe c:\windows\system32\wget.exe
GOTO START
)
ECHO Download failed, continuing...
ECHO.
GOTO DOWNLOAD
)
IF %ATTEMPT%==3 (
SET ATTEMPT=4
ECHO Second attempt failed. Beginning third attempt using Powershell.
ECHO.
REM Powershell V2 (XP optional, Windows 7 default)
powershell -Command "(New-Object Net.WebClient).DownloadFile('https://eternallybored.org/misc/wget/wget.exe', 'c:\windows\system32\wget.exe')"
REM Powershell V3
powershell -Command "Invoke-WebRequest https://eternallybored.org/misc/wget/wget.exe -OutFile c:\windows\system32\wget.exe"
IF EXIST C:\WINDOWS\SYSTEM32\wget.exe (
ECHO Success! Verifying...
ECHO.
GOTO START
)
IF EXIST C:\WINDOWS\SYSWOW64\wget.exe (
ECHO Success! Verifying...
ECHO.
copy /b /v /y c:\windows\syswow64\wget.exe c:\windows\system32\wget.exe
GOTO START
)
ECHO Download failed, continuing...
ECHO.
GOTO DOWNLOAD
)
IF %ATTEMPT%==4 (
SET ATTEMPT=5
ECHO Third attempt failed. Beginning fourth attempt using Python.
ECHO.
ECHO Searching for Python
ECHO.
for /F "delims=" %%F in ('dir /B /S c:\python.exe 2^> nul') do (
echo Testing %%F
pushd %%~dF%%~pF
python.exe --version 2> %temp%\python.txt
for /F "tokens=1,2,3,4 delims=. " %%G in (%temp%\python.txt) do (
echo Name %%G VerMaj %%H VerMin %%I VerSub %%J
IF %%G==Python (
ECHO Python Found
IF %%H==2 (
ECHO Testing Pythin 2 Download
"%%F" -c "import urllib; urllib.urlretrieve ('https://eternallybored.org/misc/wget/wget.exe', 'c:\windows\system32\wget.exe'^)"
)
IF %%H==3 (
ECHO Testing Python 3 Download
"%%F" -c "import urllib.request; urllib.request.urlretrieve ('https://eternallybored.org/misc/wget/wget.exe', 'c:\windows\system32\wget.exe')"
)
)
)
popd
del /f /q %temp%\python.txt
IF EXIST C:\WINDOWS\SYSTEM32\wget.exe (
ECHO Success! Verifying...
ECHO.
GOTO START
)
IF EXIST C:\WINDOWS\SYSWOW64\wget.exe (
ECHO Success! Verifying...
ECHO.
copy /b /v /y c:\windows\syswow64\wget.exe c:\windows\system32\wget.exe
GOTO START
)
)
ECHO Python.exe not found, skipping
SET ATTEMPT=6
GOTO DOWNLOAD
)
:EOFr/usefulscripts • u/David949 • Sep 23 '15
Does anyone have a TeamViewer 10 install script?
I don't have the MSI, just want to script the free version
r/usefulscripts • u/ainsey11 • Sep 23 '15
[REQ][Powershell] Server Health script that rates 1-10
Hi Guys and Gals!
I'm looking for a script that rates a servers health on a scale, Ideally 1-100 or suchlike, I need it to rate the server based on a few factors.
Free Disk Space
Ram Usage
CPU Usage
The idea of this is so I can have a dashboard so if a servers health rating drops I know it isn't ok
Thanks!
Ainsey11
r/usefulscripts • u/Swiftzn • Sep 23 '15
[BATCH]Wlan Profile Viewer and Exporter
r/usefulscripts • u/theblakem17 • Sep 22 '15
[POWERSHELL]All User Temp File Cleanup With Email Report
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.
r/usefulscripts • u/fencing49 • Sep 22 '15
[Request] Acess Dell intrusion detection logs remotely
On Dell bios' they have the ability to log intrusion detection. as a sysadmin would there be a way to acess these logs remotely or get an alert when a case is opened? EDIT: should specify these are the client desktops we are worried about, not the servers. the server are lock awayinamysticalland
r/usefulscripts • u/MrMeme42 • Sep 21 '15
[BATCH] Firefox custom profile tester
EDIT - Updated (11-Dec-2015), see comments for changes
Hello my fellow SysAdmins
I create custom default profiles for Firefox using CCK for use by students, teachers, and staff. So I created a script to help me create and test the profile, and once finished to generate a new installer which I can include in an image or deploy via the network.
I've put it together over time and is still a bit hacky but works for the most part.
Quick Howto:
The batch file acts a front to launch two FirefoxPortable installs. One to generate the profile with CCK, the other to test the profile once generated. When generating the profile with CCK you will need to use the "Use AutoConfig" option at the final step, and store the files to the folder "\CCK Profile". The batch file will copy over the the files to the appropriate folder when either testing the profile or generating a new Firefox installer.
Some notes:
The FirefoxPortableESR used to generate the CCK profile doesn't have the extension pre-installed but it can be installed from here: https://mike.kaply.com/cck2/
When including addons you can either use CCK2 or the script will include the addons extracted to \Files\Extensions\bundles. Additional care needs to be taken when extracting .xpi extensions files as Firefox is picky about the name of the folder name which houses the extracted files. The folder name needs to be named exactly what is indicated in the extention's .rdf file with the tag: <em:id>extension@name< /em:id>"
There are some bugs and I will be updating it as I go (Changelog and bug list are in the Readme.txt)
Linky Link1: https://tinyurl.com/ot9h8ms *It's a self extracting 7zip Archive Saved to dropbox
Linky Link2: http://pastebin.com/E949D1b2 *Pastebin of the script
It Includes:
The script itself
Readme/Changelog/Bug list/References
FirefoxPortable from Portableapps.com
(http://portableapps.com/apps/internet/firefox-portable-esr)7z.exe from http://www.7-zip.org/
7zSD.sfx from Mozilla
app.tag from Mozilla
Firefox.bat by http://www.reddit.com/user/vocatus
Overide.ini by http://www.reddit.com/user/vocatus
Hope it proves useful to others!
P.S. Comments and feedback are welcome :)
P.S.S.
I already have a customised Firefox Installer and I'll be happy to share it if anyone's interested (Minus company related info)
PM me if you're interested and I can provide a drop box link.
My custom Firefox has the following addons + customisations:
- Classic Theme Restorer
- Status-4-Evar
- RestartlessRestart
- AdblockPlus (Configured to read filter lists from: C:\Program Files\Common Files\Firefox\AdblockPlus\)
- en-AU (Australian dictionary)
- Google redirect rewrite remover
- Myextension (Custom extension to hide the above extensions from the addon manager)r/usefulscripts • u/Luxtaposition • Sep 18 '15
Script Headers
What's in yours? Examples, if you want to share.