Archive for July 2007

Forcing Inventory via Deployment Server

Here’s an easy way to force computers to report inventory to Notification Server via a job on Deployment Server:

1. Copy the file AeXWebInvPkg.exe to the client;

2. Copy a batch file to the client to run the executible:

@echo off
echo Altiris is collecting inventory on this computer.
echo Please do not close this window. It will close on it’s own in a moment.
c:\aexwebinvpkg.exe

3. Run a vb script to launch the batch file:

Set sh = CreateObject(”WScript.Shell”)
Set fso = CreateObject(”Scripting.FileSystemObject”)

sh.run “c:\inventory_ns.bat”

Set sh = Nothing
Set fso = Nothing

Since we have a fairly aggressive purge policy in place on NS, I use this script to get computers back quickly after a campus has been offline for the summer.

Configuring SQL 2005 Reporting Services

Just a minor note regarding my experience in setting up SQL 2005 Reporting Services for the first time…

Overall, a very smooth process. I specifically followed the instructions in Chapter 2 of Microsoft SQL Server 2005 Reporting Services (Step by Step), ISBN 978-0-7356-2250-0. There were only a few minor caveats:

1. I installed Reporting Services on an existing SQL 2005 SP2 installation, which meant that I had to go back and rerun SP2 for just that portion of the install before I could configure Database Setup under the Configure Report Server interface.

2. Even after doing this, I got a failure when I chose the option to upgrade the ReportServer DB. The simple fix was to click Apply yet again, and then everything finished like it was supposed to. Guess the DB upgrade had to be in place before the rest of the configuration scripts would run.

And that’s about it. I’ll blog more details about actually using Reporting Services as I get into it in more detail over the coming weeks.

An Altiris Collection to Find Deep Freeze (or Any Other Program)

If you have Altiris, at some point you have no doubt wanted to create a collection based on a program that may be installed on the desktop.  For me, this program was the administrative nightmare known as Deep Freeze, however you can modify the query to reflect whatever program you want to hunt for.

It is important to note that the SQL to build the collection for this is NOT the same as the SQL used to build a report for this, and if you start with a report to find the software and then try to create the collection, you won’t get all the data.  To create the collection statement, I poked around at a SQL level first until I got the desired result set.  At that point I was able to use the query to create the computer collection.

The bold items represent what you would swap out for your own query.

select Guid from vResource where Guid in (select ResourceGuid as Guid from (SELECT DISTINCT
i.[Name],
csw.KnownAs [Product Name],
csw.ProductVersion [Version],
csw.Manufacturer,
i.[Guid] [ResourceGuid]
FROM dbo.vComputer i
JOIN dbo.Inv_AeX_SW_Audit_Software_spt t1
ON t1.[_ResourceGuid] = i.Guid
JOIN dbo.Cmn_SW_Common csw
ON csw.[_KeyHash] = t1.[_KeyHash]
JOIN dbo.Inv_AeX_AC_Identification d
ON d.[_ResourceGuid] = i.Guid
JOIN dbo.CollectionMembership cm
ON cm.ResourceGuid = d.[_ResourceGuid]
JOIN dbo.vCollection it
ON it.Guid = cm.CollectionGuid
/* WHERE csw.KnownAs = ‘Deep Freeze‘ OR csw.KnownAs = ‘Deep Freeze 5‘ OR csw.KnownAs = ‘Deep Freeze 6‘ */
WHERE csw.KnownAs LIKE ‘Deep Freeze%
AND d.[System Type] LIKE ‘Win%’
AND i.[Name] LIKE ‘%’ ) xxx)

Renaming a Win32 Computer in Perl

I can’t take credit for the original write up of this snippet, but sadly it has also been so long that I can’t recall exactly where I got it (I know it was on the web).  Basically what this code will do, assuming you accepted some type of input earlier in your script, is rename an XP computer (whether on the domain or not) and force a reboot.

I’ve only worked with it on XP Pro platforms, so YMMV.

# Connect to Computer
$objWMILocator = Win32::OLE->new(’WbemScripting.SWbemLocator’);
$objWMILocator->Security_->{AuthenticationLevel} = 6;
$objWMIComp = $objWMILocator->ConnectServer($strComputer, ‘root\\cimv2′);
my $objWMICompSys = $objWMIComp->Get(’Win32_ComputerSystem.Name=\” . $strComputer . ‘\”);

# Rename Computer
$intRC = $objWMICompSys->Rename($strNewComputer, $strLocalPasswd, $strLocalUser);
if ($intRC != 0) {
print ‘Rename failed with error: ‘ . $intRC, “\n”;
}
else {
print “Successfully renamed $strComputer to $strNewComputer\n”;
}

print “Rebooting system…\n”;
$colOS = $objWMIComp->InstancesOf(’Win32_OperatingSystem’);
foreach my $objOS (in $colOS) {
Win32::InitiateSystemShutdown( ”, “\nAction Complete.\n\nSystem will now Reboot\!”, 10, 0, 1 );
}

Random Numbers in Perl

Here’s a super simple way to generate a random number in your perl scripts:

srand (time ^ ($$ + ($$ << 15)));
my $random_number = int(rand(30000)) + 55000 ;
print “random = $random_number\n” ;

You can play with the numeric values in line 2 to get the range of numbers you want.