Pages

Monday, December 19, 2011

Reset Admin Password in ManageEngine Password Manager Pro

After a great weekend with IBM resold Netapp SAN issues we needed to login the Password Manager Pro with the local admin account. For what ever reason the password we thought it was didn't work so we needed to reset it. We couldn't have it email us the the password reset as email was down aswell. Like i said, fun times.

In the the long run we got everything back up but until then we did we didn't have access to our password vault. I felt this was my fault. I did manage to migrate the software to another host to attempt to get access to it with out corrupting our main install. I put in a request to ManageEngine but didn't get a response till Monday. Incase I or someone else is ever in that situation here is the method I recieved from ManageEngine to reset the local admin password.

WARNING: This method can be used the hack your backup or instance or Password Manager Pro; like all things if someone has access the the raw files or phyiscal access to your machine they have acccess to the data within.

  1. Copy the attached resetpasswd.txt in the \scripts directory and rename the file name as resetpasswd.bat
  2. Open the file  \conf\database_params.conf and note the MySQL password present in the file (call it 'mysqlpassword')
  3. Ensure that PMP Service is running
  4. Go the \scripts directory using command prompt
  5. Execute the script as resetpasswd.bat (For ex : resetpasswd.bat jzEAa12TVX )
  6. You can now login to the application using admin / admin (local authentication).

Here is the contents of the attached file "resetpasswd.txt" which is all one line.

..\mysql\bin\mysql.exe -u root --port=2345 --password=%1 passtrix -e "update AaaPassword set PASSWORD='Ok6/FqR5WtJY5UCLrnvjQQ==' , SALT=12345678,ALGORITHM='MD5' where PASSWORD_ID=1"

Good Luck and may you never need this.

Wednesday, November 2, 2011

How to reinstall NetBT Service on Windows XP

Recently a past boss asked me to look at a laptop running Windows XP Service Pack 3 that he had issues with virus's and malware. The user's is an older gentalman and really didn't want Windows 7 or his machine rebuilt. While I'm not normally a desktop tech any more I was happy to help. Figuring it'd only take a hour; I doomed my self to complicated problem with out an easy fix.

I mounted the hard drive to a computer with Microsoft Forefront and started a full scan which found many virus's. I just auto checked remove on all of them and rebooted into safe mode. After I had booted into safe mode to run malwarebytes only to find the machine couldn't connect to the network.

"DHCP" Service wouldn't start because of missing dependency.

While not not sure what virus cased it started looking at DHCP Dependencies: Tcpip, Afd, NetBT.

I wish I could say it was then I noticed that the NetBT service was missing entirely from the machine at this point. But can not as instead I started digging to AFD service. After no luck even remotely messing with AFD I noticed that NetBT didn't even exist any more. It was gone.

"C:\Windows\system32\drivers\netbt.sys" was missing as well.

Searching Google for how to re-install NetBT was at best unhelpful. I found many posts talking about settings and file restore. But no posts on how to completely restore the service if it was gone.

As such here's how I did it.
  • Obtain  and place a copy of "C:\Windows\system32\drivers\netbt.sys" in that path. If its missing and no local backup exists you can download the correct service pack the machine is running and extract the service pack and then from the i386 folder. It will be named netbt.sy_ so copy it and then rename it to netbt.sys.
  • I exported the Registry service for NetBT from another machine running Windows XP Service Pack 3 and imported into the machine to replace the missing NetBT service.
    • HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\NetBT

Thursday, September 1, 2011

Sorry for the long delay in posts, Fall Sysmester was starting last week and several projects took up all of my time. The good news is I have alot of Powershell Scripts my brother and I wrote to automate a 600+ VM VMware deployment we did for our College of Informatics that I'll be sharing in future posts, as well as some IBM N Series follow posts to share in our pain.

To everyone that has emailed me and failed to get a response I'll be going through them today, keep emailing and i'll try to respond as fast as I can.

Thursday, July 14, 2011

Windows 7 Printers Stack when the Same Driver is Used

I was working with VMware View today and ran into a odd problem with Pharos Uniprint when I adding printers. I would run the installer to add a printer and it wouldn't be in the printer list. I could refresh the list and sometimes it would appear? I looked at the registry and found both printers to be installed but only one showing. I figured it was a problem with some of my pharos packages so i narrowed it down to two printers that seemed to be the only ones of the 8 that had the problem.

Here is a look at the printers listed in the registry and those displayed to the user.
Notice that the user can't see SL100 in order to print to it despite the fact that its installed. Knowing Pharos so well I assumed that it had an issue with its package installers and rebuilt them top to bottom. I cleared the modules and driver packages and recreated everything. But still on the clients everything remained the same; not working.

Odd enough however when you right clicked the printer it would display options for both printers.
Looking closer both printers use the same Port : PharosPopupPort  and used the same driver. Leaving Windows to make the assumption that the where in fact the same printer.

http://www.thewindowsclub.com/list-printers-using-the-same-printer-driver-seperately-in-windows-7

Wednesday, June 29, 2011

Set vino (Gnome Remote Desktop Settings) from the command line

Trying to configure Linux VMs for students today i found it was difficult to configure the Remote Desktop Settings from a script. I finally found the information in other places but it was spread out and difficult to find. By default the Remote Desktop found in many distro's can be configured graphically under Preferences -> Remote Desktop.

However to configure it from the command line you must run the following as root.

gconftool-2 --set --type bool /desktop/gnome/remote_access/enabled true
gconftool-2 --set --type list --list-type string  /desktop/gnome/remote_access/authentication_methods '[vnc]'
gconftool-2 --set --type bool /desktop/gnome/remote_access/prompt_enabled 0
gconftool-2 --set --type string /desktop/gnome/remote_access/vnc_password $Base64encodedPassword

The $Base64encodedPassword is just a base64 encoding and its easy enough to do.

Links

Tuesday, June 28, 2011

How to SSH from PowerShell using Putty/Plink

Today working with my brother we needed to automate some administration of some Linux VMs for Students. The goal was simple enough, in a PowerShell script create the Linux VMs, Power it on and then SSH into it to configure Linux and create student account on their VM.

Its an odd project that is sort of last minute but we think we can script a solution for the college faculty. One of the assumed easy features of this plan was to SSH into the Linux VM from PowerShell. But surprisingly their didn't a appear to be any easy solutions. The two options available appeared to be:

SharpSSH - I tried to use it but could only get the following error:

Exception getting "formatValueList": "Microsoft.PowerShell.Commands.Internal.Format.FreeFormatEntry.formatValueList"

And /N Software NetCmdlets which is a paid solution i don't have access to and didn't find very good usage on. Lastly I found that it appears best to use plink.exe. Plink comes with putty and is the command line only version of putty. The result being you can pipe your command and through plink however you first have to accept to trust the host key. That a problem because despite all my attempts I couldn't find a command parameter to allow it to accept the host key. Here is the prompt.

C:\Program Files (x86)\PuTTY>plink -ssh username@host -pw password  
The server's host key is not cached in the registry. You ave no guarantee that the server is the computer you think it is.  
The server's rsa2 key fingerprint is:  
ssh-rsa 2048 8e:39:5f:6e:6d:80:77:50:6e:39:b0:c1:13:98:ab:c1 
If you trust this host, enter "y" to add the key to PuTTY's cache and carry on connecting. If you want to carry on connecting just once, without adding the key to the cache, enter "n".
If you do not trust this host, press Return to abandon the connection. 
Store key in cache? (y/n)  

