Archive - February 2013

"Aim not for what you are, but for what you could be." - Lucas Hellmer
 
 
  

Index
bar1
Toggle Desktop Icons Show/Hide
Enumerate All Users in a Domain
Enumerate All DCs in a Domain
Random Password Generator
Find Locked Out Users
Move Inactive Computer Accounts
Delete Files Older Than X Days
Return User Account Info
Windows Update Fix
Return Domain Logon History
Password is about to Expire
Reset The Local Password On All Machines


bar1





Δ Useful Script of the Month
bar1


How to rename a list of computers from a text file

Task:
Rename a fleet of workstations from a text file.  The text file contains computer old and new names.

For example the text file (oldname, newname):

lab01,class01
lab02,class02
lab03,class03


Script:

@::  1ST CREATE THE COMPUTERS.TXT FILE - CONTAINS OLDNAME,NEWNAME COMPUTER NAMES
@::  2ND UPDATE THE NETDOM COMMAND WITH THE PROPER CREDENTIALS

@Echo off
Title Administrative Computer Rename
color 0a

::  --------------------------------------------------------------------------------------------------------------------------------
for /f "tokens=1,2 delims=," %%a in (computers.txt) do (

::  TEST FOR ONLINE STATUS
echo Loading workstation name...
echo.
ping -n 2 127.0.0.1>nul
ping %%a | find "Reply" > nul
if errorlevel 1 (echo oldname:%%a,newname:%%b,OFFLINE >> "log.txt"
) else (
echo oldname:%%a,newname:%%b,ONLINE >> "log.txt"
echo Found %%a...
echo.
ping -n 2 127.0.0.1>nul
::  RENAME COMPUTER
echo Renaming computer...
echo.
netdom renamecomputer %%a /newname:%%b /userD:DOMAIN\DOMAIN_ACCOUNT_NAME /passwordd:
DOMAIN_ACCOUNT_PASSWORD /usero:administrator /passwordo:LOCAL_ACCOUNT_PASSWORD /reboot:30 /force
ping -n 2 127.0.0.1>nul
)
)
::  --------------------------------------------------------------------------------------------------------------------------------



bar1





Δ Thursday, February 28th, 2013
bar1


Δ Toggle Desktop Icons Show/Hide

How to show and hide desktop icons

[download resource files]

Demo
demo

 

This is an AutoIT script that uses a function to toggle the show and hide icons feature.  I use
this regularly for even easier access via a one-click panel.



Δ  [email me]

bar1





Δ Wednesday, February 27th, 2013
bar1


Δ Enumerate All Users in a Domain

How to return all usernames in a domain

[download resource files]


VBScript to create a text file listing the names of all users in the domain. The file contains
the NT name of each user, one name per line. The NT name is called the pre-Windows 2000
logon name. It is the value of the sAMAccountName attribute of the user. The sAMAccountName
of any object must be unique in the domain.




Δ  [email me]

bar1





Δ Monday, February 25th, 2013
bar1


Δ Enumerate All DCs in a Domain

How to return domain controllers in a domain

[download resource files]


VBScript to enumerate all Domain Controllers in the domain.



Δ  [email me]

bar1






Δ Friday, February 22nd, 2013
bar1


Δ Random Password Generator

How to return random characters to a text file

[download resource files]

Demo
demo

 

This VBScript uses a simple function and an arrary to generate random characters and then
sendkey them to notepad.



Δ  [email me]

bar1






Δ Thursday, February 21st, 2013
bar1


Δ Find Locked Out Users

How to return all your locked out users

[download resource files]


VBScript demonstrating an efficient way to retrieve the names of all users that are currently locked
out. This program outputs the Distinguished Names of all locked out users.



Δ  [email me]

bar1






Δ Tuesday, February 19th, 2013
bar1


Δ Move Inactive Computer Accounts

How to move computer accounts in active directory

[download resource files]


VBScript program to determine when each computer account in the domain last had
their password changed. If this date is more than a specified number of days in the
past, the computer object is considered inactive and it is moved to a target
Organizational Unit. The computer account is also disabled. A log file keeps track
of which computer objects are moved.



Δ  [email me]

bar1






Δ Monday, February 18th, 2013
bar1


Δ Delete Files Older Than X Days

How to delete files older than a specified date

[download resource files]

 
This PowerShell script allows you to delete old files based on the specified amount of days old.



Δ  [email me]

bar1







Δ Friday, February 15th, 2013
bar1


Δ Return User Account Info

How to return user account information from active directory.

[download resource files]


VBScript to retrieve the password information for one user. The user Distinguished Name
is hard coded in the program. The program outputs the date the user last changed their
password, the domain maximum password age policy in days, whether the user is allowed
to change their password, and whether the password is expired. The user is allowed to change
their password if the flag "User cannot change password" is not set, and the flag "Password
never expires" is also not set.



Δ  [email me]

bar1






Δ Thursday, February 7th, 2013
bar1


Δ Windows Update Fix

How to repair windows update

[download resource files]


Every once in awhile the windows update feature just completely stops working; this is how you fix it.




Δ  [email me]

bar1






Δ Wednesday, February 6th, 2013
bar1


Δ Return Domain Logon History

How to return a user's domain logon history

[download resource files]


This script queries a list of computers and get a list of domain users that have logged on from WMI. 
Note, this takes awhile using WMI.



Δ  [email me]

bar1






Δ Monday, February 4th, 2013
bar1


Δ Password is about to Expire

How to return all users that have passwords about to expire

[download resource files]


VBScript to find all user accounts where the password is about to expire in a specified
number of days.



Δ  [email me]

bar1






Δ Friday, February 1st, 2013
bar1


Δ Reset The Local Password On All Machines

How to reset the local password on your fleet machines

EASY WAY - using SCCM/LANDesk/Logon Script




HARD WAY

[download resource files]


VBScript to reset the local Administrator password on all workstations in the domain to the
same value. The program documents all activity, including workstations that could not be
contacted or on which the password could not be reset, to a log file. The NetBIOS names
of all computers where the password was not reset are also written to a "missed" file. The
next time the program is run, only the computers listed in this file will be processed. The
program can be run repeatedly until this file is empty, meaning that the local Administrator
password has been reset on all workstations.



Δ  [email me]

bar1






 
 










  About

   I'm a Computer
   Systems Engineer

   Living and Loving Life

 

  Author