http://qs321.pair.com?node_id=14802
Windows Active Directory to PDF Phone List
on Sep 19, 2006 at 11:42 UTC
by davis

Here's a script to extract telephone entries from a Windows AD via Net::LDAP (thanks g0n!) and output them to a LaTeX file to be process with pdflatex. The results aren't too terrible.

You'll probably need to customize it; we, for example, store "Mobile speed dial" numbers in the "Pager" field. We also deliberately separate based on the physical building — YMMV.

I'd recommend separating the template into a separate file, I included here inline because it's easier to download.

Physical memory on remote machine
on Mar 27, 2006 at 23:19 UTC
by mjg
A short example of WMI and Win32::OLE to get info from another server. Note that the hostname needs to be laundered or Win32::OLE will cry.
Get Domain Members
on Sep 01, 2004 at 14:19 UTC
by BravoTwoZero

This one was more of a lark. It's only possible because the Win32::NetAdmin module does so much of the heavy lifting (and it comes with Activestate Perl or SFU's Perl). I wrote it as a quick and easy report to my boss for how many non-NT-based systems we have joined to our domain (we still have a number of 95/98 desktops in use).

The program picks up the domain controller for the system from which it is run. We don't have a multi-domain environment, so you might need to run it more than once (and append the domain name to the clients) if you do admin multiple domains. It could be the basis for more data gathering from the clients (drives, ram, specific windows versions, running services). We don't need that here, but it's nice to have it around as a building block.

The script builds an array of each of the following: primary domain controller, backup domain controller, NT servers (NT,2000,2003), unix servers, mssql servers, NT workstations (NT,2000,XP) and non-NT workstations (WFW,95,98,ME). Again, we didn't require specific versions. We just wanted a quick view of who is a *real* domain member, since they will be authenticating solely with the DC running the PDC FSMO service.

Because the array of NT domain members includes Unix and NT servers, those get added to a hash so that they won't be reported as NT-class workstations. Then it all barfs out to stdout.

By the way, if you're reading this for NT Admin stuff, the chances are good that you'll find a lotta useful information here: Wayne's NT Resources for Administrators and Users.

NT Logon Detail List
on Aug 24, 2004 at 03:07 UTC
by BravoTwoZero

We needed a way to find and sort all domain users by account status (enabled, disabled, etc) and/or last logoff time. It could be cleaner, simpler and take less time to run (45 minutes with 7 domain controllers). This takes the logon, adds details from Exchange and calculates the most recent last logoff time before dumping the whole mess to stdout as a comma-delimited list.

The only variable you need to change is the $ldapsrv scalar near the beginning. Everything else will (hopefully) just work.

Good luck... hope it helps... muchos gracias to everyone who ever wrote something related... I'm sure I looked at it a dozen times... feel free to improve it!

2004-08-25: Added pdc/bdc lookup (so you don't have to manually change the array) and fixed a problem with the headers. Thanks to Marza's domain disk space check program for the pointer to the obvious routine for adding the pdc and bdcs generically.

2004-11-16: Tweaked a lot of little stuff

  • Changed output to comma-separated from tab-separated
  • Wrapped the data in double-quotes for the csv output
  • Added password age variable (for auditing)
  • Left my company-specific employee ID attrib in place with an explanation (since someone may find it useful)
Hardware/Software Inventory
on Apr 24, 2004 at 00:26 UTC
by shonorio
Script that show how can you use the WMI do inventory of hardware/software from a specific machine.
MDaemon Nightly Mail Indexer
on May 02, 2003 at 15:24 UTC
by finni
This is something I run from Win2k's Scheduled Tasks every night, on a server running MDaemon from Alt-N. Everything in- or out-bound from our domain gets copied to a specific account we use strictly for archival. This grabs everything from his user directory that was Last Modified yesterday; moves it to that day's directory on our SnapServer; makes a plain-text index of filename, To, From, and Subject; and then zips up all the mail.

I'd love to see some feedback, because this is my first large-scale utility script.

Regtool
on Sep 29, 2002 at 16:59 UTC
by hopes
regtool.pl is a simple utility to list win32 registry keys.
One day, I posted this node. It was simple a win32 registry tool.
I've improve the regtool.pl and here is the result.
Now it's also a simple tool, but it has its own documentation.
Now I'm considering to make other functions, like "edit", "new" and "delete" :-)
Hopes
perl -le '$_=$,=q,\,@4O,,s,^$,$\,,s,s,^,b9,s,$_^=q,$\^-]!,,print'
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.
addtogrp
on Apr 12, 2002 at 21:27 UTC
by Marza
addtogrp.pl

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

spacecheck.pl

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 ptime.pl. 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.

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

Enjoy.

2002-03-13 Edit by Corion : Added CODE tags

audit.pl
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.
Disable Guest Account Subnet Sweep
on Mar 07, 2002 at 20:28 UTC
by OzzyOsbourne
Disables guest accounts on all machines on a subnet
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.
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.
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.
Comparedirs.pl
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.
lmhosts.pl
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
eventclear.pl
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:
    \\perl\users\
      - 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. =)

Enjoy,
djw
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.

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.
ciao,
djw
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.

TODO:

  • 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?

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 code.pl {share} {outputlog}

Output:server(tab)share(tab)account(tab)permission1(tab)permission2(tab)...(enter)

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.