However I worked out a solution, it isn't pretty but it works well.

Using " Echo y " and piping that to the plink it will accept the host key, but keep entering y over and over. The solution is to then pass the command exit to plink which will logout the ssh session the second it gets logged in. With that the host key is cache and trusted. How simply plink again with out the "echo y"

ehco y | plink -ssh username@host -pw password exit

plink -ssh username@host -pw password ls

Below is the PowerShell script that will allow you to pass multiple SSH commands at once. Comment if you have questions or ways to improve this.

test

Function Invoke-SSHCommands {
 Param($Hostname,$Username,$Password, $CommandArray,
  $PlinkAndPath,
  $ConnectOnceToAcceptHostKey = $true)

 $Target = $Username + '@' + $Hostname
 $plinkoptions = "-ssh $Target -pw $Password"

 #Build ssh Commands
 $CommandArray += "exit"
 $remoteCommand = ""
 $CommandArray | % {
  $remoteCommand += [string]::Format('{0}; ', $_) 
 }

 #plist prompts to accept client host key. This section will
 #login and accept the host key then logout.
 if($ConnectOnceToAcceptHostKey)
 {
  $PlinkCommand  = [string]::Format('echo y | & "{0}" {1} exit',
   $PlinkAndPath, $plinkoptions )
  #Write-Host $PlinkCommand
  $msg = Invoke-Expression $PlinkCommand
 }

 #format plist command
 $PlinkCommand = [string]::Format('& "{0}" {1} "{2}"',
  $PlinkAndPath, $plinkoptions , $remoteCommand)

 #ready to run the following command
 #Write-Host $PlinkCommand
 $msg = Invoke-Expression $PlinkCommand
 $msg
}

$PlinkAndPath = "C:\Program Files (x86)\PuTTY\plink.exe"
$Username = "remoteshell"
$Password = "pa$$w0rd"
$Hostname = "Linuxhost"

$Commands = @()
$Commands += "ls"
$Commands += "whoami"

Invoke-SSHCommands -User $Username  `
 -Hostname $Hostname `
 -Password $Password `
 -PlinkAndPath $PlinkAndPath `
 -CommandArray $Command

Wednesday, June 8, 2011

OleAut date did not convert to a DateTime Correctly

Some times I at least make stupid mistakes that generate errors that don't generate any search results in Google.

Today this happened while porting to C# a Powershell script I had written that generates some Charts showing VMware View statistics. While trying to use "DataManipulator.InsertEmptyPoints"  I have the following code:

Chart_ViewSessions.DataManipulator.InsertEmptyPoints(1, IntervalType.Hours, "*");

When Run in debugger it was throwing the following System.ArgumentException.

"OleAut date did not convert to a DateTime correctly."

I tested the Powershell and it runs fine so searched Google but nothing with that error really came up. If I  comment the line out and everything runs but doesn't stack the columns correctly as the Chart is a StackedColumn. After about 10 minutes with no luck i finally realize I added the data points after the I had called InsertEmptyPoints. The problem all along was because I had it trying to Convert a DateTime on No Data Points.

So here a reminder to stop and think about the order your doing things if the error doesn't make sense.

Tuesday, June 7, 2011

Using Local Solid State Drives to provide VMware View Storage

While Implementing Vmware View on campus we're looking at what hardware and storage to use or purchase. In our current Vmware environment we have a mixture of technology due to migration from one to another.
  • Server Hardware:  we currently have a mixture of Large Dell and IBM hosts and half a rack of Cisco UCS.  
  • Storage Hardware: we have/had IBM sans, EMC sans, Equallogic, and now IBM N Series (read Netapp with out support).
Note: You would think the answer would be simple, just use the NetApp with the PAM cards it has but we've had very bad performance  and currently a 4 Month Support call with IBM with no solution in sight. So such we're not wanting to add to the IOPS load of the Netapp.

Our View Enviroment looks to be growing to the 1000 VM Range however these are non-persistent VM's that are refreshed on logoff for student use.

While researching Pivot3's vBank I started researching Solid-State Storage(SSD) for VMware figuring anyone trying to speed up the IOPS for Vmware View was just going to stick the Replica on a SSD anyway and ideally a SSD local to the VMware host. 

This lead me to reading Brian Madden's Post on the pretty much my same conclusion on View and SSD's. Anyway a commenter on his post, Lance Hundt, gave a link to VMware Reference Architecture for Stateless Desktops. Following that Document I found a more detailed really great Vmware PDF on how to actually do this with Local Solid State Drives. 


Once you read this it because so clear, but the normal Vmware ESX mental rules get in the way. Normally Local  ESX storage is useless, we don't use it nor want it. This idea flips that on its head.

If you only had local really fast SSD's for storage everything would be really really fast. However the SSD's don't have much storage space because their two expensive. Not a problem however because the Stateless VM's are replica's and don't use much space. The idea seems sound to me but there is a added management cost when you take a host down and put it in maintenance mode, you first have to do some manual housekeeping.

I wish I provide more detail on this but I haven't been able to talked to anyone doing this yet but would be curious if any has. I'll update this post if I put together some SSD's to try it with and update this post if I do.



Friday, June 3, 2011

VMware View Composer has a maximum of 8 Hosts Per Cluster

Last week we added some Cisco UCS Hosts to our Vmware environment with out any real problems. Then today using Vmware View tried to compose some additional View VMs.

Instead of provisioning them I instead get the following error.


VMware.Sim.Fault.TooManyHostsInComputeResourceFault: Resource pool MoId = resgroup-133, cluster MoId = domain-c132, numHosts = 16, maxHosts = 8

Looking into the VMware.Sim.Fault.TooManyHostsInComputeResourceFault I find a Vmware forum post stating that "The limitation is around Composer and you can only  have a maximum of 8 Hosts per Cluster".  Hoping this was simply a mistake or changeable I looked into it further. It seems to be unchangeable rule that you have to deal with.


From this Vmware Admin Guide they state that the cluster must have 8 or fewer hosts.

NOTE   Only clusters of 8 hosts or fewer are supported and shown.

Links

Wednesday, June 1, 2011

Switching Windows 7 Build to use AHCI

This is a common problem but I figured I reference in order to switch a Windows 7 image from using the PCI IDE Controller driver to using AHCI boot driver.

If your image, (Ghost or otherwise) boots and starts windows loading then reboots. That or it may come up with the blue screen error code 0×0000007B. Which one it comes up with depends on if the BIOS is set to AHCI drives or SATA.

This can be caused by incorrect Hal but it may be be the Driver. If you have the original machine you pulled the image from make this change to the AHCI change in the registry.

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\msahci]
“Start”=dword:00000000



HOW TO: Switch to AHCI boot driver in Windows 7 after install

Then repull that image and push to the hardware before that had issues loading it.

Details
In my case a Windows 7 Ghost image made for a Dell GX620 would boot when cloned to a GX760. I deployed the image to a VMware VM with an IDE drive, made the registry change listed above, pulled a image of it and deployed it to the GX760 which now boots correctly but needed additional drivers.

