Loading

Subscribe via RSS

Subscribe by Email

Your email:

Do You Tweet Tech?

Are your tweets technology related? If so then we want to follow!
 

Admin Arsenal Blog

Current Articles | RSS Feed RSS Feed

New features in Admin Arsenal 1.5

  | Share on Twitter Twitter | Share on Facebook Facebook | Submit to Digg digg it |  Add to delicious  delicious |  Submit to StumbleUpon StumbleUpon | Submit to Reddit reddit 

We have added some sick features to Admin Arsenal in version 1.5.

My favorite is the ability to extend the Admin Arsenal Tools menu by adding your own Custom Tools. A Custom Tool is a command that exists on the Admin Arsenal console machine. When the Custom tool is selected (either from the Tools menu or a keyboard shortcut that you assign) the command is executed along with any respective command line arguments.

Want to be able to automatically go to the C$ of a target computer? Go to your Admin Arsenal Preferences and, in the Custom Tools pane, add the following line:

Open C$ Share=explorer.exe "\\%TARGET%\C$"

The syntax for a custom tool line is

Name [;keyboard shortcut]=command [ARGS]

Admin Arsenal will contain the computer name in the %TARGET% variable.

If you use DameWare Mini Remote Control, you can have initiate a Remote Control session from within Admin Arsenal by adding a custom tool entry like this:

DameWare Remote Control;CTRL+ALT+Z="C:\Program Files (x86)\DameWare Development\DameWare Mini Remote Control\dwrcc.exe" -m:%TARGET% -a:1

See additonal arguments that can be passed to DameWare Mini Remote Control.

Would you like to automatically connect to a network registry? Feel free to download one of our free utilities called StartReg.exe. Place this file on your Admin Arsenal console machine and add the following line to your custom tools:

Connect Remote Registry;CTRL+SHIFT+E="StartReg.exe" %TARGET%

In the above example I didn't pass the Path for StartReg.exe because I put it in my System32 directory which is, obviously, included in my PATH variable.

Executing your Custom Tools

See a Video example on Admin Arsenal's YouTube Channel

Note: Any download from our Free Utilities is not supported and is provided without warranty of any kind.



PowerShell Tips for System Administrators: Format Views

  | Share on Twitter Twitter | Share on Facebook Facebook | Submit to Digg digg it |  Add to delicious  delicious |  Submit to StumbleUpon StumbleUpon | Submit to Reddit reddit 

Amazing View
Photo by Dave_B_

In two recent posts I went over the PowerShell formatting cmdlets and calculated properties. Today I'm going to cover Views. You'll notice that when you display a normal object (such as the built-in FileInfo objects when you run dir) you don't see all of its properties. This is because PowerShell is using a View, which is selected based on the type of object you're outputting and which type of output is being used (table, list, or wide.)

The views are stored in XML files in the PowerShell directory which you can examine to see how the formatting is being performed. Not only that but you can add your own views and even override the default views used by PowerShell.

The standard views are stored in %systemroot%\System32\WindowsPowerShell\v1.0 in a files with the extension format.ps1xml. There are several files, but the one we'll be looking at is FileSystem.format.ps1xml. This file holds the formatting for the various file system objects, such as FileInfo and DirectoryInfo.  The section that defines the normal file system table output is this:

<View>
  <Name>children</Name>
  <ViewSelectedBy>
    <SelectionSetName>FileSystemTypes</SelectionSetName>
  </ViewSelectedBy>
  <GroupBy>
    <PropertyName>PSParentPath</PropertyName>
    <CustomControlName>FileSystemTypes-GroupingFormat</CustomControlName>
  </GroupBy>
  <TableControl>
    <TableHeaders>
      <TableColumnHeader>
        <Label>Mode</Label>
        <Width>7</Width>
        <Alignment>left</Alignment>
      </TableColumnHeader>
      <TableColumnHeader>
        <Label>LastWriteTime</Label>
        <Width>25</Width>
        <Alignment>right</Alignment>
      </TableColumnHeader>
      <TableColumnHeader>
        <Label>Length</Label>
        <Width>10</Width>
        <Alignment>right</Alignment>
      </TableColumnHeader>
      <TableColumnHeader/>
    </TableHeaders>
    <TableRowEntries>
      <TableRowEntry>
        <Wrap/>
        <TableColumnItems>
          <TableColumnItem>
            <PropertyName>Mode</PropertyName>
          </TableColumnItem>
          <TableColumnItem>
            <ScriptBlock>
              [String]::Format("{0,10}  {1,8}", $_.LastWriteTime.ToString("d"), $_.LastWriteTime.ToString("t"))
            </ScriptBlock>
          </TableColumnItem>
          <TableColumnItem>
            <PropertyName>Length</PropertyName>
          </TableColumnItem>
          <TableColumnItem>
            <PropertyName>Name</PropertyName>
          </TableColumnItem>
        </TableColumnItems>
      </TableRowEntry>
    </TableRowEntries>
  </TableControl>
