About Chris.Butler

This author has not yet filled in any details.
So far Chris.Butler has created 2 blog entries.

The Red Exclamation Points (A Suspense/Thriller Mini-Novella)…

2017-07-27T00:01:02+00:00 June 18th, 2014|Uncategorized|

This evening was going like any other busy evening for a Coretek employee with a deadline fast approaching.  I was working with Citrix Support to figure out what the problem is with a Citrix XenMobile (an Enterprise Mobile Device Manager), when the dreaded warning texts started pouring in…

I received message after message about “servers down, 8:30 PM”…  The nice thing about it is I figured out who was by their phones to respond to the alerts.  After a quick couple of text messages, I acknowledged the alerts and began troubleshooting. 

I knew the issue was with our VMWare Vcenter Server, and my first reaction was, “…well I’m busy let’s just reboot this thing.”  So I rebooted the server and waited for it to idle down before launching VSphere, which now showed a bunch of orphaned VMs (“orphaned” is a bad word in Vmware, essentially meaning that a portion of the vm be it disk or configuration files can’t be located). 

So my mind starts racing to a network or storage issue.  I go to click on an orphaned VM and vSphere Crashed.  I now *Face Palm* myself (…sigh…) and go back to the vCenter server and attempt to start the service “VMware VirtualCenter Server.”  It starts, and as I open vSphere again, and it almost immediately crashes. 

So now I’m starting to get really nervous, and I’m thinking I’m going to need to do a restore; meanwhile, the support engineer from Citrix is on the line asking me to show her my Netscaler configuration and AppController configs.  I tell her, “I’ll show you what I have in a minute, ½ of my network just alerted me it is down.”  I believe it was one of those “lost in translation” moments because she waits and a minute later says, “well can I see the configs?”.  I give in show her the configs and run for another laptop from my desk to continue troubleshooting.  And as I log in and open Event Viewer on the vCenter server to see what is going on…  All I see are red exclamation points…

 

Red Exclamation Points!

So I have another *Face Palm* moment and think, “…Well, SQL Express 2008 R2 database size limit.  Ok, fun… now what…?”  Well Google here I come…

I found a few articles that talk about shrinking the database and truncating records…  It’s now 9:30 at night, I’m not feeling the “truncate my database” vibe tonight, so I continue reading on.  Eventually, I come across an article about cleaning up performance Data…  Well now, we don’t truly review performance data!  So why not clean that out, save some space and go home.  It’s now 9:50 ish…

So I have the plan of attack, and of course immediately roadblock #1 comes up: no SQL Management Studio on the box, and I don’t have another SQL box readily available.  So I back to google to find and download “SQL Server Express 2008 R2 with tools”…  except there are not stinkin’ tools in this package!  Argh!  Howver, hopping over to my MSDN subscription, I download “SQL Server 2008 R2 Express with Tools X86” and lucky me, the tools are actually there.  It’s now 10:30 ish…

Now roadblock #2: I took over this network and environment and I don’t know the account and password to use.  So I try my domain admin account…  Nope, public access only.  Well, I’m not a DBA — and I don’t claim to be a SQL Expert — so Google, here I come again… 

One of the top results is a Microsoft article on how to get access.  So in following this article, I stopped the Vmware services and added the –m parameter in the service start-up.  I proceeded to log in with my domain account (NOTE: RUN MANAGEMENT STUDIO IN PRIVLIDGED MODE, a.k.a. “Run As Administrator”) and my new shiny tools.  Once logged in, I created my account and provided myself with sysadmin rights to the instance.

I then backed up the databases to the D: drive (separate the OS and Database), and then ran the Script I got from the above VMware Article.  It worked like a charm, and in under a minute I cleared ½ of my database and was up and running.  Now, back to the Citrix support call…  It’s now 10:45… 

The End….?

 

[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]

Powershell with embedded VBS…

2017-07-27T00:01:03+00:00 November 21st, 2013|Uncategorized|