Modifying the Registry on the machone already imaged.
I'm not sure if this works but I worked out from this link that it may be possiable to simply use the recovery console to load the registry hive on the not booting drive.


  • Using Recovery Console get the a Command Line Prompt
  • Open the registry editor: regedit
    • Note: This loads the registry editor with a temporary registry, not the windows registry from the hard disk.
  • Select HKEY_LOCAL_MACHINE in the registry tree, and go to the File menu and choose "Load Hive"
  • Open the registry hive file SOFTWARE from the location: C:\Windows\System32\Config
    • Give it a random name different to any of the existing names (the name doesn't matter).
  • Make the necessary changes to the registry hive.
  • Select the registry hive you edited, go to File, and choose "Unload Hive".
  • Then exit the recovery console and restart. The registry should have been changed.


Thursday, May 19, 2011

You can Stop using Microsoft.Passport.RPS for Live@EDU SSO

A year or ago I had written a site that used the Microsoft.Passport.RPS.dll to do a SSO Login to Live@EDU all done with "Microsoft Live@edu SSO 4.1". This week I started to port this to a .Net 4.0 Web Site using Forms Based Auth however any LiveRPS Class calls to Microsoft.Passport.RPS.dll version 5.5.4177.0 returns this error.

Retrieving the COM class factory for component with CLSID {01732742-D1A2-11D7-99EB-505054503030} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).


Server was Windows Server 2008 R2 with rps64.msi and could run the SSOPortal that ships with "Microsoft Live@edu SSO 4.1" sucessfully.


Digging into this error message I didn't find much, forums with hints that it was having trouble calling the 64bit dll. After looking for a hour or so I deiced that i would just find an updated version and try that of the rps64.msi that I orginally installed. No luck there either. I found references to a version "6.0.5286.0" of Microsoft.Passport.RPS but had no luck in obtaining a copy of it. 


I then looked for a newer version of the entire Windows LiveID SSO Kit but again had trouble finding a link to it. The solution was that I had to login to https://eduadmin.live.com/ Service portal as the specific admin account for that domain. Then and only then could I act like I was signing up for the SSO Tool Kit and download "Microsoft Live@edu SSO 4.3" . The new 4.3 version doesn't even use the Microsoft.Passport.RPS.dll and works perfectly from ASP.Net 4.0. The LiveRPS class is just a URL link in SSO 4.3.

All and all I have everything working but it really shouldn't of taken the two hours to find the download and  solution from Microsoft.


Monday, April 25, 2011

ASP.NET Forms Based Authentication with Active Directory

If you've ever used Visual Studio's 2010 the default template for an ASP.NET Web Site is a really nice. It allows you to give users accounts based on SQL accounts it creates. I however wanted to use Active  Directory instead of SQL and do the user authentication there instead of setting it on the entire IIS site. This also allows you to have a much prettier login page rather than the normal web browser's "basic access authentication" prompt.

I figured that changing the ASP 4.0 WebSite to use Active Directory would be be a GUI wizard to do it but found a large amount of confusion on the subject when I was researching how. After Figuring it out for myself I figured I'd write a guide on how.

Setup your machine
Serveral of the problems I observed were people had problems with their website and Visual Studio install before they even started with change the website to use AD. Start by creating a WebSite from the "ASP.NET Web Site" using .Net Framework 4. Don't make a single change and build and run the project. Does the site come up. Can you register a user account and then login to that user account. If not don't proceed any further till you can.

The cause for this for many people was that the website went to use the SQLEXPRESS instance only to find that it wasn't installed or running. As a result you'll get the following error from IIS.

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

Changing the Template to use Active Directory
Nearly everything nessory is done in the web sites root web.config file. Below is a copy of the complete file.

  • Add connectionStrings "ADService" to domain your going to use. example "LDAP://nku.edu" (note i tried to alter this to use )
  • Notice that we remove the AspNetSqlMembershipProvider and added AspNetActiveDirectoryMembershipProvider. 
  • Making sure to set AspNetActiveDirectoryMembershipProvider as the default membership provider.
  • Setting attributeMapUsername to sAMAccountName 


<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
 <connectionStrings>
  <add name="ADService" connectionString="LDAP://Domainname.com"/> 
  <add name="ApplicationServices" 
         connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" 
         providerName="System.Data.SqlClient"/>
 </connectionStrings>
 <system.web>
  <compilation debug="true" targetFramework="4.0">
   <assemblies>
    <add assembly="stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
      </assemblies>
    </compilation>
  <authentication mode="Forms">
   <forms loginUrl="~/Account/Login.aspx" timeout="2880"/>
  </authentication>
  <membership defaultProvider="AspNetActiveDirectoryMembershipProvider">
   <providers>
    <clear/>
    <!-- <add name="AspNetSqlMembershipProvider" 
             type="System.Web.Security.SqlMembershipProvider" 
             connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/"/> -->
    <add name="AspNetActiveDirectoryMembershipProvider"
             type="System.Web.Security.ActiveDirectoryMembershipProvider,  System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
             connectionStringName="ADService" 
             attributeMapUsername="sAMAccountName"/>
   </providers>
  </membership>
  <profile>
   <providers>
    <clear/>
    <add name="AspNetSqlProfileProvider" 
             type="System.Web.Profile.SqlProfileProvider"
             connectionStringName="ApplicationServices"
             applicationName="/"/>
   </providers>
  </profile>
  <roleManager enabled="false">
   <providers>
    <clear/>
    <add name="AspNetSqlRoleProvider" 
             type="System.Web.Security.SqlRoleProvider" 
             connectionStringName="ApplicationServices"
             applicationName="/"/>
    <add name="AspNetWindowsTokenRoleProvider"
             type="System.Web.Security.WindowsTokenRoleProvider"
             applicationName="/"/>
   </providers>
  </roleManager>
 </system.web>
 <system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
 </system.webServer>
</configuration>



We also want to create content where the user has to be authenticated to view. Create a new folder to the project. , i called mine "Content". Then add a new item to the folder, selecting "web config". Alter the new web.config to match below.

<configuration>
    <system.web>
      <authorization>
        <!-- deny = ? means deny unauthenticated users -->
        <deny users="?"/>
      </authorization>
    </system.web>
</configuration>

This means that any content inside this folder requires the users first be authenticated before they can access. Any link to this content will first prompt an unauthenticated user to login and then be redirected to the linked content.


Cleanup
There were a several pages and links we can remove as the aren't used since we are using AD to authenticate via forms based authentication. You could comment them out if you ever want to switch back to SQL based users.
  • Remove the "Register User" hyperLink from Login.aspx and delete the Register.aspx file.
  • Change the Site.Master using   we change the tabs users can see depending on if they are logged in or not.
Source
I've included a Visual Studio 2010 Project using Framework 4 that may be useful to view how it works and the changes I made.

Download  - Web Site Using AD Forms Based Authentication

Pictures showing the user Login


Anonymous User Viewing the Site

User accessing Login Page or Content that requires Login
Authenticated User Viewing Site

Links
http://stackoverflow.com/questions/895002/asp-net-active-directory-membership-provider-and-sql-profile-provider/5779884#5779884
http://www.howtodothings.com/computers/a792-aspnet-forms-authentication-with-roles.html
http://msdn.microsoft.com/en-us/library/ff648341.aspx#paght000012_step1


Microsoft Word printing from command line

All Testing was done using Office 2010 64bit.

Make Sure background printing is enabled in word. On the Tools menu, click Options, and then click the Print tab. Under Printing options, ensure that Background printing check box is checked.