</View>

If you're not used to XML this may appear a bit daunting, but you can get a quick sense of how it works. There are four main sections of the file.

  1. <ViewSelectedBy> indicates which object types are used by this view. In this case, the name FileSystemTypes refers to another section in the file that lists the types. That section is <SelectionSets>. The individual type names can be listed instead, but this reference makes the code shorter.
  2. <GroupBy> tells the table of files to be grouped by thier parent path. This also refers to another section of the file called <Controls>.
  3. <TableHeaders> sets up not only the titles that appear on the table columns, but also their width and alignment.
  4. <TableRowEntry> the actual values to show in the table. Three of the colums just pull out a property by name, but the LastModifiedTime uses PowerShell code to format the date in a particular way. Any PowerShell code can be used which gives a great deal of flexibility.

There are a lot of possibilities for how to create views and the documentation is a bit limited. To learn about formatting it's best to look at the included format files to see how things are done.

To make a custom view you will need to create your own format.ps1xml files since you can't edit the built in ones. If there is more than one view for an object then the first one found will be used. Otherwise they can be selected by name using the -View parameter of the format cmdlets. Once you have a file created you import the formats using the Format-UpdateData cmdlet. As an example of a new format, I've create a format file that adds a CreationTime column in addition to LastWriteTime. Download the file, save it with the extension .format.ps1xml and run the following command:

Format-UpdateData -PrependPath [filename]

Now when you list the contents of a directory you will see the new column. Alternately you could have used -AppendPath to put the file after the built in formats and then you would need to use the view by name:

dir | Format-Table -View MyFormat

To make the custom format persistent between sessions, add the Format-UpdateData command to your PowerShell profile. One of the principles of PowerShell is the ability for you to configure it to your tastes and Views are a very powerful, if somewhat complex, way to get just want you want.


Need help using formats (or anything else) in PowerShell? Post a question in our PowerShell forum to ask one of our engineers.

Avoid the traffic jam - Remotely Deploy Windows Service Packs

  | Share on Twitter Twitter | Share on Facebook Facebook | Submit to Digg digg it |  Add to delicious  delicious |  Submit to StumbleUpon StumbleUpon | Submit to Reddit reddit 

Avoid the traffic jam!
Photo by Lingaraj G J

We have a client that uses Microsoft SCCM to manage about 1,700 computers. The problem is that 130 of these computers needed to have the U.S. Government Configuration Baseline (USGCB) - formerly known as FDCC - version 2.4. These 130 computers had the 2.1 version of USGCB which still uses Vista Service Pack 1.

Performing the "USGCB Migration" to version 2.4 is a rather cumbersome exercise considering all of the updated applications and OS configuration changes it needs to make. The process (using SCCM) can take a few days even when the SCCM Service Windows are ignored. Many users were experiencing computers rebooting in the middle of the day as a result of the migration.

In an effort to minimize the reboots during the day (all the Migrations were started in the evening but due to SCCM polling and HW scan intervals the migration process always spilled into the work day) we used the new PDQ Deploy to quickly deploy applications that comprised the various parts of the Migration without having to wait for next Machine Policy or Advertisement. We started with the biggest reboot offender, Windows Vista SP2.

We simply ran a query in Admin Arsenal showing all machines that had Service Pack 1 of Vista and then, in the evening, deployed SP 2 with the following arguments:

/quiet /warnrestart:120

Within 3 hours almost all of the 130 computers had successfully installed Service Pack 2. We then deployed another "package" which was simply a CMD file which forced a hardware scan. (This client is not allowed to modify the set schedules that scans are run with SCCM). Using Roger Zander's suggestions the CMD file ran one command which utilizes WMI to initiate an SCCM hardware scan.

WMIC /namespace:\\root\ccm path sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000001}" /NOINTERACTIVE

This was, to say the least, very painless.

Use PDQ Deploy. It is free and fully functional only from Admin Arsenal.


