Does anyone know the password for this database?

Those that I work with know that my first, and primary, job is as a MySQL DBA. Unfortunately, cause I love MySQL, I haven’t been doing as much with it lately because of all the virtualization work going on.

Today I’m going to post about MySQL. Occasionally you may encounter a MySQL server that has been around for a while, and no one knows who set it up, where it came from, or who owns it. Those wonderfully inaccessible databases are still someone’s responsibility. So, what do you do if you don’t know the root password? Well, it’s actually not all that difficult, assuming you can start and stop the instance a few times.

Read more

Convert DN to Canonical and back

I’ve been revamping our user account creation process lately (more on that when I finish it).  I started with the quest cmdlets, but performance/limitations lead me back to adsi.  Along the way I kept having to go from canonical naming (domain.comousubousizemore, glenn) to the more common distinguished name.  After the third time I did this by hand i decided to script it.  I wrote the following functions to handle the conversion.

Note:  Should these be named ConvertTo-* or ConvertFrom-* ?

Fedora 8 Suspension

I’ve previously mentioned that I use Fedora 8 on my laptop at home. It is a Core 2 Duo Dell with a GeForceGo 7300. Originally, it had Vista Home Premium, and I really did give Vista a chance (for almost 8 months!!), but I just like linux more. I do still have to go back to Vista on the (extremely) rare occasion I need bluetooth support. For some reason I can’t get the integrated bluetooth modem to work with Fedora. The GeForce Go has caused me nothing but problems. Nvidia’s normal drivers won’t work with the Go series from Dell, I have to get the drivers directly from Dell…and they are flaky.

Anyway, I recently reloaded my laptop and let it update everything to the newest available. Unfortunately, at some point, suspend stopped working. I’m not sure when it was (it applied ~ 300 updates), but it stopped. Well, it didn’t exactly stop working…it still suspends, once, after which the monitor refuses to work. I can still ssh in, and everything seems to be functioning normally, but the monitor doesn’t work. Which makes a laptop very useless.

So, since I’ve reloaded linux a number of times, and it seems each time I forget what I did to fix it, I’m documenting it for myself, and posterity.

Read more

Where in !@#%* does the text on tty11 come from?

You know the text I’m talking about…when you walk up to an ESX host and it has the hostname and IP address along with instructions to “press ALT-F1 to open the ESX Server Console, press ALT-F11 to return to this screen”.

Yeah, that text. Where does it come from? It’s not a typical tty…it has a screen saver (if you let it be for a while it’ll go blank). I can’t figure out for the life of me where it’s started, or where it get’s it’s data from…well I found some things…but not where the obviously non-dynamic (text other than ip address, hostname) data comes from.

The point of my looking for how it get’s that data is because we recently changed the IP addresses of all our ESX hosts. The console (and consequentially webAccess) were on a public LAN. For security reasons, we didn’t want this, so we put them on a private LAN. Nothing difficult…took care of the entire process from VI Client (add new console interface, set as primary, remove old console interface). I even went to the trouble (ok, I might have OCD) of physically standing in front of the box and moving the new vswif1 so that it’s named vswif0, just because it was irritating me.

Read more

Where-object vs WQL

No matter what you’re doing in PowerShell there are guaranteed to be at least 5 different ways to accomplish your goal.  Early on I would suggest focusing on the functionality, but after your script is working as intended.  A little time spent tuning and optimizing your various functions and loops will go a long way.   Sometimes an IF statement is faster than a switch. Likewise while vs. until vs. foreach… Take the time and try the various options.  Performance varies greatly depending on what type of object you’re working with, and what you’re doing with that object.   So far in my quest for posh speed I have found two things to be globally true:

  1. The less data you pass down the pipe line the faster your script will run.
  2. 99% of the time filtering at the source is 25%-50% faster then using select-object/where-object.

Along those lines I FINALY figured out how to do a “where not” WQL query!  Low and behold Glenn’s global laws of performance held true again…

If execution times are keeping you in the dark ages of automation.  Look no further than your own code.  I am yet to find a task where PowerShell doesn’t crush VBscript/WSH/BAT.