cd C:\Program Files\Microsoft Office\Office14
winword "c:\file.BAT" /q /n /mFilePrintDefault /mFileExit

Change to the folder of your office installation.
Command Line parameters to pass to Word.

/q - Start Word without splash screen.
/n - Start Word without a document being open.
/m(MacroName) - Start Word and run the named macro. The windows macro commands FilePrintDefault and FileExit do exactly what they say. Also there is no space between the /m and the macro name.

To get a list of macros open word, on the right hand side of the View tab of the ribbon bar there s a Macros button. Click it and change the "Macros In" dropdown box to Word Commands.
Word 2010 Macros
If you need more control you can modifiy a Macro with the printing settings you need.

Create macro for the globe settings.


Sub FilePrintToPrinter1()
    ActivePrinter = "Pritner1"
    Application.PrintOut _
        FileName:="", _
        Range:=wdPrintAllDocument, _
        Item:=wdPrintDocumentWithMarkup, _
        Copies:=1, _
        Pages:="", _
        PageType:=wdPrintAllPages, _
        Collate:=True, _
        Background:=True, _
        PrintToFile:=False, _
        PrintZoomColumn:=0, _
        PrintZoomRow:=0, _
        PrintZoomPaperWidth:=0, _
        PrintZoomPaperHeight:=0
    Application.WindowState = wdWindowStateMaximize
End Sub


Now calling the this macro would be.
winword "c:\file.BAT" /q /n /mFilePrintToPrinter1 /mFileExit

Links
http://www.robvanderwoude.com/printfiles.php
http://www.autohotkey.com/forum/topic10600.html

Friday, April 22, 2011

Vmware View Windows 7 Optimizations

My brother Patrick pointed me to the new VMware Optimization guide for Windows 7 and I've been updating our VMware View Images to follow it. Its really impressive how much it helped lowering the IOPS our View Virtual Machines where using. While I have personal optimizations i already used I compared a un-optimization Virtual Machine with Windows 7 and all our Lab software and compared it to itself  after the VMware list of optimizations.

I used Resource Monitor to view the Disk I/O activity with in a freshly booted VM and directly after logging in. I could get much more scientific in my measuring but the results really drastic enough to make updating any VM worth the changes. I used Perfmon to get a longer avg but over all i saw the optimized WIndows 7 use less by 10 to 20 times less IOPS.

You may be asking why I don't post any hard numbers for IOPS I'm seeing but I'm leaving them out for a reason. Because I wasn't scientific enough in my measuring; any numbers I give you would be nearly impossible for you to repeat as our configurations are most likely different. Since you can't repeat my test, any numbers you generate may not align with mine at all. But we can't have a meaningful discussion about the difference in our numbers because our environments differ.  As such I don't wont to post any thing to lead someone to the wrong ideas about the normal IOPS to expect from a Windows 7 VM.

Note: Resource Monitor is really the best way to view the Disk ISOPs in windows 7.

Before Optimizations




After Optimizations
Windows 7 Resource Monitor - After Optimizations




Don't use Windows XP on Vmware View


This is to Dell, Vmware, and EMC, and IBM Sales reps.

Quick rant at everyone telling me I should be using Windows XP instead of Windows 7 for Vmware View.

The year is 2011, Windows XP was shipped in 2001. Thats 10 years. Thats literally forever in software terms. I know you could fit more Windows XP on your VMs, I could fit even more DOS machines. Why would I spend all the time and energy to use the newest hardware, software and Infrastructural to offer my users 10 year old software?
 
Look here at the Microsoft Product Lifecycle Search and its Clear Winodws XP is at end of support.  Get over it and stop using it to lie about the number of VMs you can run on your hardware. 

Thursday, April 14, 2011

Printer Port Error "Cannot create a file when that file already exists"

If you are getting "Cannot create a file when that file already exists" when trying to create a printer port on windows by a specific name try a reboot. I had tried to find the port in WMI and the Registry thinking it got corrupted during an install but no luck finding it. Instead just a simple restart of the Machine solved it. (services restart of print spooler did not)

When I tried to create printer port GUI wizard and it would say complete but then it would problem a message box saying "Cannot create a file when that file already exists."

Posting this because I didn't find any results from Google on the issue. Ran into it using my powershell script to add printers.



Friday, April 8, 2011

VMware vCenter stuck "In Process"

We recently had serveral unexplainable issues with our VMware vCenter Server would have task hang "In Process" untill the vCenter server or services where restarted. Normally the solution most post say is to restart ESX Mgmt-vmware service like so:


 service mgmt-vmware restart



However after all my trouble shooting failed and tracing kernal logs in ESX it became clear to myself and VMware support that the task were simply never reaching the ESX hosts. This took a lot of convincing on my part to vmware but eventually VMware support agreed with me.  We then took a closer look at our vCenter server and found that the Database was running SQL 2008 Service Pack 1.

VMware support said that they didn't yet support SQL 2008 Service Pack 1 and that odd behavior they couldn't describe or explain sometime occurred. I agreed to change the Database back to a SQL 2008 without service pack 1 and figured it would take a day or so.

How wrong I was.

There is no DB downgrade path for SQL 2008 SP1. I tried several methods to migrate the database but in the end the only solution was to recreate the vCenter as a clean install. It was hard but worth it in the end. I had to remove each ESX ever and reconnect it to the new vCenter. This was made much more difficult because I use Nexus 1000 distributed switches. I then remove a VM from inventory on the old vCenter then added it to inventory on the new vCenter. I required nightly outages until finally all the VM's were migrated.

I don't recommended this process unless there is no other method available. It did resolve my problem but I had to kill the patient in order to do so.

Links
vCenter Server displays the error: Failed to connect to host

Vmware and Cisco Nexus 1000 Notes

This post is mostly just commands I've been meaning to flush out to a full post but haven't had the time. I'm going to go ahead and post it as it may help some one. I do plan on coming back to finish and flush out more explanations but till then good luck. If really do have honest questions ask them in the comments and I'll answer what I can.




latest V1000 Software
http://www.cisco.com/cisco/software/navigator.html?mdfid=282362725&i=rp

Vmware Commands 
esxupdate query | grep VEM
vem version

vemcmd show card
vemcmd show port

tail /var/log/vmkernel -n 30

vemlog show last 2000 | more

ac02-ns1-01

read the log and remvoe the stuff we don't need

tail /var/log/vmkernel -n 40000 | grep -v runt | uniq

tail /var/log/vmkernel -n 40000 | grep -v runt | grep ": 1"

Cisco v1000 Commands
http://www.cisco.or.at/en/US/docs/switches/datacenter/nexus1000/sw/4_0/troubleshooting/configuration/guide/trouble_5modules.html

http://saloperie.com/docs/cisco/BRKVIR-3005.pdf
Great PDF with trouble shooting and commands



VEM may drop Cisco Nexus 1000V ARP request from VM.


Revised understanding of the issue of 30secs of working and 30secs of reset
putting a single nic in a port channel causes it to behave 30 seconds up and then 30 seconds down, this has be recreated. the speed setting has nothing to do with it. and the Auto Negotiation being seen in the log was just after the 30 sec fail.

Before you can disable Vpc (Virutal port channel) you must remove all but one nic it from the Distubed switch in ESX.

VEM commands can be run remotely from the VSM (v1000)
module vem 3 execute show port


Update VEM Feature Level after VSM Software Update:
system update vem feature level <number> : <number> being the feature level if you do it without the number it will show the available feature levels

