Friday, March 29, 2013

Configuring Network Connections in Windows 2008R2

A project I have been working on required us to add another NIC to all of our servers.  We didn't want production traffic accidentally being routed over that subnet.  Below are the steps we took on the servers to prevent it.


  • Hit the Windows+R keys simultaneously
  • Type control netconnections and then click OK
  • Right Click on the connection you don't want traffic to go over and select Properties.
  • Uncheck all item except for Internet Protocol Version 4 (TCP/IPv4).

  • Right click on IPv4 and select Properties and set a static IP address for the new subnet.  In the picture below the IP is just an example (shouldn't use .1 as that is normally for your gateway)
  • Click on Advanced and select the DNS tab.  Uncheck Register this connection's addresses in DNS.  Click on OK and OK to save the changes
  • Right click on the connection we just changed and select Rename
  • Pick a descriptive name for this connection
  • While in the Network Connections Window hit the Alt key.  You should see a hidden menu pop up at the top.  Click on Advanced à Advanced Settings
  • Change the connection you renamed to be below the other connections.
  • Click on OK to save the changes.
  • Next we want to make sure another default gateway wasn't created when the NIC was added.  Open up a command prompt and type in route print
  • If there are more than one default gateways (0.0.0.0) and one of them is the new subnet you will need to remove it.
  • route DELETE 0.0.0.0 255.255.255.0 10.10.10.1 servername



Wednesday, March 20, 2013

Finding URLs in Text Files with PowerShell

Allot of our connection string information is stored in our web.config files.  For a project I am working on I was asked to create a list of all of these.  This will help us determine what third parties we interface with so a new firewall can be setup accurately.  Below is the PowerShell script I came up with the help of others posts on the web.  I haven't gotten the syntax highlighter working yet on my blog but hopefully soon (I will come back and edit this post).

########################################################### 
# AUTHOR  : Mark Rainey  
# DATE    : 2013-03-13  
# COMMENT : Reads in a list of servers and searches
# the E:\Live folder for config files.  When it finds
# them it searches for anything starting with 3 or more
# letters (tcp or http) followed by a colon and \\
###########################################################

#ERROR REPORTING ALL
Set-StrictMode -Version latest

$scriptpath = Split-Path -parent $MyInvocation.MyCommand.Definition
# A friend at work helped me get this to output to Excel
$outputFile = $scriptpath + "\output.xls"
# This is a file with a FQDN of each server on a new line
$serverList = $scriptpath + "\serverlist.txt"
# Load server list
$servers = Get-Content $serverList
# Hash of all results from all files
$Results=@{}

# Find the string and save it to a file
Function getStringMatch
{
 Try { 
  # Loop through all servers
  Foreach ($server In $servers) {
      # Set UNC Path to files for this server
   #The path can be anywhere on your servers you want to search
   $path     = "\\$server\c$\temp\test\"
   #Get list of files
   $files    = Get-Childitem $path *.config -Recurse | Where-Object { !($_.psiscontainer) }
   # Loop through the server and search all config files under E:\Live
      $matches = New-Object System.Collections.ArrayList
   $matches.clear()
   Foreach ($file In $files)
      {
    $fullFileName = $file.FullName 
    # regular expression for a URL format
    $regex = '([a-zA-Z]{3,})://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)*?'
                # Find all matches in current file and add the Value for each one to an array
    select-string -Path $fullFileName -Pattern $regex -AllMatches | % { $_.Matches } | % {
     $matches.add($_.Value)
    }
      } 
   # Remove duplicates
            $matches = $matches | select -Unique 
   # Add the array for this server to the Results hash
   $Results.Add($server,$matches)
  }
  
  #export to Excel workbook
  $excel = New-Object -comobject Excel.Application
  $excel.Visible = $True
  $workbook = $excel.Workbooks.Add()
  $ws = $workbook.Worksheets.Item(1)
  $column = 1

  foreach ($Result in $Results.GetEnumerator()){
   $row = 1
   $ws.Cells.Item($row,$column) = $Result.Key; 
   $row++
   if ($Result.Value -ne $null){
    if ($Result.Value.Count -gt 1){
     for ($i=0; $i -le $Result.Value.Count; $i++ ) {
      $ws.Cells.Item($row,$column) = $Result.Value[$i]
      $row++
     }
    }
    else {
     $ws.Cells.Item($row,$column) = $Result.Value
    }
   }
   $column++
  }
  $workbook.SaveAs($outputFile)
  
  Release-Ref $ws
  Release-Ref $workbook
  $excel.Quit()
  Release-Ref $excel
 }
    Catch [System.Management.Automation.ActionPreferenceStopException]{
  Write-host "$output is locked see error:`n $_"
 } 
 Catch {
  Write-host "Something failed $_"
 }
 Finally {
  "Finished"
 }
}

# Release Reference used in Office coms
Function Release-Ref ($ref) {
 [System.Runtime.InteropServices.Marshal]::ReleaseComObject($ref)
 [System.GC]::Collect() 
 [System.GC]::WaitForPendingFinalizers()
}
 
getStringMatch

Tuesday, March 12, 2013

BuildMaster, Tool or Person?


BuildMaster, Tool or Person?

BuildMaster

What is it?

Well there is such a thing at companies and there is a book by a similar name.  However what I am referring to is a tool called BuildMaster that is developed by Inedo in Berea, Ohio.

Why use it?

Tools are made for a reason.  They make life simpler.  My computer is a tool.  My car is a tool.  BuildMaster was able to take a manual task that 2 guys had to do and reduce the time by 75% and reduce errors by almost 100%.  So unlike my car which only looses value this tool paid for itself in 1 year.

My Interview

I did an interview of my experiences with the tool and the company.  They have it posted as one of their case studies.  Here it is.  I had a good time chatting with them and hope that people considering it get something useful out of it.

Tuesday, March 5, 2013

Candy Sale

Understanding Subcultures

I have been selling candy bars at work for a few weeks now to help raise money for my kids religious education classes.  A bar or two a day was all I sold to my fellow IT co workers.  I consider my cubicle hi traffic compared to most as people stop by to ask various questions about our complex environment.  It would seem what I consider allot of traffic is nothing to the other cultures in my building.

A friend in customer care was willing to sell some candy for me this afternoon.  In a matter of 4 hours the person had sold 8 bars.  Is it gender of the group or social inclination?  There is allot more conversations going on in that area and in general people talk to each other more in person.  Down on my floor which is mostly IT, my fellow geeks have there heads down working.  If they need to talk they prefer emails and instant messaging.

Which is better?

I have always wondered which culture accomplishes more.  Those that talk allot with each other and discuss things or those who work with their heads down focused and leave the communication to their leaders.

****Update on 3/7****
I guess it is the person not the culture??  Yesterday the person was in training but the bars were at the desk.  0 bars sold.

Friday, March 1, 2013

Things you might not want to say in an interview

Don't say these things

  • "co-worker of the female persuasion"
  • When asked about motivating/persuading resources; "I would trick them"
  • When interviewing for an IT job you tell the interviewer that you like the business side of things
As I get others I will post them.  

My Tips

  • In general don't say negative things about previous co-workers or companies.  Talk about the challenges you faced and how you improved things.  
  • Make sure you cut your fingernails if you are a man.  
  • When asked to give a specific answer make sure you do.  
  • Don't go on for 10 minutes about how one of your co-workers did something.  I want to know what you did.
  • When asked a question don't start off your reply with a joke.  My goal is to find out if you are the right fit for the job and not how funny you are.