Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

NT Admin

by vroom (Pope)
on May 25, 2000 at 20:37 UTC ( #14802=sourcecodesection: print w/replies, xml ) Need Help??
Force SMS Hardware Inventory
on May 14, 2002 at 19:16 UTC
by OzzyOsbourne
Command line force of an SMS hardware inventory on a remote box.
on Apr 12, 2002 at 21:27 UTC
by Marza

This script as the name implies is used to add ids or a list of IDs to a particular domain/AD group.

There is a logmsg subroutine which can be used for automation or history purposes. If it is not required, then comment it out.

I have not tested AD yet as we don't have an AD setup.

Finally, feel free to use it and mod it as you need. If you think something could be done better, please let me know.

Domain Disk space check
on Apr 04, 2002 at 02:43 UTC
by Marza

This script was originally written by an unknown author and was moded and traded a couple times. I rewrote it and streamlined it and got rid of a few cpu intensive approaches.

It will get a domain list of cpus and then list the drive, file system, capacity, used, free, and percent free.

It is simple so feel free to take it and mod it to your needs. If you think something can be done better, please let me know!

You will need AdminMisc PM from Dave Roth.

040402 - Major changes. As to suggestion, I rescoped the vars and got rid of the declare undefs as well as I also added a ping check and an exclusion ability as well as cleaned a couple extranious variables.

040402 - Minor change. Error message was wrong and the computer print needed to be relocated.

on Mar 13, 2002 at 20:46 UTC
by zeroquo

This code was made to Scan a machine or list of machines, for get information about IIS Server, if active, on which port.


2002-03-13 Edit by Corion : Added CODE tags
on Mar 08, 2002 at 19:37 UTC
by Arcanum
I needed a program to audit disk usage on NT/Win2k servers. I couldn't find anything that would fit my needs, and the Boss was too cheap to pay for commercial software, so I decided to roll my own. This Perl script makes guesses at total disk usage for web content, logs files, and databases. I say it makes guesses because we compress the Logs directories to save space, and I used a simple divide by four to compensate for this compression. That's close enough to the real ratio for large amounts of files.

Just some background so you know what's happening:

-Clients keep their web content in e:\web\{their directory}
-The logs are stored in e:\web\{their directory}\logs
-Access databases are stored on the d:\ drive
-SQL databases are stored on up to two data servers, with NetBIOS mappings to make this work (m:\ and n:\)

Obviously this is custom tailored for our needs, but it can serve as a pretty decent guideline for your own program. I'm just a hack; I'm very much a Perl novice, so this may look be a bit crude. However, it does its job for us, so I can't complain. :)

Comments and questions are welcome. Thanks.

Edit by dws for formating and code tags

McAfee Dat Check
on Mar 07, 2002 at 21:16 UTC
by OzzyOsbourne
Checks the Netshield Dats, engines and versions on all of your servers. Create a file called allservers.txt and put your servers in it, one per line.
on Feb 12, 2002 at 21:54 UTC
by RayRay459
This script will compare the same directory on two different machines for content, size and mtime.
Command Line Service list
on Mar 07, 2002 at 20:08 UTC
by OzzyOsbourne
Gets services and their status on multiple servers from the command line.
on Jan 21, 2002 at 17:08 UTC
by DaveRoberts
This script is used to improve the reliability of trusts between NT domains. The lmhosts file is used to identify domain controllers, and is referred to by the NT operating system when building and maintaining trusts - using computers by order of occurance in the lmhosts file. This script takes a distributed copy of a standard lmhosts file and re-writes this to the normal lmhosts location (%SystemRoot%/system32/drivers/etc) re-ordering the entries in approximate order of network responsiveness. The intended effect of this is to ensure that trusts are maintained with computers that are i) alive on the network and ii) relativly close
Find Directory owners
on Mar 07, 2002 at 20:17 UTC
by OzzyOsbourne
Find the owners of directories on large public shares to ease directory cleanup. The Win32::Perms module has had a memory leak for over a year, which may lead to issues on larger directories.
Guest Account Subnet Sweep
on Mar 07, 2002 at 20:27 UTC
by OzzyOsbourne
Sweep a subnet for the status of the guest account.
DHCP Sweep
on Mar 07, 2002 at 20:23 UTC
by OzzyOsbourne
Sweep a subnet for the DHCP status of the machines.
Disable Guest Account Subnet Sweep
on Mar 07, 2002 at 20:28 UTC
by OzzyOsbourne
Disables guest accounts on all machines on a subnet
on Dec 28, 2001 at 00:35 UTC
by RayRay459
This will clear local event log on a machine. No backup, just clear. We use this for machines that are ghosted and cleaned up for production.
User drive usage reporter
on Jul 05, 2001 at 18:48 UTC
by djw
** UPDATE - Code format is aweful below, but looks normal when you hit the d/l code link. **