Show current VEM feature level on VSM:
sh system vem feature level




show system redundancy status
show interface status




show run interface po4
show run interface ethernet 6/3

conf

interface ethernet 6/3




show port-channel summary

show interface brief


show run interface po7


show svs

sh cdp nei
sh module vem mapping 
show module

show log last 30





add or remove interface to port channel
conf
interface ethernet 6/3
channel-group 21 mode active
no channel-group 21 mode active




When you can ping the VM from some Other Machines but others say destination unreacable. Its the firmware



Links 

Powershell API for Windows 2008 Print Queues and Ports

After you use this let me know what you think, this was one of projects I looked for and couldn't find before I started to write it.

Lately I've been working on migrating a Windows 2008 Print Server from from 32 bit to Windows 2008 R2 64bit. During this I've been cleaning up unused printers and ports as my other post suggested. Considering this print sever had nearly 500 printers installed worked on automating the process. Using Powershell I noticed many people complaining of poor integration of Powershell for Printer support. While I agree there should of been better built-in functions I was able to write every feature I wanted once I figured out how.

There where many posts online but none of them seemed to handle any issues that arrised. For example if you try and create a printer using [WMICLASS]"\\$ComputerName\ROOT\cimv2:Win32_Printer").createInstance() and call .Put() you may get the following error.


Exception calling "Put" with "0" argument(s): "Generic failure "
At C:\Users\towlesd\Documents\My Dropbox\PrinterInformationfor2008.ps1:319 char:24
+     [void] $newprinter.Put <<<< ()
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

This is caused because one of the pramaters you are trying to use isn't valid. It doesn't say that but thats what it means. Frustrating to say the least. The cause of this for me it was the print driver didn't exist on the server. Because of this my InstallPrinters function first checks that all printers and ports first exist on the remote server. Little things like this make the entire process possible.

You really need to break down how you want to use this script it self as there are alot of useful functions depending on what your working on. In all the script can gather all the printer information about a given server; Its printers, ports and drivers and export that to a csv-file. It can try to ping all the ports and detect which are offline or bad DNS entires.

Here are most of the Powershell functions

  • Create Printer
  • Create Port
  • Install Array of Printers
  • Get Installed Drivers
  • Get Install Ports
  • Match printers with their ports in a csv-file
  • Create csv files for any of this information
  • migrate printers from one serevr to another


Without further delay.
###########################
#
#  Purpose: Printer API for Managing and migrating Printers
#  Created By: Chris Towles
#  Website: http://www.ChrisTowles.com
#  When: 04/08/2011
#  Version: 1.0
#  Change List
#
###########################

