Network Administrator Knowledgebase:

November, 2007

Nov 28 2007   9:08PM GMT

System Center Virtual Machine Manager 2007 Scripting Guide



Posted by: Michael Khanin
Networking, Virtualization

Microsoft, exactly for me :) created a good white paper that I’d like to read:

System Center Virtual Machine Manager 2007 Scripting Guide

A very nice guide of useful script samples for SCVMM - which highlights common tasks:

Adding new Virtual Server hosts.
Configuring new Virtual Server hosts.
Deploying and configuration new virtual machines from the library.
Moving virtual machines between different hosts.

If you are working with Virtual Machine Manager, Must read!

Nov 25 2007   8:38PM GMT

One Line Commands



Posted by: Michael Khanin
Networking, Windows Computing

I’m posting some of my favorite scripts on blog and on my site (http://thesystemadministrator.com). Now, I’d like to show few of “one line commands” scripts. The command entry should all be on one line.

Domain Controllers
Nltest /dclist:%userdnsdomain%

Domain Controller IP Configuration
for /f %i in (’dsquery server -domain %userdnsdomain% -o rdn’) do psexec \\%i ipconfig /all


AD Database disk usage
for /f %i in (’dsquery server -domain %userdnsdomain% -o rdn’) do dir \\%i\admin$\ntds


Nov 23 2007   9:35AM GMT

Content on log files via browser



Posted by: Michael Khanin
Networking

I’ve a client that runs special program on about 100 servers. This program writes a log on central server every 3 minutes. So, when I checked main server, I found a directory Logs (C:\Logs). Log’s directory contains many log files (each log for each server).  On this server installed and runs a web server, Apache ;). So, I’d like to show a small AppsRuns.php file, which stored on web server. If we go to the http://server1/AppsRuns.php we will see a content of each log file on one web page. This web page refreshing every 10 sec. Here is a content of AppsRuns.php file:

<?php
    $refresh_time = 10; // seconds
    $path = “C:LOGS”;

    header(”Content-Type: text/plain”);
    header(”Refresh: $refresh_time”);

    if($handle = opendir($path)) {
    while (false !== ($file = readdir($handle))) {
        $pi = pathinfo($path . ‘/’ . $file);
        if($pi[’extension’] === ‘txt’) {
        include($path . ‘/’ . $file);
        }
    }
    }
?>


Nov 17 2007   8:22AM GMT

Updates: Free Deployment System Scripts



Posted by: Michael Khanin
Microsoft Windows, Networking

I have made a small change in my “Free Deployment System“, the set of script allows to deploy, install or run applications on any remote computer.
Equally, I just added a few new lines. In to Config.bat added a new line:

set DSRV= 192.168.211.1

By using a DSRV environment i can set IP or Computer Name of my Deployment Server.
Also, added two new lines to the INSPKG.bat script (Script in original article already changed, so you can simply take a changed script). One of new lines contains following:

%Tools%psexec.exe \%RCOMP% -u %USR% -p %PASS% -i cmd /c md C:Updates

This line creates a directory C:\Updates on remote computer. I use C:\Updates on remote computer to copy there necessary scripts and source of installation programs. The other new line in INSPKG.bat is:

@echo set DSRV=%DSRV%> \%RCOMP%C$updatesconfig.bat

As you can see, by this line I create a config.bat file on remote computer and put in to environment, that sets a name or IP of our deployment server. Additionally, we need to change a package script. So, after changes, our package script looks like follow:

@echo off
call c:updatesconfig.bat
\%DSRV%packages7ZIP7z442.exe /S

So, now, if we are changed our deployment server, we have not to change our packages script.


Nov 16 2007   12:23PM GMT

Microsoft Application Virtualization Version 4.5 Beta Now Available



Posted by: Michael Khanin
Microsoft Windows, Virtualization

Microsoft Application Virtualization, formerly known as SoftGrid Application Virtualization, is the first Microsoft-branded release of this product. Microsoft Application Virtualization is now available in a public beta on Microsoft Connect and will become generally available through the Microsoft Desktop Optimization Pack and Terminal Services in the third quarter of calendar year 2008.


Nov 16 2007   11:54AM GMT