Administering Windows Virtual Disks

  | Share on Twitter Twitter | Share on Facebook Facebook | Submit to Digg digg it |  Add to delicious  delicious |  Submit to StumbleUpon StumbleUpon | Submit to Reddit reddit 

Virtual Disk
    Photo by teclasong

While reading my daily blog roll I ran across a posting at the always informative Train Signal Training blog about VHDs, or Virtual Hard Disks. This really caught my eye as I hadn't heard of this functionality before. Virtual disks have been a part OS X since the beginning (I believe they go back to the NeXT days) and I find them to be very useful. It's great to see this capability now in Windows 7 and Server 2008 R2. The steps to create and use a VHD are a bit more complicated than creating a DMG on the Mac, but that's a small price to pay for the capability.

As usual, I'm interested in the command line options and here Microsoft doesn't disappoint. The DiskPart.exe utility provides all the necessary functionality to create, partition, format, and use a virtual disk. Here's a session that creates a 32 GB disk and assigns it a drive letter.

PS C:\> diskpart
Microsoft DiskPart version 6.1.7600
Copyright (C) 1999-2008 Microsoft Corporation
On computer: AADEV
DISKPART> create vdisk file="c:\test.vhd" maximum=32000 type=expandable
  100 percent completed
DiskPart successfully created the virtual disk file.
DISKPART> select vdisk file="c:\test.vhd"
DiskPart successfully selected the virtual disk file.
DISKPART> attach vdisk
  100 perent completed
DiskPart successfully attached the virtual disk file.
DISKPART> create partition primary
DiskPart succeeded in creating the specified partition.
DISKPART> list partition
  Partition ###  Type              Size     Offset
  -------------  ----------------  -------  -------
* Partition 1    Primary             31 GB  1024 KB
DISKPART> select partition=1
Partition 1 is now the selected partition.
DISKPART> format quick fs=ntfs
  100 percent completed
DiskPart successfully formatted the volume
DISKPART> list volume
  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  ----  -----------  -------  ---------  ------
  Volume 0     D                      CD-ROM           0 B  No Media
  Volume 1         System Rese  NTFS  Partition     100 MB  Healthy    System
  Volume 2     C                NTFS  Partition     127 GB  Healthy    Boot
  Volume 3                      NTFS  Partition      31 GB  Healthy
DISKPART> select volume=3
Volume 3 is the selected volume.
DISKPART> assign letter=V
DiskPart successfully assigned the drive letter or mount point.
DISKPART> exit
Leaving DiskPart...
PS C:\> copy license.xml v:\
PS C:\> dir v:\
    Directory: v:\
Mode                LastWriteTime       Length  Name
----                -------------       ------  ----
-a---         9/08/2010   2:41 PM          418  license.xml

As you can see, it's pretty straightforward to create and use a VHD. You can even install Windows on a VHD and boot to it, which can be very useful for troubleshooting. I love finding a new features that I didn't know about and can explore.


Looking for unattended installation software? Download a free copy of PDQ Deploy.


Software Deployment for Nothing - Introducing PDQ Deploy

  | Share on Twitter Twitter | Share on Facebook Facebook | Submit to Digg digg it |  Add to delicious  delicious |  Submit to StumbleUpon StumbleUpon | Submit to Reddit reddit 

free software deployment toolWe are pleased to announce the newest addition to our product line for Windows System Administrators – PDQ Deploy.

 PDQ Deploy provides a fast, and easy way to meet basic software deployment needs.  And it’s FREE!  With PDQ Deploy you can:

  • Deploy MSI, MSP, MSU, EXE and Batch installers
  • Use with or without Active Directory
  • Remotely deploy to multiple computers at the same time
  • Use different authentication for different deployments
  • Save installations for future use
  • Troubleshoot failed deployments

You can watch an introductory video of PDQ Deploy here.

Our goal is to get PDQ Deploy into as many Sys Admins’ hands, as possible.  So download a copy today and start to see all the things you can do with software deployment.  And did we mention that it’s FREE?!?

Please let us know what you think!  We are always open to your ideas for improving our products.

Follow me on Twitter @ShawnAnderson


PowerShell Tips for System Administrators: Profiles

  | Share on Twitter Twitter | Share on Facebook Facebook | Submit to Digg digg it |  Add to delicious  delicious |  Submit to StumbleUpon StumbleUpon | Submit to Reddit reddit 

Sphinx Profile
Photo by Andrew®