function Ping() {
 param ([string] $ComputerName)
 [bool] $Pingable = $false
  
 try {
  $ping = new-object System.Net.NetworkInformation.Ping
  $Reply = $ping.send($ComputerName, 1000)
  if ($Reply.status –eq “Success”) {
   $Pingable = $true
  }
 } 
 catch { return "DNS Issue" }
 
 if ($Pingable) { return “Online” }
 else { return "Offline" }
}
function Get-Nslookup() {
 param ([string] $Name)
 
 $DNSInfo = "" | select "DNSName", "DNS_IP"
 $DNSInfo.DNSName = $null
 $DNSInfo.DNS_IP = $null
 
 try {
  #http://powershellmasters.blogspot.com/2009/04/nslookup-and-powershell.html
  $cmd = "nslookup " + $Name + " " + $ns + " 2>&1" 
  $result = Invoke-Expression ($cmd) -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
  
  $DNSInfo.DNSName = $result.SyncRoot[3]
  $DNSInfo.DNSName = $DNSInfo.DNSName.Split(":")[1]
  $DNSInfo.DNSName = $DNSInfo.DNSName.Trim()
  
  $DNSInfo.DNS_IP = $result.SyncRoot[4]
  $DNSInfo.DNS_IP = $DNSInfo.DNS_IP.Split(":")[1]
  $DNSInfo.DNS_IP = $DNSInfo.DNS_IP.Trim()
 }
 catch{
  $DNSInfo.DNSName = $null
  $DNSInfo.DNS_IP = $null
 }
 return  $DNSInfo
}
Function Get-Printers( ) {
 param ([string] $ComputerName  = ".") #sets "." as the default param if none is supplied

 Write-Host "Connecting to $ComputerName by WMI to gather printer information."
 Write-Host " Warning this may take a few minutes depending how many printers there are." -ForegroundColor Red
 
 $colItems = get-wmiobject -class "Win32_Printer" -namespace "root\CIMV2" -computername $ComputerName
 $count = $colItems.Count
 $pos = 0
 Write-Host "Found $count printers. Getting details on each now."
 $Printers = @()

 foreach ($objItem in $colItems) {
  write-progress -activity "Getting Information on each printer." -status "% Complete" -percentcomplete (($pos++/$count)*100);
  
  #creating a new object called $PrinterInfo 
     $PrinterInfo = New-Object psobject  

     $PrinterInfo | Add-Member NoteProperty Caption $objItem.Caption
     $PrinterInfo | Add-Member NoteProperty Comment  $objItem.Comment
     $PrinterInfo | Add-Member NoteProperty "Default"  $objItem.Default
     $PrinterInfo | Add-Member NoteProperty "DriverName" $objItem.DriverName
     $PrinterInfo | Add-Member NoteProperty "Local" $objItem.Local
     $PrinterInfo | Add-Member NoteProperty "Name" $objItem.Name
     $PrinterInfo | Add-Member NoteProperty "PortName" $objItem.PortName
     $PrinterInfo | Add-Member NoteProperty "PrinterStatus" $objItem.PrinterStatus
     $PrinterInfo | Add-Member NoteProperty "PrintProcessor" $objItem.PrintProcessor
     $PrinterInfo | Add-Member NoteProperty "Shared" $objItem.Shared
     $PrinterInfo | Add-Member NoteProperty "ShareName" $objItem.ShareName
     $PrinterInfo | Add-Member NoteProperty "Status" $objItem.Status
     $PrinterInfo | Add-Member NoteProperty "SystemName" $objItem.SystemName
     $PrinterInfo | Add-Member NoteProperty "WorkOffline" $objItem.WorkOffline
     
  $Printers += $PrinterInfo
 }
 write-progress -activity "Getting Information on each Port." -status "% Complete:" -percentcomplete 100 -Completed;
 return $Printers
}
function Get-PortInfo () {
 param ([string] $ComputerName  = ".",
   [bool]$CheckPorts = $true) #sets "." as the default param if none is supplied
  
 Write-Host "Connecting to $ComputerName by WMI to gather printer port information."
 Write-Host " Warning this may take a few minutes because its pinging each port." -ForegroundColor Red

 $colItems = get-wmiobject -class "Win32_TCPIPPrinterPort" -namespace "root\CIMV2" -computername $ComputerName
 $count = $colItems.Count
 $pos = 0
 Write-Host "Found $count printer ports. Getting details on each now."
 
 
 $Ports = @()
 
 foreach ($objItem in $colItems) {
  write-progress -activity "Getting Information on each Printer Port. " -status "% Complete:" -percentcomplete (($pos++/$count)*100);
  
  $PortInfo = New-Object psobject  
  $PortInfo | Add-Member NoteProperty "ByteCount" $objItem.ByteCount
  $PortInfo | Add-Member NoteProperty "HostAddress" $objItem.HostAddress
  $PortInfo | Add-Member NoteProperty "HostAddressLink" ("http://" + $objItem.HostAddress + "/" )
  $PortInfo | Add-Member NoteProperty "Name" $objItem.Name
  $PortInfo | Add-Member NoteProperty "PortNumber" $objItem.PortNumber
  $PortInfo | Add-Member NoteProperty "Protocol" $objItem.Protocol
  $PortInfo | Add-Member NoteProperty "Queue" $objItem.Queue
  $PortInfo | Add-Member NoteProperty "SNMPCommunity" $objItem.SNMPCommunity
  $PortInfo | Add-Member NoteProperty "SNMPDevIndex" $objItem.SNMPDevIndex
  $PortInfo | Add-Member NoteProperty "SNMPEnabled" $objItem.SNMPEnabled
  
  if($CheckPorts) {
   $pingstring = Ping -ComputerName $objItem.HostAddress
   $PortInfo | Add-Member NoteProperty "Ping" $pingstring
  
   $DNSInfo = get-nslookup -Name $objItem.HostAddress
   $PortInfo | Add-Member NoteProperty "DNSName" $DNSInfo.DNSName
   $PortInfo | Add-Member NoteProperty "DNS_IP" $DNSInfo.DNS_IP
  }
  
  $Ports += $PortInfo
 }
 write-progress -activity "Getting Information on each Port." -status "% Complete:" -percentcomplete 100 -Completed;
 return $Ports
}
function Get-PrintersWithPort {
 param ( [array] $Printers,
   [array] $Ports  )

 $count = $Printers.Count
 $pos = 0
 $PrinterWithPortInfo = @()
 Foreach($Printer in $Printers) {
 
  write-progress -activity "Sorting Printers to their matching Ports." -status "% Complete" -percentcomplete (($pos++/$count)*100);
  $Port = $Ports | where {$_.Name -like ($Printer.PortName) }
  if($Port -ne $null) {
   $properties = $Port | Get-Member -MemberType NoteProperty
   
   foreach ($member in $properties )
   {
    $PropName = $member.Name
    $PropValue = $Port | Get-Member -MemberType NoteProperty ($member.Name) 
    
    $PropValue = $PropValue.ToString().Split("=")[1]
    
    if($PropValue -match "null")
    { $PropValue = ""}
    
    $Printer | Add-Member NoteProperty ("Port_" + $Propname) $PropValue
   }
   $PrinterWithPortInfo += $Printer
  }
 }
 write-progress -activity "Sorting Printers to their matching Ports. Phase 3 of 3." -status "% Complete" -percentcomplete 100 -Completed;
 return $PrinterWithPortInfo
}
function Get-PortsWithPrinterAndOnline {
 param ( [array] $Printers , 
   [array] $Ports  )
 
 $PortsWithPrinterAndOnline = @()
 Foreach($Printer in $Printers) {
   $Port = $Ports | where { $_.Name -like ($Printer.PortName)  }
   if(($Port -ne $null ) -and ($Port.Ping -like "Online")) {
    $PortsWithPrinterAndOnline += $Port
   }
 }
 return $PortsWithPrinterAndOnline
}
function Get-PortsWithoutPrinters {
 param ( [array] $Printers , 
   [array] $Ports  )
 
 $PortsWithoutPrinters  = @()
  
 Foreach($Port in $Ports) {  
   $Printer = $Printers | where { $_.PortName -like ($Port.Name) }
   if(($Printer -eq $null ) ) { #-and ($Port.Ping -like "Online")) {
    #Port Has no Printer
    $PortsWithoutPrinters += $Port
   }
 }
 $PortsWithoutPrinters = $PortsWithoutPrinters | sort -Property "Name"
 
 return $PortsWithoutPrinters
}
function Get-PrintersWithPortsOffLine {
 param ( [array] $Printers,
   [array] $Ports  )
 
 $PrinterWithPortOffLine = @()
 Foreach($Printer in $Printers) {
   $Port = $Ports | where { $_.Name -like ($Printer.PortName)  }
   if(($Port -ne $null ) -and ($Port.Ping -inotlike "Online")) {
    $PrinterWithPortOffLine += $Printer
   }
 }
 return $PrinterWithPortOffLine
}
function Get-PharosQueuesWithWInprintProcessor {
 param ( [array] $Printers )
 $WinPrint = @()
 Foreach($Printer in $Printers) {
   
  if($Printer.PrintProcessor -ine "WinPrint" -and $Printer.Name -like '*Q') {
   $WinPrint += $Printer
  }
 }
 return $WinPrint | sort "Name" 
}
Function Get-InstalledPrinterDrivers () {
 param ( [string] $ComputerName = "." )
  
 $colItems = get-wmiobject -class "Win32_PrinterDriver " -namespace "root\CIMV2" -computername $ComputerName

 $PrintDrivers = @()
 foreach ($objItem in $colItems) {
  #creating a new object called $PrinterInfo 
     $Driver = New-Object psobject 
     $Driver | Add-Member NoteProperty Name $objItem.Name.Split(",")[0]
  $Driver | Add-Member NoteProperty Chip $objItem.Name.Split(",")[2]
  
  $PrintDrivers += $Driver
 }
 
 return $PrintDrivers
}
function Create-PrinterPort {
 param ( [string] $ComputerName  = ".", #sets "." as the default param if none is supplied
  [string] $PortName ,
  [string] $DNSName ,
  [int] $Protocol = 1,  #default of 1 for RAW
  [string]$Queue = $null,
  [string]$PortNumber =  "9100",
  [bool] $SNMPEnabled ,
  [string] $SNMPCommunity = $null)
 
 $newPort = ([WMICLASS]"\\$ComputerName\ROOT\cimv2:Win32_TCPIPPrinterPort").createInstance() 
 $newport.Name = $PortName
 $newport.HostAddress= $DNSName #sometimes IP Address
 $newport.Protocol= $Protocol 
 #Protocols possiable
 #1 = RAW, Printing directly to a device or print server.
 #2 = LPR, Legacy protocol, which is eventually replaced by RAW.
 
 if ($Protocol -eq 2 ) {
  $newport.Queue = $Queue 
 }
 
 $newPort.PortNumber = "9100"
 $newport.SNMPEnabled = $SNMPEnabled
 if( $SNMPCommunity -ne $null ) {
  $newport.SNMPCommunity = $SNMPCommunity
 }
 
 Write-Host "Creating Port $PortName" -foregroundcolor "darkgreen"
 [void] $newport.Put()
 
}
function Create-CSVOutputFile {
 param ( [array] $CustomObject , 
   [String] $filename  )

 #writing file to 
 Write-Host $filename
 $CustomObject  | Sort-Object "Name" | Export-Csv $filename

 #removes the top line as it just has #TYPE System.Management.Automation.PSCustomObject in it.
 get-content $filename |  select -Skip 1 |  set-content "$filename-temp"
 
 if (Test-Path "$filename-temp") {
  move  "$filename-temp" $filename -Force 
 }
 else {
  Remove-Item "$filename"
  Write-Host "$filename was deleted because nothing was in it." 
 } 
}
function Create-Printer {
  Param (
  [string]$ComputerName = ".",
     [string]$PrinterName,
     [string]$DriverName,
     [string]$Location,
  [string]$ShareName,
  [String]$PortName,
     [string]$Comment
    )
   
 $newprinter = ([WMICLASS]"\\$ComputerName\ROOT\cimv2:Win32_Printer").createInstance() 
 $newprinter.Drivername = $DriverName
 $newprinter.PortName = $PortName
 $newprinter.Shared = $true
 $newprinter.Sharename = $ShareName
 $newprinter.Location = $Location
 $newprinter.Comment = $Comment
 $newprinter.DeviceID = $PrinterName
 Write-Host "Creating Printer $PrinterName" -foregroundcolor "darkgreen"
 [void] $newprinter.Put()
 
 #Exception calling "Put" with "0" argument(s): "Generic failure "
 # This Means their is something wrong with a paramter, Most likely its the driver name
}
function Install-PrinterPorts {
 param ( [string] $ComputerName , 
   [array] $Ports  )

 Write-Host "Creating the following " $Ports.Count " printer ports on " $ComputerName
 foreach ($newport in $Ports) {
  
  [bool] $SNMPEnabled = $false
  if( $newport.SNMPEnabled -eq $true ) {
   $SNMPEnabled = $true
  }
  
  Create-PrinterPort -ComputerName $ComputerName `
   -DNSName $newport.HostAddress.ToUpper() `
   -PortName $newport.Name.ToUpper() `
   -PortNumber $newport.PortNumber `
   -Protocol $newport.Protocol `
   -SNMPEnabled $SNMPEnabled `
   -SNMPCommunity $newport.SNMPCommunity `
   -Queue $newport.Queue
 }
}
Function Install-Printers {
 param (
  [string] $ComputerName = ".",
  [array] $PrintersToCreate,
  [array] $PortsToCreate,
  [bool] $TestDriversAndPortsOnly = $false
 )
 $PrintersToInstall = @()
 $MissingPort = @()
 $MissingDriver = @()
 
 #Create the Remote Ports
 Install-PrinterPorts  -ComputerName $ComputerName -Ports $PortsToCreate
 
 #Check Print server for what ports and Printers are installed.
 $InstalledDrivers = Get-InstalledPrinterDrivers -ComputerName $ComputerName 
 $InstalledPorts = Get-PortInfo -ComputerName $ComputerName -CheckPorts $false
 
 #I wished to have all the names in uppercase only.
 $Printer.PortName = $Printer.PortName.ToUpper() 
 
 foreach($Printer in $Printers)
 {
  $DriverFound = $InstalledDrivers | where {$_.Name -eq $Printer.DriverName} 
  $PortFound = $InstalledPorts | where {$_.Name -eq $Printer.PortName} 
  
  if($DriverFound -eq $null) {
   #Write-Host ("The Print Driver isn't installed on the Destination Server" + $Printer.DriverName )
   $MissingDriver += $Printer.DriverName
  }
  elseif($PortFound -eq $null) {
   #Write-Host ("The Printer Port " + $Printer.Port_Name + " didn't existon the destination Server" + $Printer.DriverName )
   $MissingPort += $Printer.PortName
  }
  else{
   $PrintersToInstall += $Printer
  }
 }
 
 Write-Host ""
 Write-Host ("The following printer drivers are missing from " + $ComputerName )
 $MissingDriver | Sort | Get-Unique | ft -AutoSize
 
 Write-Host ""
 Write-Host ("The following printer port didn't exist on " + $ComputerName )
 $MissingPort | Sort | Get-Unique | ft -AutoSize
 
 Write-Host ""
 if ( $TestDriversAndPortsOnly -eq $false ) {
  foreach($Printer in $PrintersToInstall) {
 
   Create-Printer `
    -PrinterName  $Printer.Name  `
    -ComputerName $DestinationHost `
    -DriverName   $Printer.DriverName `
    -PortName    $Printer.PortName.ToUpper() `
     -ShareName    $Printer.ShareName  `
    -Comment    $Printer.Comment `
    -Location    "" 
  }
 }
}

