Tag Archives: find

Scripts to Mount and search windows machines

Here are some scripts that I wrote to mount and search bulk windows machines.

mountmachines.sh

#!/bin/bash
cd /searchmachines
echo “Username please”
read username
echo “Password please”
read -s password
for machine in `cat machinelist.txt`
do
mkdir remote$machine
echo “Attempting to mount $machine…”
mount.cifs //$machine/c$ ./remote$machine -o username=$username,password=$password
done
exit

This next script searches the machines for NTUSER.DAT files to find users that were logged in during a specific time frame.

search.sh

#!/bin/bash
cd /searchmachines
echo “Enter number of days for oldest file. (4 for no older than 4 days)”
read old
echo “Enter number of days for newest file. (2 for at least 2 days old)”
read new
echo “Searching…”
find ./ -name NTUSER.DAT -mtime $new -mtime -$old -daystart