If you ever wanted to save a google search to a CSV file, you should check out SEOquake.
Recently I used SEOquake to generate 50 CSV files. The end goal was to work with these CSV files in Powershell. Unfortunately, each of the original files had a header that I wanted to remove.
I used the following powershell code to strip out the first 6 lines of each of these files:
After running that powershell code, I can now work with SEOquake output more easily inside of other powershell scripts.
Friday, November 27, 2015
Friday, July 24, 2015
Data Center Cleanup: Part 2
The next step in the cleanup process was deploying switches to each rack, commonly referred to as Top of Rack (ToR). We opted for a slightly different twist on this, and decided to install the switches in the bottom of the rack.
With ToR, when a cable is too long, there is the potential for droop.
With ToR, when a cable is too long, there is the potential for droop.
With this in mind, we opted to install the switch at the bottom of the rack. This way, excess cable collects at the bottom of the rack.
Still a bit messy, but another step toward forward.
Friday, July 10, 2015
Data Center Cleanup: Part 1
For quite some time, we had discussed "cleaning up" our data center. Past installations had made ongoing support tricky. For example, it was easy to accidentally bump a power cord and unplug a server. Additionally, it was very difficult to see / trace cables.
Fortunately, as part of a new project, we were given the green light to address the situation.
Fortunately, as part of a new project, we were given the green light to address the situation.
Here is an example of two of the server racks in our data center (before):
Clearly there were many issues that needed to be addressed. Where to start?
Most of the original power cords that came with the servers were 8 - 10 feet long black power cords.
Step 1: Color code and shorten the power cords lengths.
We swapped the original cords out with 2' red and blue power cords. The color coding now allows us to quickly confirm that each server (dual power supply server) is running on both the A & B PDU. Additionally, the shorter cables have allowed us to start to eliminate the extreme amount of excess cabling in our racks.
Step 1: Color code and shorten the power cords lengths.
We swapped the original cords out with 2' red and blue power cords. The color coding now allows us to quickly confirm that each server (dual power supply server) is running on both the A & B PDU. Additionally, the shorter cables have allowed us to start to eliminate the extreme amount of excess cabling in our racks.
Here are the power cords that we removed from just 1 cabinet. The excessive length of the power cords had obstructed our view of the servers. Additionally, the weight of the cables made it VERY easy for the cords fall out of the PDU.
Although this is just a beginning, at the end of the first step (left cabinet), we could finally start to glimpse the servers (after step 1).
![]() |
Monday, October 27, 2014
Nested loops
A number of years ago, the company I worked for needed to generate a large set of unique codes. The codes needed to be 5 digits long, and we wanted to remove the letters I and O and the numbers 1 and 0 from the listing. In an effort to avoid letting my PowerShell skills rust, I decided to recreate this project in PowerShell.
As I started thinking about ways to approach this, it occurred to me that I rarely seem to need to use nested loops. I assume there are other ways to solve this, but nesting seemed like fun. Maybe this outline will prove useful for someone looking to learn a little bit more about nesting.
I broke the problem down into two parts:
- Create an alphanumeric array that conforms to the requirements (removing the I,O,1, and 0)
- Create a series of nested loops, with each loop representing 1 of the places in the 5 digit code
Once finished, the output was written to a .CSV file, and it looked similar to the small sample below:
BH3NA
BH3NB
BH3NC
BH3ND
BH3NE
BH3NF
BH3NG
If you were to let this run to completion, I believe it would generate 24,000,000 + unique codes (this post is about PowerShell, not Finite mathematics).
Sunday, April 6, 2014
Powershell Intro
Was excited to learn that a friend's son is going to a technology camp this summer. Thought he might like this little bit of powershell code.
The code at the end of this post will ask what you want the computer to say, and then it will speak the text. Assuming you have a Windows computer, do the following to run the code:
1) Click on the Start button --> and type Run
2) type in Powershell ISE
3) Copy and paste the code at the bottom of the post into the powershell window (should look similar to the screen shot below)
4) Press F5 (or the icon that looks like a DVD Play button)
Code to copy and paste:
# ------------------------------------------------------# ignore this for now# ------------------------------------------------------$ErrorActionPreference= 'silentlycontinue'[Reflection.Assembly]::LoadWithPartialName('System.Speech')# ------------------------------------------------------# clear the screen# ------------------------------------------------------cls# ------------------------------------------------------# Ask what you want the computer to say and put that# info in the variable $phrase# ------------------------------------------------------$phrase = read-host -prompt "What do you what the computer to say?"# ------------------------------------------------------# ignore this for now# ------------------------------------------------------$object = New-Object -ComObject SAPI.SpVoice# ------------------------------------------------------# Write the variable $pharse to screen (not needed)# ------------------------------------------------------write-host $phrase# ------------------------------------------------------# Have the computer speak what was entered# ------------------------------------------------------$object.Speak($phrase)
Friday, January 24, 2014
The quizzer
The script outlined below is essentially a set of electronic flash cards. There are all sorts of websites & programs that offer similar functionality. That being said, I had a large set of terms I wanted to memorize, and this seemed like a fun way to get a little more Powershell experience.
Many parts of the script are VERY basic, but there were a few parts (Get-Random and hash tables) that were interesting to explore.
Here is an overview of the components of the script:
1) Read in a CSV of terms and definitions
2) Randomly pick a Term / Definition to quiz the user on
3) Generate a hash of the correct term (answer) and 4 other false answers
4) Randomize the hash and present to the user
5) Prompt the user to select an answer and evaluate the response
Click here for the full script
Many parts of the script are VERY basic, but there were a few parts (Get-Random and hash tables) that were interesting to explore.
Here is an overview of the components of the script:
1) Read in a CSV of terms and definitions
2) Randomly pick a Term / Definition to quiz the user on
3) Generate a hash of the correct term (answer) and 4 other false answers
4) Randomize the hash and present to the user
5) Prompt the user to select an answer and evaluate the response
Click here for the full script
Saturday, January 18, 2014
Faster DNS Resolution
Recently a friend shared a link from TechRepublic that suggested changing your DNS servers in order improve web browsing speeds.
This seemed interesting and I initially changed my home DNS servers to 8.8.8.8 and 8.8.4.4. Afterward, I started to wonder if my Internet provider might be able to route to one DNS server faster than another. Additionally, it seemed logical to assume that the actual resolution could potentially be done faster on one DNS server farm than another.
It seemed like it would be neat to validate existing performance vs. the suggested DNS servers listed in the TechRepublic article. The idea would be to highlight if a DNS server change would be beneficial on your home network.
Here is the type of output I ended up with:
10.10.1.1 is an internal DNS server and should not be modified
10.10.1.2 is an internal DNS server and should not be modified
Resolution times by DNS Servers (best to worst)
Name Value
208.67.222.222 00:00:00.0728325
75.75.75.75* 00:00:00.0740533
208.67.220.220 00:00:00.0813375
8.8.8.8 00:00:00.0988982
8.8.4.4 00:00:00.1096580
208.67.222.222 00:00:00.0728325
75.75.75.75* 00:00:00.0740533
208.67.220.220 00:00:00.0813375
8.8.8.8 00:00:00.0988982
8.8.4.4 00:00:00.1096580
* - denotes your existing DNS server
If you would like to test your current DNS settings, you are welcome to try the following powershell script on your system:
$ErrorActionPreference = "SilentlyContinue"
cls
$DNS = Get-WmiObject Win32_NetworkAdapterConfiguration -computername . | select DNSServerSearchOrder
$names = $dns.DNSServerSearchOrder
$techRepublicSuggested = ("208.67.222.222", "208.67.220.220", "8.8.8.8", "8.8.4.4")
$names = $names + $techRepublicSuggested
Foreach ($name in $names)
{
if (($name -like "10.*") -or ($name -like "176.*") -or ($name -like "192.168.*"))
{
Write-Host "$name is an internal DNS server and should not be modified"
$names = $names -replace $name
}
}
Write-Host ""
$names = $names | Where { $_.Trim(" `t")}
$hashlatency = @{}
$hashresolve = @{}
Foreach ($name in $names)
{
$resTime = Measure-command {resolve-dnsname systemzengineer.blogspot.com -server $name}
if ($techRepublicSuggested -notcontains $name)
{$name = $name + "*"}
$hashresolve.add($name, $resTime)
}
Write-Host "Resolution times by DNS Servers (best to worst)"
$hashresolve.GetEnumerator() | Sort-Object Value
Write-Host ""
Write-Host "* - denotes your existing DNS server"
Subscribe to:
Posts (Atom)