The Script Library: New and Improved

Well, not new really, but definitely improved 😉

When you visit the Script Library at http://www2.adminscripteditor.com/ScriptLibrary you’ll see that it matches the layout of the site as expected and the scripts that were on the old one are indeed carried forward to this new release of the service. What you’ll also find is that we are leveraging GoogleConnect for credentials in the ScriptLibrary.

To make things easier on everyone, we eliminated the need for a site/support account, but for the ScriptLibrary we really do need a personal account to pull it off. We started to dabble in GoogleConnect here and have leveraged that here for a couple of reasons. The biggest reason is you don’t have to create a new account! You can use your existing Google, Twitter or Facebook account instead of having to manage an additional account.

So it is up and running now and we’d love for you to check it out and let us know what you think. Thank you in advance!

Scripting 101

Oh my gosh!  Joe the scripting guy just left and guess what??!!??  I now get to do the login script for the entire enterprise and do not know what to do??!!??  Where do I go?  What do I do?  Sound typical?  If you speak with anybody out there who has done domain login scripting, it has pretty much played out in this scenario

Let’s stop for a second..  Take a breather..  I know.. I know, your boss is crawling down your neck asking you to add in a new drive mapping for Accounting

  1. Get a lay of the land
  2. What tools do you have available?
  3. What resources are out there?
  4. Check to see if you have appropriate domain rights
  5. Test test test..
  6. Implement

First of all, you are in IT so you know the one thing that is constant is change.  That is, things are always changing..

Get a lay of the land

  • Do you know where all of the DCs are?
  • Replication schedules?
  • Servers?
  • Workstations?
  • Printers?

I am not going to go in to all of the tools/applications that are available to determine this information

What format is the script in?  Is it KiXtart, VBS, GPO?

What tools do you have available?

  • Editor: For example: Admin Script Editor
  • The script files themselves, you may want to create a test script to verify if there any issues that come up before implementing into prod.  Be sure you have a BACKUP of any scripts you change – it will save you heartache later (trust me)!
  • The script parser itself (regular run and debug mode): kix32.exe, cscript.exe/wscript.exe, autoit3.exe, etc.  This will typically show you where there are problems.  Check for return codes, etc.
  • Deadline: While not a tool per se, it gives you a time container to work in

What resources are out there?

  • Documentation – When you download KiXtart or AutoIT for example, there are some examples included of what you can do with the product
  • Support Forums – A support forum is a treasure trove of information from people just like you that have had similar issues
  • Colleagues – Has anybody in the department done scripting before?  Maybe somebody a little obscure like your Report Writer..  What is good about this is that they have gone down the path you are starting to go down
  • Former colleagues – What have you done in the past that you can leverage a former colleague?  Please be careful and respect the person’s time as they are most likely on the clock and ask them if it is a good time to talk and if not, book another time to chat

Check to see if you have appropriate domain rights
If you cannot get to the script with write privileges, you will need to talk with your Domain Administrator.  If you are not sure, talk to your Manager for the appropriate policies and/or procedures. YMMV.  Note: This maybe a procedural issue where you have to put the scripts/updates in a specific location to be picked up and you will have to wait for domain replication to take place

Test test test..
Typically, as a scripter you do not have a software QC resource to test your scripts, for example.  Usually, you are on your own for testing, verifying, and updating.  Be sure to have a back-out plan in the event things don’t work.  Be careful oh Obi-Wan!

Implement
Once you have tested the script, implement into production.  You will hear if there is an issue – I know that is a bit hard to hear, but we all have stumbled.

Command-Line Add-ons

External Batch software

There are a lot of great command-line tools that come with Windows, but did you know there are number of great third-party DOS (or command-line) tools as well?  This is not intended to endorse or promote any application, but to show that there are tools available to help you do your job.  This is also by no means a complete list.

PowerShell Scripting – Getting Started

Getting started with PowerShell..

PowerShell is a “new kid on the block” in the scripting arena..

Be sure you have PowerShell installed.  If you run Windows Update, it should be installed automatically..

To start it, you can simply go to a Command Prompt (CMD.EXE) and type in powershell <ENTER>

To call up a script, you can just type in the name of the script and press the <ENTER> key.

For example type in:  rts-extract, or rts-extract.ps1, or can you use “command-line” completion, by pressing the <TAB> key.

Note: There is a caveat to running a PowerShell Script.  After you install it, you cannot run scripts as your computer system by default blocks them after installing PowerShell.

Enable Script Support in PowerShell..

  1. Open PowerShell (if you are running PowerShell on Windows Vista, right-click your PowerShell icon and select Run as administrator. If you don’t do this, you will not be able to enable script support).
  2. Check the current script execution policy by using the Get-ExecutionPolicy cmdlet. To do this, input Get-ExecutionPolicy and press Enter on your keyboard. PowerShell will return a value of Restricted.
  3. To change the script execution policy, use the Set-ExecutionPolicy cmdlet. Input Set-ExecutionPolicy unrestricted and press Enter on your keyboard.
  4. To ensure that the script execution policy has been changed, use the Get-ExecutionPolicy cmdlet again. PowerShell should return a value of Unrestricted.