I recently have been working on a project where the client uses an application that requires a generic username and password to be passed to the database.  To further complicate the matter the users could not know or input the username/password…

To accommodate the project I started working with the logic and how to accomplish this goal.  I started Imprivata (A Single Sign on Application) and AppSense to launch the app at the end of the userinit process.  Unfortunately, this failed to function due to the outdated server version at the client site.  So I ended up with PowerShell to launch the application…

I wrote 26 lines of code (see below) to check if the script had been run before; if it hadn’t, then it would create a flag.  Once it completed, it would check the flag, run the script, expect Imprivata to proxy the credentials, and the day was saved, right?!? 

 

# Create Windows Shell Object to allow for window to be minimized
$shell = New-Object -ComObject "Shell.Application"
# Create Registry Key Flag if it doesn’t already exist
if (!(test-path -path HKCU:SoftwareCUSTOMER -pathType container))
{
  New-Item -Path HKCU:Software -Name CUSTOMER
  New-ItemProperty "HKCU:SoftwareCUSTOMER" -Name "SynapseLaunched" -Value 0 -PropertyType "DWord"
}
#Check the value of Synapse Launched
if ((Get-ItemProperty 'hkCU:softwareCUSTOMER' -name SynapseLaunched | select -exp SynapseLaunched) -ne 1) 
{ 
  #launch Synapse then minimize all windows
  & 'C:Windowsexplorer.exe' "::{1FBD11EF-1260-11D1-87A7-444553540001}"
  start-sleep -s 2
  $shell.minimizeall() 
  #countdown from 2 seconds to allow app to connect to server
  Start-Sleep -s 2
  #kill Explorer.exe and relaunch
  $proc = Get-Process
  foreach ($objItm in $proc) 
  {
    If ($objItm.ProcessName -eq "explorer") 
    {
       kill $objItm.ID
    }
  }
  #Set SynapseLaunched Dword Value to 1
  Set-ItemProperty 'hkcu:softwareCUSTOMER' -name SynapseLaunched -Value 1  
}  

…Sadly, not so.  Imprivata at the client site was outdated and would not be available to be used for Windows 7 at the site for 2 months, causing an unacceptable delay in the project. 

Well, after the Imprivata approach failed for me, I needed to accomplish what I couldn’t do in Imprivata.  I started by thinking that perhaps I could launch an explorer process (this app is an explorer shell extension) as run as user with my username…  But no dice; the launching of explorer like that didn’t work because it would cause the files I needed to be created in a non-existent user profile, and would error out on the server.

So, I fell back to Windows VBS scripting’s SendKeys.  Since my script was already in PowerShell, and scripting in autoIT or VBS is something I rarely do, I experimented with creating a new Shell object.  Below is the code that I used for that:

 

#proxy Credentials
      $wshell = new-object -com wscript.shell
      $wshell.AppActivate("Windows Security")
      $wshell.sendkeys("{ENTER}")
      start-sleep -m 30
      $wshell.AppActivate("OneSign")
      $wshell.sendkeys("{ENTER}")
      start-sleep -m 30
      $wshell.AppActivate("Windows Security")
      $wshell.sendkeys("USERNAME")
      $wshell.sendkeys("{TAB}")
      $wshell.sendkeys("PASSWORD_OF_USER")
      start-sleep -m 30
      $wshell.sendkeys("{ENTER}") 

By utilizing $wshell = new-object -com wscript.shell, I was able to tap into .Net commands to interact with windows.  Now I could utilize some old VB Scripting code I had laying around from the past…

By utilizing $shell = New-Object -ComObject "Shell.Application", I was able to manipulate the Explorer.exe shell and minimize/maximize windows as I saw fit…

This was a very rewarding exercise.  Through this solution we (Coretek) were able to solve the client’s issues with the app, accommodate both teams (Desktop and PACs), simplify the end user experience, and best of all bring Windows 7 deployments back on schedule!