Thursday, 12 February 2009
Geek Rhyming Slang
This started (for me anyway) when my wife told people I was away at Geek Week, i.e. Teched EMEA and I had for a long time described my (or lack of as others might say) own fashion style as Geek Chic. Anyway after the legends of the IT Crowd used my Geek Chic phrase (OK, I'm claiming it) multiple times during one of their recent shows I decided to try and find some more and here's the results. Special thanks to @Jaykul, @Poshoholic and @ebgreen for the contributions.
Translations added for any non-Geek Speak(ers)
Geek Week - an IT conference like Teched, VMworld
Geek Chic - fashion style (or lack of, can be either) displayed by an IT pro
Geek Speak - jargon filled conversation
Geek Freak - a person who (pretends to be?) hot for geeks
Geek Bleak - how geeks normally decorate
Geek Cheek - when IT thinks management can't touch them
Geek Antique - a TRS-80, Amiga, or C-64
Geek Boutique - Fry's, Best Buy, Future Shop
Geek Physique - Wii Sports/Fitness
Geek Tweak - a bug fix
Geek Shriek - the sound of a wedgie
Geek Clique - a huddle of geeks
Geek Peak'd - completing a IT project
Geek Mystique - this aura surrounds you when you do "exactly what I did" for a coworker, but it works for you on the first try
Geek Critique - ripping each other apart bassed on minutiae and technycalities and misspellings
Geek Oblique - our version of subtle -- when you have to explain the joke, in case people don't know what oblique means
Geek Technique - This is how we (over) do it
I'm on a Geek Streak........
Translations added for any non-Geek Speak(ers)
Geek Week - an IT conference like Teched, VMworld
Geek Chic - fashion style (or lack of, can be either) displayed by an IT pro
Geek Speak - jargon filled conversation
Geek Freak - a person who (pretends to be?) hot for geeks
Geek Bleak - how geeks normally decorate
Geek Cheek - when IT thinks management can't touch them
Geek Antique - a TRS-80, Amiga, or C-64
Geek Boutique - Fry's, Best Buy, Future Shop
Geek Physique - Wii Sports/Fitness
Geek Tweak - a bug fix
Geek Shriek - the sound of a wedgie
Geek Clique - a huddle of geeks
Geek Peak'd - completing a IT project
Geek Mystique - this aura surrounds you when you do "exactly what I did" for a coworker, but it works for you on the first try
Geek Critique - ripping each other apart bassed on minutiae and technycalities and misspellings
Geek Oblique - our version of subtle -- when you have to explain the joke, in case people don't know what oblique means
Geek Technique - This is how we (over) do it
I'm on a Geek Streak........
Monday, 2 February 2009
Upcoming for the UK Powershell User Group
Coming up in February are two events for the UK Powershell User Group.
1) Following the Technet Event Managing Windows Servers with Powershell V2 on Feb 10th at Microsoft London there will be a Powershell UserGroup meeting.
My good friend Jonathan Noble will be travelling down all the way from the North of England to present for us about using Powershell to automate tasks in the large University environment he works in - well worth turning up for. Let Richard Siddaway know if you wish to attend.
Sometime between the afternoon Technet Event and the evening User Group I shall be interviewing Jonathan for the Get-Scripting Podcast.
2) February 26th Rolf Mausch, who runs the German Powershell User Group, will be presenting a live webcast for us about using Powershell in login scripts - an interesting topic since not a lot of people are doing that yet from what I have seen. Early details here.
1) Following the Technet Event Managing Windows Servers with Powershell V2 on Feb 10th at Microsoft London there will be a Powershell UserGroup meeting.
My good friend Jonathan Noble will be travelling down all the way from the North of England to present for us about using Powershell to automate tasks in the large University environment he works in - well worth turning up for. Let Richard Siddaway know if you wish to attend.
Sometime between the afternoon Technet Event and the evening User Group I shall be interviewing Jonathan for the Get-Scripting Podcast.
2) February 26th Rolf Mausch, who runs the German Powershell User Group, will be presenting a live webcast for us about using Powershell in login scripts - an interesting topic since not a lot of people are doing that yet from what I have seen. Early details here.
Windows 2003 Password Policy - Complexity Requirements Message
Doing a lot of investigation into password policies available in Windows Server 2003 and 2008 at the minute, plus some of the third-party solutions available around this area.
One of the reasons I've never myself recommend using the 'Complexity On' feature in Windows Server is the sheer difficulty in trying to explain to users that you need to use characters from at least three of the following four groups:
They typically switch off as soon as you get to the ...at least three.... part of the above sentence and to be honest I don't really blame them.
Even if you do head down this solution (good luck to you!) the message a user gets back when they fail to change their password successfully is fairly generic and does not even mention the fact that complexity is in use.
However, today I was made aware of a hotfix for Windows 2003 (and associated clients) where the user will now see mention of complexity requirements in the message they receive back. Since I've never heard or seen anyone else using this before I thought it was worth mentioning since it might make your deployment a bit smoother.
I've yet to test this out myself, but I guess you gotta trust the KB article ;-)
One of the reasons I've never myself recommend using the 'Complexity On' feature in Windows Server is the sheer difficulty in trying to explain to users that you need to use characters from at least three of the following four groups:
- Uppercase
- Lowercase
- Digits
- Special Characters
They typically switch off as soon as you get to the ...at least three.... part of the above sentence and to be honest I don't really blame them.
Even if you do head down this solution (good luck to you!) the message a user gets back when they fail to change their password successfully is fairly generic and does not even mention the fact that complexity is in use.
However, today I was made aware of a hotfix for Windows 2003 (and associated clients) where the user will now see mention of complexity requirements in the message they receive back. Since I've never heard or seen anyone else using this before I thought it was worth mentioning since it might make your deployment a bit smoother.
I've yet to test this out myself, but I guess you gotta trust the KB article ;-)
Wednesday, 28 January 2009
Using Powershell to Find Free Space in Exchange 2003 databases
One regular task for Exchange admins can be reclaiming free space within Exchange mailbox stores either after a large amount of data has been removed or just a significant amount has built up over time for various reasons. For those of you who don't know, to reclaim the space the mailbox store has to be taken offline and the database defragged to get the space back on the disk.
Finding good candidates for defragging especially in a large environment with multiple databases and Exchange servers can be a pretty tedious task. Exchange records an entry in the Application Event Log (Event ID 1221) after online maintenance has taken place which tells you how much free space is in the database - this means trawling through the event logs on each server and recording which databases you think are worth defragging. So naturally I wrote a Powershell script to save wasting time on this task!
Using WMI the script queries the Application log on each of the Exchange servers you choose, looking for 1221 events in the last day. It sucks out the name of the mailbox store and the amount of free space in the database from the message field of the event and if the free space is greater than a particular figure (in the example below 3GB) adds the info to a csv file.
You could obviously change the figure to meet your needs and also if you remove the if statement you could get it to report on every database so you have a report of free space across all databases.
Tip: If you have clustered mailbox servers then you only need to point the script at one of the servers in the cluster since it will contain all of the event log entries for each server in the cluster.
#Check to see if csv exists and if so remove it
If (Test-Path "FreeSpaceGreaterThan1GB.csv")
{
Remove-Item "FreeSpaceGreaterThan1GB.csv"
}
Else
{
}
#Set the columns for the csv file
$rows = "Servername," + "Mailbox Store," + "Free Space (MB),"
Add-Content FreeSpaceGreaterThan1GB.csv $rows
$ExchServer = 'server1','server2'
foreach ($Server in $ExchServer){
#Get the time 1 day ago in the right format for WMI query
$WmidtQueryDT = [System.Management.ManagementDateTimeConverter]::ToDmtfDateTime([DateTime]::Now.AddDays(-1))
#Perform WMI query of Event 1221 in Application log in the last day
$1221 = Get-WmiObject -computer $ExchServer -query ("Select * from Win32_NTLogEvent Where Logfile='Application' and Eventcode = '1221' and TimeWritten >='" + $WmidtQueryDT + "'")
foreach ($event in $1221){
#Get the name of the Mailbox Store
$MBXStoreLocationStart = $event.Message.IndexOf("Storage Group") + 16
$MBXStoreLocationFinish = $event.Message.IndexOf("has") - 2
$MBXStoreLocation = $event.Message.SubString($MBXStoreLocationStart, $MBXStoreLocationFinish - $MBXStoreLocationStart)
#Get the free space figure and convert it to an integer
$MBLocationStart = $event.Message.IndexOf("has") + 4
$MBLocationFinish = $event.Message.IndexOf("megabytes") - 1
$MBLocation = $event.Message.SubString($MBLocationStart, $MBLocationFinish - $MBLocationStart)
$result = [int]$MBLocation
$ComputerName = $event.ComputerName
#If free space > 3GB, add the details to the csv file
if ($result -ge 3072){
$rowline = "$ComputerName," + "$MBXStoreLocation," + "$MBLocation,"
Add-Content FreeSpaceGreaterThan1GB.csv $rowline
}
else
{
}
}
}
Finding good candidates for defragging especially in a large environment with multiple databases and Exchange servers can be a pretty tedious task. Exchange records an entry in the Application Event Log (Event ID 1221) after online maintenance has taken place which tells you how much free space is in the database - this means trawling through the event logs on each server and recording which databases you think are worth defragging. So naturally I wrote a Powershell script to save wasting time on this task!
Using WMI the script queries the Application log on each of the Exchange servers you choose, looking for 1221 events in the last day. It sucks out the name of the mailbox store and the amount of free space in the database from the message field of the event and if the free space is greater than a particular figure (in the example below 3GB) adds the info to a csv file.
You could obviously change the figure to meet your needs and also if you remove the if statement you could get it to report on every database so you have a report of free space across all databases.
Tip: If you have clustered mailbox servers then you only need to point the script at one of the servers in the cluster since it will contain all of the event log entries for each server in the cluster.
#Check to see if csv exists and if so remove it
If (Test-Path "FreeSpaceGreaterThan1GB.csv")
{
Remove-Item "FreeSpaceGreaterThan1GB.csv"
}
Else
{
}
#Set the columns for the csv file
$rows = "Servername," + "Mailbox Store," + "Free Space (MB),"
Add-Content FreeSpaceGreaterThan1GB.csv $rows
$ExchServer = 'server1','server2'
foreach ($Server in $ExchServer){
#Get the time 1 day ago in the right format for WMI query
$WmidtQueryDT = [System.Management.ManagementDateTimeConverter]::ToDmtfDateTime([DateTime]::Now.AddDays(-1))
#Perform WMI query of Event 1221 in Application log in the last day
$1221 = Get-WmiObject -computer $ExchServer -query ("Select * from Win32_NTLogEvent Where Logfile='Application' and Eventcode = '1221' and TimeWritten >='" + $WmidtQueryDT + "'")
foreach ($event in $1221){
#Get the name of the Mailbox Store
$MBXStoreLocationStart = $event.Message.IndexOf("Storage Group") + 16
$MBXStoreLocationFinish = $event.Message.IndexOf("has") - 2
$MBXStoreLocation = $event.Message.SubString($MBXStoreLocationStart, $MBXStoreLocationFinish - $MBXStoreLocationStart)
#Get the free space figure and convert it to an integer
$MBLocationStart = $event.Message.IndexOf("has") + 4
$MBLocationFinish = $event.Message.IndexOf("megabytes") - 1
$MBLocation = $event.Message.SubString($MBLocationStart, $MBLocationFinish - $MBLocationStart)
$result = [int]$MBLocation
$ComputerName = $event.ComputerName
#If free space > 3GB, add the details to the csv file
if ($result -ge 3072){
$rowline = "$ComputerName," + "$MBXStoreLocation," + "$MBLocation,"
Add-Content FreeSpaceGreaterThan1GB.csv $rowline
}
else
{
}
}
}
Sunday, 25 January 2009
Using Powershell to Monitor VMware Guests - on a Budget...
...i.e. a budget of £0.
(Update 28/01/09 - FYI..got some feedback about this post and the reason we are not using the built in alerts in the VI client is because the CPU alerts in this case were not granular enough for us.)
So this all stemmed from trying to track down which process was causing particular servers' CPU to hit 100% for a period. So first of all my colleague and Get-Scripting co-host Alan Renouf traded a script back and forth which ended up as the CheckHighCPU function - it is now pretty cool and comes back with a list of processes sorted by how much CPU they are using and very importantly for our circumstance who is the owner of each process.
The servers in question all belong to a particular cluster in ESX. Rather than constantly having to monitor the console, wait for a VM to turn red and then run the script to track down the process we decided to try and monitor them with a Powershell script, kick off the CheckHighCPU function when a server's CPU hit 100% for a significant enough period and email a warning through with the process details - and so the below script was born.
OK, its not Operations Manager and to be honest its not really production quality, but it does the job we need it to.
The VI Toolkit from VMware is a great set of cmdlets you can plug into your Powershell console to manage your VMware environment. You can use the Get-Cluster and Get-VM cmdlets to return a list of all the VM's in that cluster as objects. You can then use the very handy Get-Stat cmdlet to retrieve performance data for each VM.
In this case we check the cpu.usage.average statistic of a period of the last few minutes (watch out for the -IntervalMins parameter it can produce a period slightly different to what you would expect) and if its over 99% run the CheckHighCPU function and send the results by email.
We then make the script sleep for a short time period so that we are not constantly bombarded with alerts if a warning is triggered.
Obviously if we wanted to make it production quality we would add in some error checking and testing to see if an alert had recently been sent, but for the time being its doing a great job for the requirements that exist.
You could obviously re-use the below to monitor for different statistics offered by Get-Stat like disk or memory.
Function EmailWarning ()
{param ($ServerName,$Attachment)
#Email warning
Write-Output "Creating E-Mail Structure"
$smtpServer = "servername"
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($attachment)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = "sender"
$msg.To.Add("recipient")
$msg.Subject = "Server Warning - High CPU on $Servername"
$msg.Body = "$Servername has a CPU value of $HighCPU %"
$msg.Attachments.Add($att)
Write-Output "Send E-Mail"
$smtp.Send($msg)
$att.Dispose();
}
Function CheckHighCPU ()
{param ($Target)
$procs_total = Get-WmiObject -Class Win32_PerfRawData_PerfProc_Process -Filter 'name="_total"' -ComputerName $Target
$procs = Get-WmiObject -Class Win32_PerfRawData_PerfProc_Process -Filter 'name<>"_total"' -ComputerName $Target
[int64]$totalpercentuser = 0
foreach ($proc in $procs_total)
{$totalpercentuser = $totalpercentuser + $proc.PercentUserTime}
[decimal] $perc = [System.Convert]::ToDecimal($totalpercentuser)
$myCol = @()
Foreach ($proc in $procs){
$proc_perct = (($proc.PercentUserTime / $perc) * 100)
if ($proc_perct -gt 1){
$Process = Get-WmiObject win32_process -ComputerName $target | where {$_.ProcessID -eq $proc.IDProcess}
$MYInfo = "" | select-Object Name, CPUUsage,Owner, ProcessID
$MYInfo.Name = $proc.name
$MYInfo.ProcessID = $proc.IdProcess
$MYInfo.CPUUsage = [Math]::Round($proc_perct, 0)
$MYInfo.Owner = $process.GetOwner().user
$myCol += $MYInfo
}
}
$myCol | Sort-Object CPUUsage -Descending | Out-File $file
EmailWarning $VMname $file
}
Connect-VIServer servername
$vms = Get-Cluster clustername | get-vm
$time = Get-Date
do {
foreach ($vm in $vms){
$VMname = $vm.name
$filename = $VMname + '.txt'
$file = "C:\Scripts\$filename"
$stats = Get-Stat -entity $vm -IntervalMins 2 -stat cpu.usage.average -MaxSamples 1
write-host $VMname
$stats
if ($stats.value -ge 99){
$HighCPU = $stats.value
Write-Host "Warning!" -ForegroundColor red
CheckHighCPU $VMname
}
else
{
}
}
Start-Sleep -Seconds 30
}
until ($time.hour -ge 17)
(Update 28/01/09 - FYI..got some feedback about this post and the reason we are not using the built in alerts in the VI client is because the CPU alerts in this case were not granular enough for us.)
So this all stemmed from trying to track down which process was causing particular servers' CPU to hit 100% for a period. So first of all my colleague and Get-Scripting co-host Alan Renouf traded a script back and forth which ended up as the CheckHighCPU function - it is now pretty cool and comes back with a list of processes sorted by how much CPU they are using and very importantly for our circumstance who is the owner of each process.
The servers in question all belong to a particular cluster in ESX. Rather than constantly having to monitor the console, wait for a VM to turn red and then run the script to track down the process we decided to try and monitor them with a Powershell script, kick off the CheckHighCPU function when a server's CPU hit 100% for a significant enough period and email a warning through with the process details - and so the below script was born.
OK, its not Operations Manager and to be honest its not really production quality, but it does the job we need it to.
The VI Toolkit from VMware is a great set of cmdlets you can plug into your Powershell console to manage your VMware environment. You can use the Get-Cluster and Get-VM cmdlets to return a list of all the VM's in that cluster as objects. You can then use the very handy Get-Stat cmdlet to retrieve performance data for each VM.
In this case we check the cpu.usage.average statistic of a period of the last few minutes (watch out for the -IntervalMins parameter it can produce a period slightly different to what you would expect) and if its over 99% run the CheckHighCPU function and send the results by email.
We then make the script sleep for a short time period so that we are not constantly bombarded with alerts if a warning is triggered.
Obviously if we wanted to make it production quality we would add in some error checking and testing to see if an alert had recently been sent, but for the time being its doing a great job for the requirements that exist.
You could obviously re-use the below to monitor for different statistics offered by Get-Stat like disk or memory.
Function EmailWarning ()
{param ($ServerName,$Attachment)
#Email warning
Write-Output "Creating E-Mail Structure"
$smtpServer = "servername"
$msg = new-object Net.Mail.MailMessage
$att = new-object Net.Mail.Attachment($attachment)
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = "sender"
$msg.To.Add("recipient")
$msg.Subject = "Server Warning - High CPU on $Servername"
$msg.Body = "$Servername has a CPU value of $HighCPU %"
$msg.Attachments.Add($att)
Write-Output "Send E-Mail"
$smtp.Send($msg)
$att.Dispose();
}
Function CheckHighCPU ()
{param ($Target)
$procs_total = Get-WmiObject -Class Win32_PerfRawData_PerfProc_Process -Filter 'name="_total"' -ComputerName $Target
$procs = Get-WmiObject -Class Win32_PerfRawData_PerfProc_Process -Filter 'name<>"_total"' -ComputerName $Target
[int64]$totalpercentuser = 0
foreach ($proc in $procs_total)
{$totalpercentuser = $totalpercentuser + $proc.PercentUserTime}
[decimal] $perc = [System.Convert]::ToDecimal($totalpercentuser)
$myCol = @()
Foreach ($proc in $procs){
$proc_perct = (($proc.PercentUserTime / $perc) * 100)
if ($proc_perct -gt 1){
$Process = Get-WmiObject win32_process -ComputerName $target | where {$_.ProcessID -eq $proc.IDProcess}
$MYInfo = "" | select-Object Name, CPUUsage,Owner, ProcessID
$MYInfo.Name = $proc.name
$MYInfo.ProcessID = $proc.IdProcess
$MYInfo.CPUUsage = [Math]::Round($proc_perct, 0)
$MYInfo.Owner = $process.GetOwner().user
$myCol += $MYInfo
}
}
$myCol | Sort-Object CPUUsage -Descending | Out-File $file
EmailWarning $VMname $file
}
Connect-VIServer servername
$vms = Get-Cluster clustername | get-vm
$time = Get-Date
do {
foreach ($vm in $vms){
$VMname = $vm.name
$filename = $VMname + '.txt'
$file = "C:\Scripts\$filename"
$stats = Get-Stat -entity $vm -IntervalMins 2 -stat cpu.usage.average -MaxSamples 1
write-host $VMname
$stats
if ($stats.value -ge 99){
$HighCPU = $stats.value
Write-Host "Warning!" -ForegroundColor red
CheckHighCPU $VMname
}
else
{
}
}
Start-Sleep -Seconds 30
}
until ($time.hour -ge 17)
Presenting at MM&M User Group UK - Wednesday 18th February
So I was lucky enough to receive an invite from Nathan Winters who runs the MM&M User Group UK (aka Exchange) to present at their next meeting on Wednesday 18th February at Microsoft in London.
It will be an evening around using Powershell to manage Exchange, the agenda is as below:
If you want to attend you can sign up here http://www.mmmug.co.uk/forums/thread/26352.aspx
It will be an evening around using Powershell to manage Exchange, the agenda is as below:
18:15 - 18:40 Arrival
18:40 - 18:45 Introduction to speakers and the aims of the group
18:45 - 19:30 1st session; Jonathan Medd, Introduction to PowerShell and Using PowerShell to manage Exchange 2003!
19:30 - 19:50 Food!
19:50 - 20:45 2nd session; Will Rawlings, Causing no harm with PowerShell, and using PowerShell on a large Exchange environment
20:45 - 21:00 Summing up and suggestions for future meetings.
If you want to attend you can sign up here http://www.mmmug.co.uk/forums/thread/26352.aspx
Tuesday, 13 January 2009
UK Powershell User Group - January Meeting
The January meeting of the UK Powershell User Group takes place Wednesday 21st Jan 2009 6.30pm GMT.
It should be a great evening. Jeffrey is obviously the man to ask if you have any burning questions about Powershell, particularly V2 for this event. Jeremy is a long time member of the user group and is incredibly knowledgeable about Powershell so I'm really looking forward to seeing what he is going to talk about.
If you want to turn up please contact Richard Siddaway at the below website, you can also find details of the webcast if you wish to watch from afar.
http://richardsiddaway.spaces.live.com/blog/cns!43CFA46A74CF3E96!1987.entry
Memphis Room
Building 3
Microsoft Campus TVP
Reading UK
We have a Live Meeting with Jeffrey Snover talking about PowerShell v2
Pizza break
Then Jeremy Pack from HP will then be doing a PowerShell demo - exact topic to be confirmed
It should be a great evening. Jeffrey is obviously the man to ask if you have any burning questions about Powershell, particularly V2 for this event. Jeremy is a long time member of the user group and is incredibly knowledgeable about Powershell so I'm really looking forward to seeing what he is going to talk about.
If you want to turn up please contact Richard Siddaway at the below website, you can also find details of the webcast if you wish to watch from afar.
http://richardsiddaway.spaces.live.com/blog/cns!43CFA46A74CF3E96!1987.entry
Subscribe to:
Posts (Atom)