~Glenn

Managing required Snapins

I’m often hesitant to rely on snap-ins in my production scripts.  My fear is that a Jr Sysad will grab the script and attempt to run it.   Without the required Snap-ins the script will fail, and that failure will be “my fault”.  I solved this little problem by adding the following to any scripts that requires snap-ins.

write-Host “Loading required PSSnapins…”
# Load the PSCX if they are not already loaded…
if (!(Get-PSSnapin | ?{$_.name -eq “pscx”})){Add-PSSnapin pscx -ErrorAction Stop}

Now when the script fails I can at least point at the error, and say “what do you mean you don’t know why it’s not working, it’s right there!”

Thank you aleksandar !
Talk about doing it the hard way, all I had to do was add the “#requires” header to the first line of my scripts.

#requires -pssnapin pscx

Gotta love PowerShell every time you think you solved a problem, someone points out a feature of the parser that handles it natively!

~Glenn

Powershell Quote of the day!

There I was hanging out on the #powershell irc channel when sepeck said the following.

PowerShell is just fun to use, something vbScript never was

There is nothing I can add to that…

~Glenn

Simplify Get-VIServer

BSonPOSH took almost all the pain out of logging into Virtual Infrastructure with his get-credentials script.  That was still too much typing for me.  Every time I turned around I had timeout of my VC session.  My solution a small function added to my profile.

################### Start VMWARE ##################################

# Load Admin credentials
# Modified from http://bsonposh.com/archives/338

$creds = New-Object System.Management.Automation.PsCredential(“DomainUser-adm”, `
(Get-Content “$env:homesharescriptsmycreds.txt” | ConvertTo-SecureString)

# Load Vmware

IF (!(Get-PSSnapin | ?{$_.name -eq “VMware.VimAutomation.Core”}
{
Add-PSSnapin VMware.VimAutomation.Core
}

# Add VMware Community Extentions
# Requires Powershell V2
Add-Module “$env:homesharescriptsVMWareExtenstions.psm1”

Function Get-VC([string]$VCServer = “DefaultVCServer”)
{
Get-VIServer -Server $VCServer -Credentials $creds | Out-Null
}

Set-Alias GVC Get-VC

################### End VMWARE ####################################

Now when I want to connect to my primary VC Server I type.

PS > . GVC
that’s dot space GCV…

NOTE:  As far as how secure is this solution?  Well, my password is stored in a file.  That file cannot be interpreted by anyone other then me (similar to EFS).  Additionally I know some would mock globally loading $creds. However, I work on an isolated network, and my execution policy is set to ALLSigned.  I acknowledge that there is still a risk, but it’s one I can live with.

~Glenn

UPDATE:  VMware has changed the get-viserver cmdlet to connect-viserver more to come…

Command Line Licensing

I discovered that if you set the license server incorrectly, or if it can’t contact the license server, then ESX/VirtualCenter won’t let you change it. ESX seems to want to contact the old server before it will let you change to a new one.

Anyway, by modifying the /etc/vmware/license.cfg file, you can change the license server to what it should be (or just set it to an empty string and use VI Client). After modification, restart the management service:

Podcast Junky

Hi, my name is Glenn and I am a Podcast junky.  My addiction reached the point that my wife gave me an IPOD Shuffle specifically for my podcast’s.  I consume between 15 – 20 hours of content a week!  Sounds like a lot I know, but here’s my secret…

I have kids whom I love dearly, but the little buggers took all my study time.  About a year ago I found a couple of techcast and started subscribing… I listen to them whenever I’m in my car, or doing chores around the house.  That my friend is how I stay up to date.  Today I got the latest scoop on ThinApp while I did the dishes.  If you haven’t discovered these little gems check them out who knows you might learn something.

Some of my current subscriptions: 
http://www.cstechcast.com/
http://www.mindofroot.com/
http://powerscripting.net
http://www.runasradio.com/
http://www.grc.com/securitynow.htm

And this little gem I just found TODAY!
http://blogs.vmware.com/vmtn/podcasts/index.html

~Glenn