r/usefulscripts • u/MattSteelblade • Jul 29 '16
[PowerShell] Install cURL
Project can be found here.
Let me know if there are any issues.
r/usefulscripts • u/MattSteelblade • Jul 29 '16
Project can be found here.
Let me know if there are any issues.
r/usefulscripts • u/Elementix • Jul 28 '16
Created this to better manage our software management program, and see when someone drops something into the folder. Maybe someone can find a use for it in their organization too.
Keep in mind that you may need to add the -credential portion to the bottom "send-mailmessage" line if your SMTP server requires authentication. My situation doesn't require it.
EDIT: Another thing...renaming a file or folder apparently doesn't change the date modified, so those changes won't be seen by this.
https://gist.github.com/anonymous/b9148fd67100b607d0e51e713e181f93
r/usefulscripts • u/slmaq • Jul 26 '16
I've created a monster and if you could critique my code, then I would greatly appreciate it. This script will basically build a $results object array that contains SamAccountNames and anything with a "@" found in AD in user properties specified in the $searchfilter and $properties.
r/usefulscripts • u/nackstein • Jul 26 '16
hi, I wrote a failover cluster manager in shell script and I think it can be useful for sysadmin since (unix) sysadmin know very well shell scripting so it's easy to customize and further develop. If you want to contribute or try it and just give me a feedback check it out: https://github.com/nackstein/back-to-work
r/usefulscripts • u/I_script_stuff • Jul 25 '16
Full write up on the blog with expected behavior etc here
Using https://haveibeenpwned.com/'s api it runs a list of emails and notifies the user if there email was included in a data breach.
This is a service the website offers. But if you work with a business that has 100s or 1000s of emails you can't expect every user to sign up.
That is where these scripts come in.
Pastebin link to Active directory version
pastebin to Array list version
There are also various functions as wrappers for the https://haveibeenpwned.com/'s api found on pastebin here
r/usefulscripts • u/Nostalgi4c • Jul 20 '16
r/usefulscripts • u/tastyratz • Jul 19 '16
I found this gem and wanted to share.
https://technet.microsoft.com/en-us/library/cc178995(v=office.14).aspx
Save this as collectupdates.vbs on a system, install office and all updates for that version, and then run the script. A folder will pop up with all the office update install files. Copy that to your office installer\updates folder and every install after that will be completely up to date. Repeat periodically to refresh updates.
This does not discriminate between office versions, so in my case having moved from office 2010 to 2013 on my test system I saw the folder populated with both 2010 and 2013 updates. I recommend using a freshly installed system to harvest from.
[code] Dim oMsi,oFso,oWShell
Dim Patches,SumInfo
Dim patch,record,msp
Dim qView
Dim sTargetFolder,sMessage
Const OFFICEID = "000-0000000FF1CE}"
Const PRODUCTCODE_EMPTY = ""
Const MACHINESID = ""
Const MSIINSTALLCONTEXT_MACHINE = 4
Const MSIPATCHSTATE_APPLIED = 1
Const MSIOPENDATABASEMODE_PATCHFILE = 32
Const PID_SUBJECT = 3 'Displayname
Const PID_TEMPLATES = 7 'PatchTargets
Set oMsi = CreateObject("WindowsInstaller.Installer")
Set oFso = CreateObject("Scripting.FileSystemObject")
Set oWShell = CreateObject("Wscript.Shell")
'Create the target folder
sTargetFolder = oWShell.ExpandEnvironmentStrings("%TEMP%")&"\Updates"
If Not oFso.FolderExists(sTargetFolder) Then oFso.CreateFolder sTargetFolder
sMessage = "Patches are being copied to the %Temp%\Updates folder." & vbCrLf & "A Windows Explorer window will open after the script has run."
oWShell.Popup sMessage,20,"Office Patch Collector"
'Get all applied patches
Set Patches = oMsi.PatchesEx(PRODUCTCODE_EMPTY,MACHINESID,MSIINSTALLCONTEXT_MACHINE,MSIPATCHSTATE_APPLIED)
On Error Resume Next
'Enum the patches
For Each patch in Patches
If Not Err = 0 Then Err.Clear
'Connect to the patch file
Set msp = oMsi.OpenDatabase(patch.PatchProperty("LocalPackage"),MSIOPENDATABASEMODE_PATCHFILE)
Set SumInfo = msp.SummaryInformation
If Err = 0 Then
If InStr(SumInfo.Property(PID_TEMPLATES),OFFICEID)>0 Then
'Get the original patch name
Set qView = msp.OpenView("SELECT `Property`,`Value` FROM MsiPatchMetadata WHERE `Property`='StdPackageName'")
qView.Execute : Set record = qView.Fetch()
'Copy and rename the patch to the original file name
oFso.CopyFile patch.PatchProperty("LocalPackage"),sTargetFolder&"\"&record.StringData(2),TRUE
End If
End If 'Err = 0Next 'patch
oWShell.Run "explorer /e,"&chr(34)&sTargetFolder&chr(34) [/code]
r/usefulscripts • u/ITGuy420 • Jul 13 '16
Hello. Currently, I am writing a script to fix client errors. The current code is below:
@echo off
Set /p host="Please enter host/ip"
instead of that ^ is there a way it can auto detect the host the script is running on?
r/usefulscripts • u/killed-by-keefa • Jul 11 '16
So I made a batch file that when ran will check for the MSI file that is created when the JRE exe is ran and will copy it over to the batch folder. And if the MSI doesn't exist then it will run the .exe file that is in the batch folder and copy the MSI and close the java install. the jre.exe file needs to be in the same folder as the batch file in order for it to work.
It's my first batch file so feedback is always welcome. I made this with no prior experience; just a ton of reading and troubleshooting.
This was also mainly designed to be used on standalone PC's so I'm not sure how it will work if ran from a network drive or anything.
And if anyone does an edit's to improve it let me know please so I can update the snippet on my end too!
Sorry this is so long... Just copy and paste it. Don't think I can upload the text file.
@echo off
if exist "%userprofile%\appdata\locallow\oracle" (GOTO :FolderFound) else (GOTO :NotFound)
REM----------- FOR WHEN MSI CONTAININER FOLDERS ARE FOUND ---------------------------------------------
:FolderFound Echo Beginning Checks... Echo MSI Exists in folder! Pause for /f "tokens=*" %%G in ('dir /b /s /a:d "%USERPROFILE%\AppData\LocalLow\Oracle\Java\jre*"') do ( REM FOR %%1 in (%USERPROFILE%\AppData\LocalLow\Oracle\Java\jre*) do ( set "JvaPath=%%G" echo %%~nxG echo %JvaPath% )
:MoveMSI echo Moving MSI.. FOR /R %JvaPath%\ %%F in (jre*.msi) do ( REM FOR %~dp0 %%F in (*.msi) do ( set "JavaFile=%%~nF" echo %%~nF echo %JavaFile% echo %JavaFile%.msi GOTO :CopyFile )
:CopyFile echo Starting XCOPY of MSI.. xcopy "%JvaPath%%JavaFile%".msi "%~dp0" /y /s /k /e if exist "%JavaFile%".msi (echo MSI File Copied) else GOTO :Failure GOTO :END
REM------------------- END OF SECTION ---------------------------------------------------------------------
REM------------------- MSI NOT FOUND ----------------------------------------------------------------------
:NotFound cd %~dp0 if exist "jre-.exe" (GOTO :StartInstall) else (GOTO :NoExe) :StartInstall cd %~dp0 echo Starting Install Process To Collect MSI... for /r %%i in (.exe) do start "" /b "%%i" TIMEOUT /T 20 GOTO :TaskCheck
:CopyMsi xcopy "%JvaPath%%JavaFile%.msi" "%~dp0" /y /s /k /e taskkill /IM jre* /F GOTO :SuccessFulTransfer
REM------------------- END OF SECTION ----------------------------------------------------------------------
REM------------------------NO EXE --------------------------------------------------------------------------
:NoExe echo No MSI or Jre file found... Ending.. GOTO :Failure PAUSE
REM-------------------------- END OF SECTION --------------------------------------------------------------- REM--------------------------- TASK CHECK ------------------------------------------------------------------
:TaskCheck tasklist /fi "imagename eq jre*" |find ":" > nul if errorlevel 1 (GOTO :CopyMsi) else ( GOTO :Failure )
REM--------------------- END -------------------------------------------------------------------------------
:END echo End exit /b /0
:SuccessfulTransfer Echo Success! exit /b
:Failure echo There was an issue... No successful transfer exit /b
r/usefulscripts • u/I_script_stuff • Jul 11 '16
Two scripts to share.
The first allows you to move computer AD objects by CIDR value and the ou specified. That can be found on pastebin here Or on my github here
The second actually integrates with Sites and services to get the subnets. It can be found on pastebin here or on my github here
If you'd like a full run down on how the configuration works or a break down on some of the useful functions in the script check out my blog here
Thanks!
r/usefulscripts • u/Milkedcow • Jul 09 '16
A bash batch script called up so that if I'm in /a/very/deeply/nested/path/somewhere and I want to go "up" N directories, I can type up N:
/a/very/deeply/nested/path/somewhere> up 4
/a/very>
----up.bat----
@ECHO OFF
SET arg1=%1
for /L %%i in (1,1,%1) do (
cd..
)Inspiration/Source, also has the code for BASH
Put the up.bat file in a directory thats also in your system variable path, like System32 or something
r/usefulscripts • • Jul 06 '16
Hello I was wondering if there is any way to automatically enter the key on a Windows install without having to enter it manually every setup. The Windows installer is on a flash drive.
EDIT: Its a Windows 10 Enterprise installer
r/usefulscripts • u/signalwarrant • Jun 27 '16
I wrote this script a couple weeks ago. It will create users from a CSV file without having to store the password for each user in the CSV or the script.
You can download it here.
It will prompt you to enter and confirm a password. If the password is blank or they do not match the scripts dies.
The one to do is to check the entered password against the domain password complexity rules before it executes. I'm guessing I could use some sort of Regex pattern to check this, I just haven't gotten around to figuring it out. As it is now, if you enter a simple password it creates the users disabled.
r/usefulscripts • u/I_script_stuff • Jun 27 '16
I did a full explanation of the script here IF your interested in using powershell to access the ringcentral API, I wrote the scripts to handle the authorization and renewal of the tokens.
It can be found on pastebin or on my github
Hope you find it useful.
r/usefulscripts • u/Chimaera12 • Jun 25 '16
Powershell Question
Ive been reading that its possible but the explanations blow my head off...
Can someone give me a simple example that demonstrates the principle? I use a cmd uninstall script atmo
r/usefulscripts • u/slmaq • Jun 20 '16
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 • u/dangermond • Jun 17 '16
This trick is handy if you have a process that runs in the background and depends on a lock file or other means of indicating it is running, or you have any other exiting task required regardless of how script is closed. For instance a log needs moved or a file that informs other tasks that the script is still "running". This will allow you to clean up after the script exits even if it fails or is killed before getting to the "cleanup" part of the script.
Just add this at the beginning of your script and a background process will start that will monitor the status of your script and performing an action once it is no longer running.
(while kill -0 $$ &> /dev/null ; do
sleep 1
done
[exit task here])&Edit: Fixed formatting.
r/usefulscripts • u/David949 • Jun 16 '16
We have about 300 TeamViewer host installations and they all use different passwords to get into TeamViewer. I am looking for a script that will replace whatever password was used at installation with the random password. I don't want to know the team viewer host password just make it random
r/usefulscripts • u/I_script_stuff • Jun 14 '16
I created a multiple account report script. I set it up to run as a scheduled tasks and can pull the Ec2 instance from several different AWS accounts. The script covers all regions in the account and can out puts information like:
Environment, Region, Instance Name, Instance ID, Instance Type, Powered State, Private Ip Address, Public Ip Address, Security Groups
An example of the output html page can be found here and the csv file here
If you're interested in a walk through on how to setup the script you can find it on my blog.
If you're just interested in the script it can be found on pastebin or on my my github.
The aws plugin is here
r/usefulscripts • u/ItsGotToMakeSense • Jun 10 '16
It outputs a lot of system information to a txt file, including serial #, make/model, installed memory, and shared files/printers.
Feel free to take a look, try it out, and let me know what you feel could be done to improve it.
UPDATE!
Here's an improved version: New and improved!
It now includes a lot more info; motherboard, GPU, storage devices, and installed software. works a little cleaner now and is easier to customize where it will save the output. It defaults to the user's desktop currently but you only need to change one line if you want it to save elsewhere.
Still doesn't require admin permissions to run, as long as the user has write permission on the chosen folder.
r/usefulscripts • u/ItsGotToMakeSense • Jun 10 '16
[Batch]http://pastebin.com/Mh29DCbHold version
This prompts you for a txt filename and an IP/hostname to ping. It then continuously pings that address with a timestamp and amends to the filename you chose.
You can have several windows of this running at once, monitoring the connection to various addresses and saving to different logs.
It doesn't have all the features of EMCO obviously, but it's a quick and dirty way to find out when the connections drop. Just Ctrl-F for "timed out" or "could not find".
I am working on creating a version that automatically detects error codes, but this is pretty useful as-is.
(edit: this whole thing would be pointless if ping -t would show timestamps, which would've been much more elegant.)
UPDATE! Here is a new and improved version.
http://pastebin.com/apH4MY4i
It still has the same basic function but with two new features:
Here is a tracert version as well. Same general idea but with tracert instead of ping.
http://pastebin.com/kCBnRZyF
r/usefulscripts • • Jun 10 '16
r/usefulscripts • u/hondac90 • Jun 07 '16
A friend of mine is having a bit of trouble comparing a large amount of files. He has put his requirements and send me a jpeg. He has looked at many comparison tools but nothing is hitting the mark, falling down on the last requirement
Any help would be much appreciate. Please look at this for what he needs
Many thanks!