A profile in PowerShell is nothing more than a script file that is run when the shell starts. This file is very handy to create variables, functions, or change settings that you find you use a lot. Instead of having to re-import a library of functions or change the shell's settings each time you start up PowerShell.

The variable $profile holds the name of the file that you are using for the current shell. PowerShell doesn't create this file, so it won't exist out of the box, but the variable will still hold the name. For example, on my box it is:

C:\Users\Adam> $profile
C:\Users\Adam\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

You can put anything in this file that you can put into a script file, so feel free to create functions, set variables and run commands. Any changes made to the file won't be used by the current shell, so you'll need to restart to see any effect. And remember that if you are going to load any other script files in the profile you need to precede the script with a single dot (.) for the functions and variables in that script file to remain visible in your new shell:

. \libs\Functions.ps1

There is also a profile on the computer that applies to all users as well as profiles for other shells. Microsoft has all of the lowdown.


Follow me on Twitter @AdamRuth


PowerShell Tips for System Administrators: Calculated Properties

  | Share on Twitter Twitter | Share on Facebook Facebook | Submit to Digg digg it |  Add to delicious  delicious |  Submit to StumbleUpon StumbleUpon | Submit to Reddit reddit 

In a previous post I went over three cmdlets for formatting data. Each of those cmdlets let you select which object properties you want to show. You aren't just limited to the existing properties on the objects, though, you can use Calculated Properties which let you format the properties in any way you like. The syntax for calculated properties looks a little odd at first, but it's actually quite simple.

For example, this expression displays the time between the creation and last write times of files:

Screen shot 2010 07 16 at 8.36.15 AM

There are a few things here that need explaining:

  • The back-tick at the end of the first line allows you to type in commands on multiple lines, making it easier to read and write long commands.
  • Calculated properties are defined as Hash Tables, which are simple name/value containers. They are created by putting the names and values inside of @{} separated by semicolons.
  • Calculated properties require that the hash table has two values: Name and Expression.
  • The Expression value in the hash table is itself enclosed in curly braces {} which is the way you pass PowerShell script code as a property to a cmdlet.
  • The value $_ inside of the Expression is the object that is being formatted. In the above example it is referenced twice to pull out the two properties CreationTime and LastWriteTime.
  • CreationTime and LastWriteTime are .NET objects called DateTime and they have a number of properties and actions themselves. The example uses the Subtract method which gives the difference between two DateTime objects.
  • The object returned from the Subtract method is called a TimeSpan. It displays as days.hours:minutes:seconds.milliseconds. It also has a number of properties to get these values individually.

As you can see, showing a TimeSpan like that is not the easiest to read. We can display just the days like this:

Screen shot 2010 07 16 at 8.57.06 AM

One PowerShell construct that is very helpful when formatting output is the -f operator. This takes text with embedded placeholders in it and replaces them with formatted values. A simple example:

Screen shot 2010 07 16 at 9.07.16 AM

There are two placeholders which insert the two values (placeholder numbering starts with 0.) Not only can the -f operator insert the given values, but it can also format numbers in a variety of ways. Consider this example:

Screen shot 2010 07 16 at 9.13.09 AM

This example shows the size of each file in megabytes, formatted out to two decimal places. It starts by dividing the Length of the file by 1Mb (which is a built-in PowerShell value handy when dealing with file sizes along with 1kb, 1gb, and 1tb.) This value is then passed to a format placeholder {0:0.00}. The text after the colon defines how the number is to be displayed. In this case, it will show one at least one digit to the left and no more than 2 digits to the right of the decimal. There are many different types of formatting rules you can use, here's Microsoft's documentation for more details.

Once you understand the basics of Calculated Properties, there really isn't any limit to how values can be formatted. Calculated properties aren't just for making output easy to read, but they come in very handy when you need to pass the output of some command to a program that expects things to be in a specific format. Consider using them any time you have to massage data manually.


Need help with PowerShell? Post a question in our new PowerShell forum and get an answer quick.


Modular PowerShell - System Administration Scripting Tip

  | Share on Twitter Twitter | Share on Facebook Facebook | Submit to Digg digg it |  Add to delicious  delicious |  Submit to StumbleUpon StumbleUpon | Submit to Reddit reddit 

One feature of PowerShell that I had a hard time figuring out was how to include one script in another. I have a number of build scripts which build the installers for our products, and there are a lot of steps that are the same between them. Up until recently I was using the proven method of copy/paste to share the functionality, but I finally decided to sit down and take the time to build out my build system properly. 