When setting up an NT network you usually enter a Home Directory path for all users somewhere on the network. Usually with "\\server\share\%USERNAME%" for the path. In NT this automatically creates a directory under "\\server\share" for each user - and the directory name is the network username of the user (in my case for example, 'djw').

So if I had this setup on a server called "perl" and a sharename of "users" I might have something that looks like this:
      - djw\
      - redmist\
      - danger\
      - Macphisto\
      - ar0n\
      - CowboyNeal\
      - boo_radley\
What this program does is go through each users's directory and reports on the usage. Right now it gives totals for users with more than 1GB, users with less than 1GB, and users with no usage. It also prints out the total share usage, along with individual statistics.

I use this as a simple reporting tool - not a spy tool. =)

Generic Registry Editor
on Jun 22, 2001 at 23:19 UTC
by ralfthewise
The is a gui driven registry editor for network admins. It allows admins to create standard registry edits for workstation builds, maintenance, etc.
Find orphaned home directories
on Jun 08, 2001 at 00:38 UTC
by OzzyOsbourne

People's accounts are deleted when they leave your company, but are their home directories? Hopefully yes, but sometimes, no. This will allow you to be sure.

There are 2 scripts, because in my domain, getting all of the account information tends to take a very long time.

The 1st script pulls all of the usernames and home dirs to a text file called accounts.txt. The second reads the user directories from your servers and checks to see if they are being used as home directories by comparing them to the accounts.txt. If the home dir is not being used by an active account, it is considered "Orphaned" and will be printed to orphan.txt. Then, you can flag it for deletion.

Compare Directories/Permissions across all servers
on Mar 23, 2001 at 22:16 UTC
by OzzyOsbourne

Uses File::Find and Win32::FileSecurity to dump file permissions to a text file on shares that you specify.

Usage {share} {outputlog}


If the account does not have a permission, the script double tabs, for easy visual inspection.

By importing the resultant tab-delimited log into a spreadsheet program, you can sort by account(colC), then share(colB), then server(colA), to very simply compare directory rights across your file and prints.

Thanks to Tyke.

Exchange Service Monitor
on Apr 25, 2001 at 06:38 UTC
by djw
This program will monitor the following services on a Microsoft Exchange 5.5 server:
  • System Attendant
  • Directory
  • Event Service
  • Information Store
  • Internet Mail Service
  • Message Transfer Agent
  • IIS Admin Service (for OWA)
  • World Wide Web Publishing Service (for OWA)
Although it can be modified to monitor any NT/2k Service.

This script works well when set as a Scheduled Task on a dedicated network monitoring station (mine runs every 2 hours). It will attempt to resume or start any paused or stopped service in your list and report everything it finds in a log file, and will send important notices to an Administrator account or an SMS phone, or pager (requires configuration).

To use SMS or paging services, you will need to setup the send_sms sub to fit your service provider. You could change this to use Net::Pager or SMS, but I found simply using my provider's CGI worked well enough.

Here are some screenshots and example logs here:
Network status log file SMS status log file Let me know if you like this or see anything that could be improved.
userdel for NT/2K
on Apr 23, 2001 at 15:04 UTC
by idnopheq
userdel -- Delete a user account.

userdel modifies the system account files, deleting all entries that refer to login. The named user must exist.

useradd for NT
on Apr 23, 2001 at 15:02 UTC
by idnopheq
useradd adds a user to a NT host a la the Solaris useradd utility.


  • Modify for Win2K, domains
  • POD
  • Testing Testing Testing

This script is very BETA, hense the use diagnostics. But, I posted this for the logonhours part (works like net user syntax) and for folks who want to reuse solaris useradmin scripts on NT.