So, now you will get the results you are looking for in the resulting CSV file.

Here is our code we are using..  Note: The is part of an application I use called RoyalTS and it uses an XML configuration file for the servers I connect to.  I had a need to extract out Server Names, IP, etc. and it was shared with me that this can be done pretty easily in PowerShell.

[xml]$Document=Get-Content ..\PIBConnections.rts;
$Categories=$Document.SelectNodes("/RTSDocument/Categories/RTSCategory");
$Connections = @(
 foreach($Category in $Categories){foreach($Connection in
 $Category.Connections.RTSConnection) {$Connection|Select-Object CategoryName, ConnectionName, Host, User, Domain}}
)
$Connections|Export-Csv -path .\test.csv;

To leave PowerShell, just type in exit and then exit again to leave the CMD prompt.

This is by no means a complete lesson in PowerShell, but a high-level of one of the things you can do with it..

Installing a new, larger drive

NOTE: The audience of this article should be technical enough to understand the information discussed below.  I used Windows XP for this process, but you should be able to use Vista/7 for the same.

  1. DISCLAIMER: There is no guarantee the below process will work for you and I have used this several times with success
  2. POTENTIAL PITFALL #1: The system HAL may not be able to address or handle the larger drive and/or hardware changes
  3. POTENTIAL PITFALL #2: You may also have to re-install your operating system (but, not deleting your old software) on the new drive to fix any existing issuses that get tranferred over – YMMV
  4. POTENTIAL PITFALL #3: The original intent of this article is to take a copy of an image from an old drive to a new drive and run the new drive under the same, original chassis.  If you copy the image from one chassis to another, you maybe able to run it, but then again you are on your own as the HAL will be different.
  5. You have to be patient and stick with it!!
  6. You have been warned! 🙂
Preparations:
  1. Be sure that you can boot your system from the CD-ROM drive
  2. Be sure you have the correct, bootable Windows CD (I used XP with an appropriate edition (Home, Media Center, or Professional), Service Pack (SP1, SP2, or SP3 – be sure it is the same Service Pack that is installed on the system), Internet Explorer (6, 7, or 8))
  3. Download GParted (version 0.5.2-1 or newer with Debian LINUX), they have fixed/updated the copy process for NTFS partitions http://gparted.sourceforge.net
  4. Use a program like Imgburn to burn the GParted ISO to a new blank CD http://www.imgburn.com
  5. Download and/or obtain any tools, utilities, and/or updates from the hard drive manufacturer as they maybe needed for the new drive installation.  And/or you need to be sure you have the install disks, CDs, etc. that may have come with both the new/old drives
  6. Follow manufacturer’s instructions and reference materials for correct technical data:  This can be, but not limited to: jumper settings, software drivers, firmware, etc. for the drives (old/new)
Process Steps:
On a high-level, you will be taking a copy of your old hard drive and copying it to your new drive.  Once copied, then you will need to disconnect the old drive and boot off of the newly created volume.  I have also tried to use the DOS Command XCOPY with various switches to copy the volume from one drive to another, but when put into practice I had mixed results.  If the process does not work, you can put your old drive back in as a Master position/jumper(s) and you can use the old drive.  With a SATA connector (depending on your PC manufacturer) can be as a simple as a  move from one connector slot to another on the motherboard for the Master/Slave configuration.  It may also be helpful to apply BIOS Updates as well.
  1. BACKUP FIRST: Backup your system to insure that you have your Desktop, Favorites, Documents, Outlook files, registry, etc to an offline store like a network drive.  This will help insure that if there is a problem you can get to your old data
  2. Configure and plug the new drive in a secondary (or slave) location into the intended system
  3. Boot using the GParted CD
    1. From the button bar, locate the: //dev/sda and switch it to: //dev/sdb – this is an example, yours maybe different
    2. Create a new NTFS Partition(s).  Note: If you have used a tool like MaxBlast or another utility, you maybe able to skip this step
    3. From the button bar, locate the: //dev/sdb and switch it back to: //dev/sda – this is an example, yours maybe different
    4. Locate the original drive and image and select it should be something like: //dev/sda1
    5. Locate and press the copy button from the toolbar in GParted
    6. From the button bar, locate the: //dev/sda and switch it to: //dev/sdb – this is an example, yours maybe different
    7. Select the new image location
    8. From the button bar, locate and press the paste button.  NOTE: If the old drive is larger than the new drive, you may have to re-size the old drive using GParted to fit on the new drive – don’t laugh this happened to me
      NOTE: The copy process can take a while (60-90 minutes plus), so you have to be patient and is dependent on processor, bus speed, drive size, and so on..  I had one drive that took me most of a weekend to complete it’s copy, but was with an older version of GParted
    9. Once the copy has completed, right-click on the image and choose boot flags: verify it has a checkmark in boot
    10. Shutdown and eject the GParted CD
  4. Remove the old drive out of the machine or undo the cable temporarily
  5. Add the new drive cable into the primary (or Master location and/or jumpers)
  6. Start up your computer with your Operating System Boot CD
    1. Once it boots up, have the install check and correct the new drive for errors.  Once complete, it will say maintenance has completed and will need to restart
    2. Eject the Operating System Boot CD
  7. After the computer restarts and if all goes correctly, you should be able to start and login to Windows.  NOTE: If the computer is in a Domain Environment, you may have to reset the Computer Account in Active Directory.
  8. Let it sit on the desktop for a while (might take a few minutes), it should detect the new drive an prompt for another restart
  9. Once it restarts and you log back in to windows, you may want to install and tools or utilities from the manufacturer of the drive
    NOTE:
    It is very important that you check and correct any errors on the drive before the drive is put to use