thegoods.pl
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.
CleanPath
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.
Adminmail.pl
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
netspace.pl
on Apr 27, 2000 at 17:54 UTC
by ergowolf
see the pod bellow
Windows Active Directory to PDF Phone List
on Sep 19, 2006 at 11:42 UTC
by davis

Here's a script to extract telephone entries from a Windows AD via Net::LDAP (thanks g0n!) and output them to a LaTeX file to be process with pdflatex. The results aren't too terrible.

You'll probably need to customize it; we, for example, store "Mobile speed dial" numbers in the "Pager" field. We also deliberately separate based on the physical building — YMMV.

I'd recommend separating the template into a separate file, I included here inline because it's easier to download.

Physical memory on remote machine
on Mar 27, 2006 at 23:19 UTC
by mjg
A short example of WMI and Win32::OLE to get info from another server. Note that the hostname needs to be laundered or Win32::OLE will cry.
Get Domain Members
on Sep 01, 2004 at 14:19 UTC
by BravoTwoZero

This one was more of a lark. It's only possible because the Win32::NetAdmin module does so much of the heavy lifting (and it comes with Activestate Perl or SFU's Perl). I wrote it as a quick and easy report to my boss for how many non-NT-based systems we have joined to our domain (we still have a number of 95/98 desktops in use).

The program picks up the domain controller for the system from which it is run. We don't have a multi-domain environment, so you might need to run it more than once (and append the domain name to the clients) if you do admin multiple domains. It could be the basis for more data gathering from the clients (drives, ram, specific windows versions, running services). We don't need that here, but it's nice to have it around as a building block.

The script builds an array of each of the following: primary domain controller, backup domain controller, NT servers (NT,2000,2003), unix servers, mssql servers, NT workstations (NT,2000,XP) and non-NT workstations (WFW,95,98,ME). Again, we didn't require specific versions. We just wanted a quick view of who is a *real* domain member, since they will be authenticating solely with the DC running the PDC FSMO service.

Because the array of NT domain members includes Unix and NT servers, those get added to a hash so that they won't be reported as NT-class workstations. Then it all barfs out to stdout.

By the way, if you're reading this for NT Admin stuff, the chances are good that you'll find a lotta useful information here: Wayne's NT Resources for Administrators and Users.

NT Logon Detail List
on Aug 24, 2004 at 03:07 UTC
by BravoTwoZero

We needed a way to find and sort all domain users by account status (enabled, disabled, etc) and/or last logoff time. It could be cleaner, simpler and take less time to run (45 minutes with 7 domain controllers). This takes the logon, adds details from Exchange and calculates the most recent last logoff time before dumping the whole mess to stdout as a comma-delimited list.

The only variable you need to change is the $ldapsrv scalar near the beginning. Everything else will (hopefully) just work.

Good luck... hope it helps... muchos gracias to everyone who ever wrote something related... I'm sure I looked at it a dozen times... feel free to improve it!

2004-08-25: Added pdc/bdc lookup (so you don't have to manually change the array) and fixed a problem with the headers. Thanks to Marza's domain disk space check program for the pointer to the obvious routine for adding the pdc and bdcs generically.

2004-11-16: Tweaked a lot of little stuff

  • Changed output to comma-separated from tab-separated
  • Wrapped the data in double-quotes for the csv output
  • Added password age variable (for auditing)
  • Left my company-specific employee ID attrib in place with an explanation (since someone may find it useful)
Hardware/Software Inventory
on Apr 24, 2004 at 00:26 UTC
by shonorio
Script that show how can you use the WMI do inventory of hardware/software from a specific machine.
MDaemon Nightly Mail Indexer
on May 02, 2003 at 15:24 UTC
by finni
This is something I run from Win2k's Scheduled Tasks every night, on a server running MDaemon from Alt-N. Everything in- or out-bound from our domain gets copied to a specific account we use strictly for archival. This grabs everything from his user directory that was Last Modified yesterday; moves it to that day's directory on our SnapServer; makes a plain-text index of filename, To, From, and Subject; and then zips up all the mail.

I'd love to see some feedback, because this is my first large-scale utility script.

Regtool
on Sep 29, 2002 at 16:59 UTC
by hopes
regtool.pl is a simple utility to list win32 registry keys.
One day, I posted this node. It was simple a win32 registry tool.
I've improve the regtool.pl and here is the result.
Now it's also a simple tool, but it has its own documentation.
Now I'm considering to make other functions, like "edit", "new" and "delete" :-)
Hopes
perl -le '$_=$,=q,\,@4O,,s,^$,$\,,s,s,^,b9,s,$_^=q,$\^-]!,,print'
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.
addtogrp
on Apr 12, 2002 at 21:27 UTC
by Marza
addtogrp.pl

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

spacecheck.pl

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 ptime.pl. 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.

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

Enjoy.

2002-03-13 Edit by Corion : Added CODE tags

audit.pl
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.
Comparedirs.pl
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.
lmhosts.pl
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
eventclear.pl
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:
    \\perl\users\
      - 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. =)

Enjoy,
djw
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 code.pl {share} {outputlog}

Output:server(tab)share(tab)account(tab)permission1(tab)permission2(tab)...(enter)

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.
ciao,
djw
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.

TODO:

  • 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?

thegoods.pl
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.
CleanPath
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.
netspace.pl
on Apr 27, 2000 at 17:54 UTC
by ergowolf
see the pod bellow
Adminmail.pl
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