The first thing I needed to do was to put similar functionality into a library and load it into each product's build script. This library consists of a bunch of functions such as incrementing version numbers, building help files, compiling source code, and digitally signing files. The problem is how to get the functions to be available to other scripts. As you may have noticed, when you run a script none of the functions are available to you after the script ends. Here's me running a script that has a single function called Hello:

In order to make the function in the script last after the script ends, it's necessary to run the script preceded by a period:

With that, all symbols in the script persist and you can create any library scripts you may need.

Once you get to the point where you have enough scripts to make modularity necessary, you are to the point you should consider using some source control (for a primer read my whitepaper on the topic.) 

Have any other PowerShell tips that may not be obvious to everyone? Post them in the comments and share with the world (or the tiny portion of it that reads this blog, anyway.) 


System Administrator Tool Review - Xenu Link Sleuth

  | Share on Twitter Twitter | Share on Facebook Facebook | Submit to Digg digg it |  Add to delicious  delicious |  Submit to StumbleUpon StumbleUpon | Submit to Reddit reddit 

One of the many tasks that system administrators deal with is managing one or more web sites. Over the course of a web site's life it will be moved, reconfigured, or have its structure changed. These changes can easily break links and the nature of the web is that there isn't a way to know a link is broken other than trying it. Not to mention any links to external pages that can break or decay over time, there isn't a way to be notified that a page no longer exists.

Enter Xenu Link Sleuth which is a fast no-frills link checker for Windows generously provided for free by German programmer Tilman Hausherr. I find it to be extremely helpful to periodically run on the web sites that I manage to make sure that nothing has broken. It's even more helpful to run after there have been some changes to the site, such as moving to a new host. 

When you run it you will be presented with the starting point dialog.

 

Here you enter the URL you want to check. Xenu will check all files from this root down, so you can only check a subset if your site if you wish. You can also exclude some URLs from the check and set other options (how many threads to run, types of links to check, and even e-mail yourself a report when it's finished.)

That's it, once you run it you'll get a report back showing what's broken, if anything. Here's the report from the documentation for our new product PDQ Deploy.

 

The documentation contains some links to external resources, so I can know right away if any of them have broken and need to be repaired.  If you've never run a link checker against one of your web sites you might be surprised at how much is broken. It's entropy at work, the system administrators ever-present friend.

I really like Xenu because it's both very fast and very thorough. It's got a very simple interface that doesn't get in your way so you can see what's important very quickly. The only thing that would be nice is if it had a command-line interface for running it as part of a script. But that's a small gripe for such a great tool. 


Windows Admin Tools - Not Every Challenge Is A Nail

  | Share on Twitter Twitter | Share on Facebook Facebook | Submit to Digg digg it |  Add to delicious  delicious |  Submit to StumbleUpon StumbleUpon | Submit to Reddit reddit 

Windows administrators take charge!
Photo by bb_matt

Slashdot writes on the downfall of rewriting applications from scratch. The article references an older article (Things You Should Never Do) from Joel Spolsky written in 2000.

If you're not familiar with Joel I highly suggest bookmarking his blog, JoelOnSoftware.com. 

Though Joel's article focused on developing applications, I'd like to apply it to our jobs as system administrators. Specifically, the tools that we use everyday. 

Too many system admins take the do-it-yourself approach when managing their systems. They have a few tools on which they rely, but as new challenges arise they simply use their old tools. 

When all you have is a hammer everything looks like a nail

I first heard that statement when consulting for an new company. They handled almost all systems management via batch logon scripts. The logon process was several minutes, and the patches did everything from verifying proper hostname to patching systems (this was before WSUS and Active Directory). 

The organization was screaming for a new tools, yet they had one solution for every problem. More logon scripts. 

Hit the pause button (or at the very least the 1/2 speed button) and take a moment to ponder if there aren't faster ways to do your tasks more efficiently. Then find solutions, remembering that you don't need to create from scratch.

You'll find everything from COTS (Commercial Off The Shelf) products, to freeware point solutions. (If scripting is in your arsenal of tools then you can even make a go at automating some of these  solutions.)

Use Joel's logic to your benefit. Make these products work for what you need, or make them better. Just don't remake them from scratch. 

Pstools from Sysinternals are some of my favorite admin tools. They're a free way to get a lot of things done that system admins need. 

Which tools have become indispensable in your daily work?



Follow me on Twitter @ShawnAnderson
Admin Arsenal - a tool for every Windows Administrator.

 

 


All Posts