Enjoy your new drive!

Command Line Tricks

Some command-prompt tricks

In Bryce’s recent postings on http://www.technibble.com/scripting-your-own-computer-repair-tools-pt4/ he has provided some great information about batch scripting.

In the process, I blurted out that you can chain DOS commands together, but had to recant my statements..

There are several ways to do this, however:

First one is a re-direct:
> Re-direct the screen output to a file like the example:
DIR C: > somefile.txt

What is this doing?  This is taking what is being shown on the screen and re-directing the output to a file called: somefile.txt

Caveat: With one “>” this or any other command re-directed to this file will be over-written each and every time.  If you want to append (add to) the end of the file, just simply double it up:
“>>” like the example:
DIR C: >> somefile.txt

Next is a pipe “|” and is used for things like:
DIR C:\windows | more

Yawn, yeah I know that I can also do:
DIR /p C:\windows

and get the same results..

However, you can pass through things like (Be very careful here, please!!):
ECHO y|DEL C:\somedir\*.txt

So, what this does is to take the y (or yes response) and “pipe” it through the del command.

There are some other things that are a bit obscure that can be done too.  Your mileage may vary..

One command to do two actions..  Let’s see if we can do a Dir on two folders..
DIR C:\windows;”C:\program files”

Note: This is all one command-line command.  Pretty cool huh?  This does a Dir on both the C:\Windows and the C:\Program Files  in one command!!

Two commands to do at a one time..  Hmmm..
Now, let’s try to do two commands in one command from the command-line:
TYPE C:\boot.ini&DIR c:

Note: This is all one command.  This does Type the contents of the boot.ini file and then a Dir on C:\ drive in one command!!  It is important to note that if you do a DIR with an /s, you will traverse (go through all of the directories) in the C:\ drive and you will get a ton of results.

Caveat: If you use this in a batch file, you will need to do the following:
TYPE C:\boot.ini&&DIR C:

Note: the double “&&” to chain these two commands together in a batch file.

Note #2: You cannot do the following with XCOPY, for example..

XCOPY C:\Windows;”C:\Program Files” D:\SomeFolder

New Website Now Live (beta)

Today we started sharing our new site as it is now a pretty functional resource. Aside from looking better, you no longer need a support account to activate offline. In fact you no longer need a separate support account at all. For checking licensing you can do so with your license information.

We’ll be keeping the old site around even after the new site is fully functional as we realize there is some valuable information still there. That said, we have opted to move to a knowledge base system and have been porting all the most common questions and answers over to the new system for the last couple of months. So while, the forum may arguably be a more valuable resource today we will be working to reverse this as we beef up our new support center. We also think many will appreciate our new ticket system for tracking feedback and requests.

Please check it out and let us know what you think. What remains to be done? We still have some graphics to update and plan to migrate our script library to the new layout as well. Also items like online documentation and wizards have not yet been moved over, so if you don’t find what you are looking for at the new site, remember it is “under construction” and kindly refer to our “legacy” website 😉

Script Tab Properties

ImageDid you know that you can right click on a tab and choose “Script Properties” to see information and options for that script? Give it a try! When you right click on a tab and choose “Script Properties” in ASE you’ll see:

  • Full script path and filename
  • The type of document (as ASE identifies it)
  • Word and line count data
  • An option to pop up a dialog to collect a change log entry when the script is closed
  • An option to automatically create a time-stamped backup when the script is closed

Change log entries are inserted into a dynamically updated region called “Changelog” (which will initially be created at the very top of the script). There are some further settings to control change log entries in ASE options listed under “Formatting > Change log” where you may specify the format of the change log entries including control over what categories are offered and optional use of several variables for entering dynamic data within the entry (dates, domain, user, etc.). Finally there is also the ability to globally pop up change log entries on all scripts, with an additional option to help prevent it from being dismissed (requiring the user enter some kind of detail and not just hit OK or Cancel).

ASE Blog Launch

Not really a launch yet, because it is unannounced, but if you’ve found this, welcome to the new Admin Script Editor blog. Here we will share news and tips about the Admin Script Editor . Soon we will be launching a new website, new support portal and ticket system, oh and a little thing we are calling ASE 4.0.