who for NT/2K
on Apr 23, 2001 at 14:55 UTC
by idnopheq
who - who is on the system

The who utility can list the user's name and login time for each current system user.

users for NT/2K
on Apr 23, 2001 at 14:54 UTC
by idnopheq
users - display a compact list of users logged in

users lists the login names of the users currently on the system in a compact, one-line format.

uptime for NT/2K
on Apr 23, 2001 at 14:15 UTC
by idnopheq
uptime - show how long the system has been up

The uptime command prints the current time, the length of time the system has been up, and the number of users logged on.

REQUIRES: Date::Calc

shutdown for NT/2K
on Apr 23, 2001 at 14:11 UTC
by idnopheq
shutdown -- shut down system, change system state

shutdown is executed by the super-user to change the state of the machine.

By default, shutdown brings the system to a state ready for power off.

Before starting to shut down services and killing processes, shutdown sends a warning message via GUI pop-up with the warning message "The systemis shutting down. Please save all work in progress and log off. Any unsaved changes will be lost. This shutdown was initiated by ..." The bottom of the window pop-up contains the custom message included in the shutdown command. If the string contains more than one word, it should be contained within single (') or double (") quotation marks.

The warning message provides output detailing the time remaining before shutdown begins. See EXAMPLES .

No warning is sent to Remote Access Service (RAS) users or users connected via rcmd or telnet.

reboot for NT/2K
on Apr 23, 2001 at 14:07 UTC
by idnopheq
reboot -- restart the operating system

reboot restarts the hardware and operating system.

Although reboot can be run by the super-user at any time, shutdown is normally used first to warn all users logged in of the impending loss of service. See shutdown for details.

passwd for NT/2K
on Apr 23, 2001 at 14:03 UTC
by idnopheq
passwd -- change login password.

passwd changes the password or lists password attributes associated with the user's login name (userid) <- Not yet implemented.

When used to change a password, passwd prompts everyone for their old password, if any. It then prompts for the new password twice.

If executed by a user with USER_PRIV_ADMIN() privilege flag (i.e. super-user), the old password prompt does not appear.

Passwords must be constructed to meet the operating system requirements

TODO: Add password attribute listing

lastlogin for NT/2K
on Apr 23, 2001 at 13:53 UTC
by idnopheq
lastlogin -- show the last date on which each person logged in.

lastlogin displayes the last logon date for each user in the local host's user database.

UPDATE: Got rid of the exists test on scalars, per Re: lastlogin for NT/2K. THX frag! What ~was~ I thinking?
on Dec 03, 2000 at 10:11 UTC
by hendrix
A quick and dirty software auditing script for an nt domain. Basically just takes everything out of the uninstall reg key and generates a couple reports based on the information it gets.
on Oct 09, 2000 at 18:23 UTC
by tye

Cleans up the System and User-specific PATH persistent environment variables by removing duplicate and invalid entries. Can also add directories to the System PATH. Note that it has been wrapped by pl2bat for ease of use under Windows NT. This script does not work for Win9x. I've tested it under WinNT, Win2K, and WinXP.

Update: Now also fixes the value type having been set to REG_SZ instead of REG_EXPAND_SZ.

Update 2: Now also sets the PATH in the parent command shell, which can be very convenient. Code also cleaned up just a bit. See reply below for older version.

Update 3: (2007-01-20) Fixed but where "ARRAY(...)" written to change log rather than path strings, minor whitespace ajustments, and fix bug demerphq pointed out long ago.

Win2k Disk Quota Util
on Sep 29, 2000 at 23:53 UTC
by vladdrak
Complete control over Windows 2000's builtin Disk Quota system. Microsoft decided not to include any commandline utilities for creating/deleting Quotas or for modifying the global config in the 2k release or in the ResKit. So, here it is in Perl. :)
NT Event log clearing
on May 26, 2000 at 22:14 UTC
by flyfishin
This simple little script clears and saves the event logs for whatever servers you place in @servers. It then copies them all to a central location for easy reference.
on Apr 27, 2000 at 17:54 UTC
by ergowolf
see the pod bellow
on Apr 27, 2000 at 18:06 UTC
by ergowolf
This program grabs a list of all users on the domain and emails them to whoever you specify
Log In?

What's my password?
Create A New User
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2018-07-23 14:11 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (469 votes). Check out past polls.