MTEE Commandline Standard Stream Splitter - sends any data it receives to the console and / or to any number of log files



Posted by: Michael Khanin
Microsoft Windows, Windows Computing

For me and my clients I create many scripts to simplify daily Administration tasks. Many of this script should be running from a command line ( cmd. exe). It’s very easy to run any script and to get a result of it to the log file. But, if you would like to run script and watch the result on the screen and in same time you need a hard copied log, you can use a MTEE command line utility. Mtee is a commandline utility that sends any data it receives to the console and to any number of files. Useful if you want to watch and record the output from a batch file or program.

Mtee is an 11kb standalone executable. There is no installation procedure, just run it.
Mtee is simple to use and only has several options. To list them, type mtee/?

You can download Mtee from offisial web site by following to the http://www.commandline.co.uk/mtee/index.html


Nov 16 2007   7:16AM GMT

Top 5 Exchange Server 2007 Security Best Practices



Posted by: Michael Khanin
Exchange

Few days ago, on Microsoft TechNet’s web site published a very good article “Top 5 Exchange Server 2007 Security Best Practices“. I really recommend to read it.


Nov 15 2007   8:15AM GMT

Windows Server 2008 pricing



Posted by: Michael Khanin
Microsoft Windows, Virtualization

Earlier this week at TechEd IT Forum in Barcelona, Microsoft announced pricing, packaging and licensing options for Windows Server 2008, which includes Microsoft’s server virtualization technology Hyper-V, previously code-named “Viridian.” The new packaging outlined in the announcement includes eight new versions, three of which include Hyper-V. For a rundown of the pricing, see the press release. In addition, Microsoft announced Hyper-V Server, a standalone hypervisor-based server virtualization product that complements the Hyper-V technology within Windows Server 2008, allowing customers to consolidate workloads onto a single physical server.


Nov 14 2007   3:40PM GMT

Free Deployment System



Posted by: Michael Khanin
Microsoft Windows, Networking, Windows Computing

All Network Administrators at least once thought about how to install a program on remote computer without ever touching it. Hopefully, today we have a lot of ways to achieve this goal. The very interesting part of it all is, when ever I provide a consulting services to companies, I hear the same question, “Michael, do you know any FREE solutions to distribute programs, patches or run anything on remote computers?

I’d like to show you the solution, I’ve created for myself. Let’s call it “Free Deployment System :)”…

Free Deployment System” contains a set of scripts and free tools. The heart of this system is a PSExec by Sysinternals.

Before I start, let’s clarify few pre-requirements. We need one server or computer that will hold off packages and scripts. The Deployment System will run on this system. We need a user with administration privileges on all remote computers (We can create a user on Domain level and set the necessary permissions to this user).

Ok, now we are ready to start.

Let’s created a directory structure on deployment server.

C:Operation
 |_Scripts
 |_Tools
 |_Packages

In my situation, I don’t have any files in C:\Operation directory. In C:\Operation\Tools directory I have tools that I have been using in my scripts. The main scripts of “Free Deployment System” are located in C:\Operation\Scripts. C:\Operation\Packages contains packages for remote installation. Set a Share on the C:\Operation\Packages and give all users Read Permissions.Now we need to create a few files in C:\Operation\Scripts directory. The first file is #Servers.txt. This file contains an IP addresses or Computer Name of remote computers. Each IP or name should be on new line. In my case #Servers.txt looks as follow:

192.168.3.95
192.168.3.96
192.168.3.97
192.168.3.98
192.168.3.99
192.168.3.10

The next file in our system will be a Config.bat. By using Config.bat I set credentials for connection to remote computers. Config.bat looks as follow:

@echo off
set DM=AdminInfo
set USR=TSAADMIN
set PASS=TSAPassWord

OK, now we are going to create a main script of our system. I named it INSPKG.bat, meaning “Install Packages”. Before show the content of INSPKG.bat I’d like to say a few words about how it works.

INSPKG.bat runs in loop and checks each line of #Servers.txt file and use this addresses as a destination where the installation package should be installed. When the package installed on last computer (last line in #Servers.txt file) INSPKG.bat will stop working. If you have too many computers in your network, the package deployment could take time, be patient. So, INSPKG.bat contains the following lines:

@echo off

