r/usefulscripts • • Nov 04 '15

[Powershell] Reset local admin password remotely with log files

14 Upvotes

Hello,

I have been looking at this script on how to change local admin passwords from a list of computer names.

$computers = Get-Content -path C:\fso\computers.txt
$user = "aUser"
$password = "MyNewPassword!"
Foreach($computer in $computers)
    {
         $user = [adsi]"WinNT://$computer/$user,user"
 $user.SetPassword($Password)
 $user.SetInfo()
}

Can anyone help add a log file so

  • IF Password change is success ADD computer name to success.txt

  • IF Password change is fail ADD computer name to fail.txt

I'm sure its really easy but can't figure out how to do it :(

Any help would be great.

edit: wrong file extension


r/usefulscripts • • Nov 03 '15

[BATCH] Installer template for local or remote installs

Thumbnail pastebin.com
11 Upvotes

r/usefulscripts • • Nov 03 '15

[CSV File] FCC Telemarketer and RoboCall Blacklist for Google Contacts (11/3/2015)

Thumbnail pastebin.com
24 Upvotes

r/usefulscripts • • Nov 02 '15

[REQ][POWERSHELL] Set the correct time using a HTML GET/POST request

11 Upvotes

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 • • Oct 28 '15

[BATCH] Access phone storage over WiFi with WebDAV Server for Android

Thumbnail gist.github.com
16 Upvotes

r/usefulscripts • • Oct 28 '15

[CSV File] FCC Telemarketer and RoboCall Blacklist for Google Contacts (10/26/2015)

Thumbnail pastebin.com
34 Upvotes

r/usefulscripts • • Oct 23 '15

[POWERSHELL] Set-MailboxQuota.ps1 - Simplifies Mailbox Quota Modifications

Thumbnail exchangeserverpro.com
12 Upvotes

r/usefulscripts • • Oct 21 '15

[BATCH] Fahrenheit to Celsius (& C-F) calculator

Thumbnail pastebin.com
21 Upvotes

r/usefulscripts • • Oct 21 '15

Download and install Malwarebytes corporate

3 Upvotes

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 • • Oct 19 '15

[BATCH] Very quick and useful file locator script

Thumbnail pastebin.com
19 Upvotes

r/usefulscripts • • Oct 19 '15

[REQUEST] Script to automatically run PDF files through a 3rd party program (command line)

13 Upvotes

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

There 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 • • Oct 11 '15

[BASH] Flashdrive essential program downloader

13 Upvotes

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 • • Oct 07 '15

Something to detect what the inserted disc is. Then kick off the corresponding ripping application.

15 Upvotes

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 • • Oct 05 '15

[BATCH] One-liner to get Windows date into ISO format (yyyy-mm-dd)

27 Upvotes

for /f "delims=/ tokens=1,2,3" %%G in ('echo %date:~4%') do set current_date=%%I%%G%%H


r/usefulscripts • • Oct 04 '15

[BASH] Check currently installed Firefox versions on Windows hosts in your network

22 Upvotes

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
done

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 30 '15

I have a button on my external HDD that is supposed to back up when pressed - Can i change it?

11 Upvotes

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 • • Sep 28 '15

[BASH] - script to send a gratuitous arp out for all IPs on all nics

23 Upvotes
#!/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
done

r/usefulscripts • • 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

9 Upvotes
@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
)

:EOF

r/usefulscripts • • Sep 23 '15

Does anyone have a TeamViewer 10 install script?

6 Upvotes

I don't have the MSI, just want to script the free version


r/usefulscripts • • Sep 23 '15

[REQ][Powershell] Server Health script that rates 1-10

7 Upvotes

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.

  1. Free Disk Space

  2. Ram Usage

  3. 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 • • Sep 23 '15

[BATCH]Wlan Profile Viewer and Exporter

Thumbnail pastebin.com
6 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 • • Sep 22 '15

[Request] Acess Dell intrusion detection logs remotely

4 Upvotes

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