Tuesday, April 11, 2017

How to set Citrix default printer with a logon script.


powershell.exe -Command "$printer = get-wmiobject -class win32_printer | select -first 1 ; $printer.setdefaultprinter()"

This will get a list of printers from the user session and make the first one default. The first printer in the list is the default on the local computer outside of Citrix. I don't know why the local default is always first in the list but that appears to be the case.

Friday, May 8, 2015

How to delete files older than 30 days with one command line.


cleanup.bat

forfiles /p e:\camfiles /d -30 /m *.* /s /c "cmd /C del /q @FILE"

IP cameras do an ftp upload every five minutes. A schedules task will clean up the old files nightly.

Monday, February 9, 2015

Simple script to backup Fortinet hardware.


I have a bunch of Fortinet equipment installed and I needed an easy way to backup my configurations. This is a windows command line script that requires putty and an ftp server. When a new unit is installed, just add one line to this script.


bkup.bat

echo execute backup config ftp  /unit-123 ftp.example.com  user pass >bkup.tmp
c:\putty 10.123.1.1 -l admin -pw pass -m bkup.tmp

echo execute backup config ftp  /unit-124 ftp.example.com  user pass >bkup.tmp
c:\putty 10.124.1.1 -l admin -pw pass -m bkup.tmp

...

Tuesday, December 9, 2014

Office 2010 activation fails with error 0x80070190.

Right click on Command Prompt and select Run as administrator. Run excel and this should fix it. You will have to find the folder where excel is located.

Wednesday, August 20, 2014

How to extract music on hold from Mitel 3300.

I put a music file on the Mitel a couple of years ago. Now I need to put it on another Mitel and of course I lost the original file.

ftp mitel-ip

cd "/db"
cd "eMOH"
ls

The file name does not match the name in the GUI.

Tuesday, July 8, 2014

How to get a quick list from AD with samid and company name.


dsquery user -limit 1000 | dsget user -samid -company

I doubt anyone else would ever need this info.

Tuesday, February 18, 2014

How to quickly sniff a few packets with a Cisco router.

There was a large amount of traffic on a router and I knew something was not right.

int g 0/0
ip accounting output-packets

#sh ip accounting
   Source           Destination              Packets               Bytes
 10.201.195.4    71.225.81.54                   400              187200
 10.194.41.94    63.251.34.130                  488               28733
 10.194.41.36    108.168.214.12                1140              163510862
 10.136.114.135  78.108.118.250                  45                2100
 10.194.41.57    174.62.230.118                  40                2411
 10.194.41.36    65.112.54.26                     5                178235
 10.194.41.78    63.251.34.145                  479               27517

We need more detail on .36

access-list 105 permit tcp host 10.194.41.36 any

debug ip packet 105

terminal monitor (If you are doing this remotely.)

Now you should get more info like port numbers.

no debug all

This was a DOS attack. Now it has been blocked.