I do a fair amount of sysadmin scripting. Guess it's time to wikify some of that work!
See the Navigate Pages section of the sidebar --->
CMD
I still default to CMD when I need to script something. Why? Because I can count on it being installed on whatever system I might need to run the script on. This is also true of VBscript, I admit. But cmd scripting is what I learned first, and I still love its pure pithiness. If you can accomplish the task in both VBscript and cmd, the cmd script will generally be shorter and (in my opinion) easier to read.
-
-
The
FOR command is the heart of many cmd scripts.
1
-
WSH/VBscript
WMI/WMIC
Powershell
-
Getting started with powershell is something I haven't yet done. Time and braincells are limited, and the knowledge that Powershell isn't installed by default any version of the OS keeps me from going whole-hog on learning this amazing tool. Because then I'd keep wanting to use it in places where it isn't yet installed.
Must-have utilities
I have a whole site with a more or less custom 'distro' of utilities. But these are the ones I consider to be part of my lifeblood; I often use scripts which call these utilities.
-
pstools - psexec, psshutdown, psservice, pslist, pspasswd - these are my favorites, but there are more, and they are
all handy.
-
-
subinacl - syntax is painful at times. But this is
the tool for permissions work.
- robocopy - the Windows rsync. Copy/sync files or dirs and their permissions. A daily workhorse.
- sleep.exe - batchfile 'wait' command.
- srvinfo - WMIC does more, but srvinfo is a quick way to get vital info about a remote server (if you have admin privs)
- The Windows 2003 Adminpak gives you:
- dsquery/dsget/dsmod/etc - hugely valuable for querying and modifying AD attributes like users, groups, and computers.
- ntdsutil - hugely valuable for maintaining AD's FSMO roles, among other things.
- much more
- Windows 2000 Resource Kit tools which need to be downloaded separately from Dynawell:
- timethis -time the execution of a command or script
- cusrmgr - add/delete/change users from commandline (syntax). Oldschool, but it still works!
- The XP SP2 Support Tools contains the following gems (among others!):
- addiag - for diagnosing AD problems.
- dhcploc - great for finding rogue DHCP servers, and diagnosing DHCP issues.
- netdiag - diagnose network issues
- nltest - check domain secure channels
- netdom - commandline Windows domain join/part/change/test tool.
- setx - commandline tool for setting machine-level environment variables
- whoami is that embarrassing little command for alleviating my Alzheimers-like problem of forgetting whether I'm logged in with admin privs or not. It's part of the resource kit utilities
-
nbtscan is a handy network scanner for Windows systems. Probably growing a bit less useful as local firewalls proliferate and netbios naming dies its slow death.
-
portqry (
download) (
docs) is handy for troubleshooting connectivity issues.
-
eldump is a great commandline event log dumper.
-
wget is handy for downloading things from the commandline
-
openssh is an alternative to
Putty's need for a GUI window of its own. Openssh uses cygwin but does
not need to have the full cygwin install on your system*. The Openssh installer can put an SSH server daemon on your system as well as a client (I do not use the server daemon).
-
Unxutils is a nice source of basic bash-style utilities ported to run natively on the Windows commandline. No cygwin* needed.
-
You need a good text editor. Currently I use and love
EditPadPro, which is gui (and has both pay and free versions). I keep meaning to find a good cmd implementation of
nano, (they do have one at the nano website), but I still haven't gotten 'round to it. I guess I'm more comfortable editing text in the GUI.
* For some reason I am suspicious of cygwin's security robustness. I know this isn't something I can rationally prove by pointing to verifiable sources. Yet still my suspiscions remain.