Rem *****************************************************************************
Rem *       For 1 envirement use the Pakage file name                           *
Rem *       The general location of all Pakage is: C:OperationPackages        *
Rem *       On remote computer computer should be located  “C:Updates”         *
Rem *                                                                           *
Rem *       Websites:  http://thesystemadministrator.com                        *
Rem *                                                                           *
Rem *****************************************************************************

if {%1}=={} @Echo Please set the Pakagename.The format is INSPKG.bat 7Zip &goto :EOF

set Scripts=C:OperationScripts
set Tools=C:OperationTools
set Packages=C:OperationPackages

call %Scripts%Config.bat

SET IP-SRV=
SET LoopNum=
SET Line=
SET I=
SET RCOMP=
SET Line=0

TYPE %Scripts%#Servers.txt > %TEMP%SRVLIST.txt

FOR /F “TOKENS=*” %%a in (’%Tools%LINEX -c ^<%TEMP%SRVLIST.txt’) do set IP-SRV=%%a
SET /a LoopNum=%IP-SRV% + 1

:LOOP1
SET /a I=%I% + 1
SET /a Line=%Line% + 1
IF “%I%”==”%LoopNum%” goto END
FOR /F “TOKENS=*” %%a in (’%Tools%LINEX -l %Line% ^<%TEMP%SRVLIST.txt’) do set RCOMP=%%a

copy “%Packages%%1%1.bat”  “\%RCOMP%c$Updates\” /Y

@echo Please wait …

%Tools%psexec.exe \%RCOMP% -u %DM%%USR% -p %PASS% -i C:Updates%1.bat

SET Line=%Line%
goto LOOP1

:END
SET IP-SRV=
SET LoopNum=
SET Line=
SET I=
SET RCOMP=
SET Line=

INSPKG.bat should run from a console (cmd.exe) of our deployment server. The format is following:

C:OperationScriptsINSPKG.bat 7Zip

Where, 7Zip is a name of a package. As you can see, in this example, I’m going to deploy a 7-Zip to all computers, but before this I have to create a package. So, for this purpose I’m going to the C:\Operation\Packages directory and create a new directory, 7ZIP. Inside 7ZIP I create a file 7ZIP.bat and put the installation file of 7-Zip. I’m going to install a 7z442.exe on all computers. By using RTFM rule :), I know that to install a 7-Zip in silent mode I have to use switch /S. So, my 7Zip.bat contains the following lines:

@echo off
\192.168.3.39packages7ZIP7z442.exe /S

Note: Change 192.168.3.39 to the IP or name of your Deployment Server.

And, on the final, we need put necessary tools to the C:\Operation\Tools directory. Download last version of PSExec and put it to C:\Operation\Tools directory. In INSPKG.bat I’m using a very cool tool, LINEX.EXE. Linex.exe is a part of “Bill Stewart’s freeware Batch Script Tools”. When I wrote this article, I tried to find an official web site of “Bill Stewart’s freeware Batch Script Tools”, but failed. So, you can download a Linex.exe directly from my web site.As additional example, I’ve created packages for Acrobat Reader and Firefox.  Keep in mind to create a separate directory for each package. The Directory and name of package script should be the same, meaning if you are going to create a package for Firefox inside C:\Operation\Packages create directory Firefox and inside C:\Operation\Packages\Firefox create a script Firefox.bat and also inside C:\Operation\Packages\Firefox put the installation file of Firefox. Here is my Firefox.bat:

@echo off
\192.168.3.39packagesFirefoxFirefoxSetup2.0.0.9.exe -ms 

Note: Change 192.168.3.39 to the IP or name of your Deployment Server.

I hope I didn’t forgot anything :) .
Let me know what kind of package you are interesting in and I’ll try to create it. I’ll be very happy if you write comment for this article.


Nov 11 2007   6:01PM GMT

Sysinternals tools have been updated



Posted by: Michael Khanin
Microsoft Windows, Networking

Sysinternals Tools have been updated. PSExec v1.90 improves handling of arguments, BgInfo v4.12 offers improved reporting, Process Explorer v11.04 fixes a memory leak, ADExplorer v1.01, DebugView v4.72 and Process Monitor v1.26 fix some minor bugs.