#################################################################################
#        MAIN           #
#################################################################################
Clear
$ComputerName = Read-Host "Enter the Print Server you wish to gather data about."
#$DestinationHost = "dvprintserv1"

[bool] $QueryData = $true
[bool] $OutputFiles = $true

if( $QueryData ) {
 #Gets all the information
 $Printers = @() | Get-Printers -ComputerName $ComputerName
 $Ports  = @() | Get-PortInfo -ComputerName $ComputerName
 $PrinterWithPortInfo = @() | Get-PrintersWithPort -Printers $Printers -Ports  $Ports
 $PortsWithoutPrinters = @() | Get-PortsWithoutPrinters -Printers $Printers -Ports $Ports
 $PrintersWithOffLinePort =   @() | Get-PrintersWithPortsOffLine -Printers $Printers -Ports  $Ports
}
#Used to migrate printers from one server to another.
#Install-Printers -ComputerName $DestinationHost -PrintersToCreate $Printers -Ports $Ports #-TestDriversAndPortsOnly $true

if($OutputFiles) {

 #Formated File Names
 $d = get-date
 $FileTime = "" + $d.Year + "-" + ("{0:D2}" -f $d.Month) + "-" + ("{0:D2}" -f $d.Day) + "-" + ("{0:D2}" -f $d.Hour ) + ("{0:D2}" -f $d.Minute)
 $PortsFilename = [String]::Format( "{0}_Ports_{1}.csv", $ComputerName, $FileTime )
 $PrintersFilename = [String]::Format( "{0}_Printers_{1}.csv", $ComputerName, $FileTime )
 $PrintersWithPortFilename = [String]::Format( "{0}_PrintersWithPort_{1}.csv", $ComputerName, $FileTime )
 $PortsWithoutPrintersFilename = [String]::Format( "{0}_PortsWithoutPrinters_{1}.csv", $ComputerName, $FileTime )
 $PrintersWithOffLinePortFileName = [String]::Format( "{0}_PrintersWithOffLinePort_{1}.csv", $ComputerName, $FileTime )

 #writing file
 [Environment]::CurrentDirectory = (Get-Location -PSProvider FileSystem).ProviderPath
 Write-Host ("Saving CSV Files at " + [Environment]::CurrentDirectory + " Named the following.")
 
 Create-CSVOutputFile $Printers -filename $PrintersFilename
 Create-CSVOutputFile $Ports -filename $PortsFilename
 Create-CSVOutputFile $PrinterWithPortInfo  -filename $PrintersWithPortFilename
 Create-CSVOutputFile $PortsWithoutPrinters  -filename $PortsWithoutPrintersFilename
 Create-CSVOutputFile $PrintersWithOffLinePort -filename $PrintersWithOffLinePortFileName
}
Here an example of some output.
Connecting to dvprintserv1 by WMI to gather printer information.
Warning this may take a few minutes depending how many printers there are.
Found 123 printers. Getting details on each now.
Connecting to dvprintserv1 by WMI to gather printer port information.
 Warning this may take a few minutes because its pinging each port.
Found 355 printer ports. Getting details on each now.
Saving CSV Files at C:\Users\towlesd\Documents Named the following.
dvprintserv1_Printers_2011-04-08-1211.csv
dvprintserv1_Ports_2011-04-08-1211.csv
dvprintserv1_PrintersWithPort_2011-04-08-1211.csv
dvprintserv1_PortsWithoutPrinters_2011-04-08-1211.csv
dvprintserv1_PrintersWithOffLinePort_2011-04-08-1211.csv

Tuesday, March 29, 2011

Powershell for Printer Information from Windows 2008

While working on migrating are campus print server to Windows 2008 R2 64 bit I wrote some Powershell scripts I figured others may find useful. I have other scripts I'll post in the future on creating and working with printers but this post is primarily about getting data about the printers and ports.

The end result is are three excel files (CSV).
  1. Contains all the information about the printers on the server.
  2. Contains the Ports information and tries to ping the Host Address to see if the port is valid
  3. Joins the data so that you can see the printer and its port information all together.
All the data is gathered via WMI so you'll need administrative access to the server your running it against. I used PowerGUI to write and test this and have been quite happy with the outcome. Considering our server has 500 printers on it takes about 5 minutes to run but lower numbers of printers run much faster.

The fact that the scripts pings all the ports and reports their status is a feature I should of written a long time ago.


Command Line Output


Picutre of the resulting Files

Thursday, March 24, 2011

Download Dell OpenManage Server Update Utility (SUU)

Ever have one of those tasks that you figure will take 10 minutes but ends up taking your entire morning day. I did this morning when last night the front display on one of our Dell R900 VMware ESX hosts reported a problem with a CPU. Just a warning but it needed addressing. I put the ESX Host in maintenance mode and starting to research the issue. Multiple websites say that just upgrading the firmware and bios should take care of the issue. Either way its good practice usually.

Now remember for the rest of the post my only goal was to update the firmware and bios of a Dell R900.

Downloading the Dell OpenManage Server Update Utility


First things first I decide to do is optain the newest Dell OpenManage Server Update Utility DVD. I search both Google and Dell and look for the main site but they refuse to give a product page link from their support site. The last time I used it was at version SUU 6.4 but just try proving that is the latest version. Dell says "For the latest version, go to http://support.dell.com and search on 'SUU' " but Dell seems to keep returning  links to 2008's version. There is this link here which will take you to the manual but god forbid there a be download link. Finally I find a useful post here on DellTechCenter which sorta works.

Whats really funny is the post even says that google analytics shows searches for "OpenManage Download" were top searches for the entire site yet there still isn't a clear product page with the versions. Instead the post has you search their FTP for the latest. DellTechCenter has you use naviagate to ftp://ftp.dell.com/sysman using FileZilla. Sort the Files there and download the highest version of omxxx_suu_xxx.iso.xxx. Note that they are really large files (1.8gig each) so this takes a while; as in hours. Also note that its much better to use a ftp client like FileZilla to download these files rather than the http site which may introduce errors into files this large ( read below for checksum)

Dell FTP for SUU
After the files have finished downloading you have to combine the files together together. On windows this is done by opening a command prompt to the folder of the files and then execute the following. First be sure to change the file names if you are

Dell System Update Utility is already running

So after a failed run of the Dell OpenManage Server Update Utility I found that I couldn't rerun the update. You can read my other post as to how this occured and how to download and run SUU. The error I was getting when trying to run SUU was as follows, and since I had just rebooted I knew no other instances were running.

[root@nkuvmhost4 cdrom]# sh suu -e
Another instance of SUU is already running. Hence exiting SUU application.....
If you are sure, no other instance is currently running on this system, then please refer
"Frequently Asked Questions" section in the user guide on how to start SUU

The cause was a file "/var/log/dell/suu/suu.lck" however deleteing this file was unsucesful even with "rm -f suu.lck".The reason it couldn't be renamed, moved or deleted was because is was being protected using extended file system 'i' attribute.


cd /var/log/dell/suu
lsattr suu.lck
----i-------- suu.lck

You can remove this with "chattr -i". Now you can remove the file like you would normally with "rm -f" with out any further issue.

chattr -i suu.lck
rm -f  suu.lck

Links
How to delete a write protected file

VMware ESX URB timed Out

Working with Dell Remote Access Card (DRAC) 5 I ran into an issue where I got a URB warning from Vmware ESX 4.1 was booted.

Message : cpu6:4263)URB timed out - USB device may not respond

VMware ESX URB timed out

(Disregard the be2net line as that is part of the beta drivers we're running on our Emulex cards.)

This problem popped up after using the Virtual Media mapping done via the DRAC 5. I tried to set the Virtual Media to be detatched however that didn't resolve the issue.

Looking around I found this VMware Forum post talking about the issue may be fixed with a firmware update.I was running DRAC 5 firmware 1.51 and downloaded 1.60 from Dell's DRAC 5 Firmware Download. I choose the Hard drive option and

Dell Remote Access Controller (DRAC) 5 ActiveX Install Loop

I ran into this issue trying to mount a large ISO I couldn't burn to media on a Dell Remote Access Card version 5. It occurred using both Internet Explore 9 and 8.  I tried to open the Media tab and map the ISO. However when I loaded the tab it prompts to install a Dell Add on (ActiveX) and gives the following error : "Description: The Virtual Media plug-in is not installed or running."

DRAC 5 ActiveX Install Prompt

I right clicked and installed the add-on only to have it log me out of the DRAC. Figuring it installed and just needed a reload the site I log back in and go back to the media tab. I see exactly the same prompt and exactly the same error.

The easy fix is to

Tuesday, March 15, 2011

Pharos UniPrint - "Not enough money to print job"

On our new Pharos UniPrint 8.1 system a new error appeared today. "Not enough money to print job". I first figured this was a message I had written in the Pharos billing Plug-in. But looking closer I found that this message wasn't one I had written. and it appeared before my Plug-In "PrintJob -Accept Costs" was called. 

Pharos Not enough Money to print job
The issue only happened when a user had some money in internal balances and then the rest on the gateway balance. I narrowed it down to a feature that when Pharos Billing Plug-In was called the PlugIn.Balance was returned. If the balance wasn't enough the Pharos Popup not enough money to print job appeared. This all makes since but i'd been using the same Billing script in Pharos UniPrint 8.0.

The problem was actually how Pharos UniPrint 8.1 parsed

MBRAlign of Vmware on IBM N Series (Netapp)

We use a IBM N-Series array (read as: Netapp without the useful software yet comes with painful IBM support) and are experiencing horrific performance. As part of the blame game IBM pointed the finger at a few Vmware Virtual Machines that where misaligned then hung up. Even if the there are no misaligned Virtual Machines on a particular filer the speed doesn't improve nor does non Vmware connected servers. Nor does an aligned Virtual Machine run the tests any better then before we aligned it. But aligning is a good thing and as such heres some of the notes on the process.

First we need the MBRalign tools. You can download them from your vCenter client If you installed  IBM N series VSC on your vCenter. If you didn't start installing. This will add a plugin to your VCenter Client. Once thats installed, good luck, select a ESX host and there should be a "IBM N Series" Tab. From there select tools and download.
VCenter IBM N Series Tab
That download should be a "mbrtools.tar.gz" file that we need to copy to the ESXthat will be running the alignment and has access to the VM datastores. I use WinSCP to copy the file to the ESX host. You should also open the "mbrtools.tar.gz" file on your work station to view the readme and pdf how-to stored in it.

Note: Its normally necessary to SSH into a ESX server so I always create a local account to login remotely with and then su up to root. If you haven't done this it is really worth your time to do so. That same non root account is also useful to login with WinSCP to move files on and off the host.

Once the "mbrtools.tar.gz" file is on the ESX host SSH to that