Friday, August 7, 2009

Powershell script for prepending and appending text

I recently had the need to go through a text file and prepend a string to every line, and while that's ok for a couple of lines it doesn't work for a file with hundreds and thousands of lines. So here's the powershell command to do that:


get-content file.txt | foreach-object {add-content output.txt "text_to_add $_"}


This goes through every line in file.txt, adds "text_to_add" followed by a space and then whatever was on the original line (which is put in by the $_ ) and then writes that out to output.txt.


If you wanted to append to the end of every line it would be:


get-content file.txt | foreach-object {add-content output.txt "$_ text_to_add "}


If you wanted search for and replace only specific lines you'd write a function to do so which a good example of searching through a text file I've found here.


Wednesday, July 15, 2009

Cisco DHCP options for Nortel IP Phones

This took longer to track down via google than it should have when I was looking. So here it is simple and to the point for running Nortel IP Phones with cisco DHCP:

dhcpd option 128 ascii Nortel-i2004-A,1.1.1.1:4100,1,1;2.2.2.2:4100,1,10. interface inside

I used examples of s1: 1.1.1.1 and s2: 2.2.2.2 Of course your IPs will substitute there.

One thing to note, if you have a certain model of Nortel system (or have changed the listening port on yours) the 4100 in the command will of course be a different port...

here's the syntax:

Nortel-i2004-A,iii.iii.iii.iii:ppppp,aaa,rrr;iii.iii.iii.iii:ppppp,aaa,rrr.

“A” = the Hardware Revision of the i2004 Phone
“iii.iii.iii.iii” = the IP Address of the Call Server (S1 or S2)
“ppppp” = port number for the Call Server
“aaa” = the Action for the Server
“rrr” = the Retry Count for the Server

Tuesday, June 30, 2009

Backup your Print Server (with server 2008)

The handy printer migration tool you might have used in 03 has now morphed into the command line utility printbrm in server 08 (Syntax here). Pretty straightforward, simply add print services to your 08 machine and then run the following command to backup:

printbrm -s \\server_to_backup -b -f c:\PrintServerBackups\servername.printerExport

The printbrm command is located in %windir%\system32\spool\tools

Wednesday, June 24, 2009

What Computer Should I Buy?

The following is my personal advice when people usually ask me the age-old question of "I need a computer, what should I buy?"

This advice is for you if:
  • You're a mainstream computer user who will use their computer like 75% of people out there (office documents, photos, Internet, music, email)
  • You don't care or probably won't ever upgrade your machine, open it up, understand what a SATA cable is, etc, etc.
  • You don't need to be able to play the absolute newest computer games as fast as they can possibly be run
  • You're not going to be doing graphic or video editing or other resource intense things on your computer
  • You don't have a need to run 12 or 24 programs all at the same time on your machine
Note: The following are my opinions as a result of my experience in IT and don't come with any sort of warranty, express or implied. Aka if you're buying a computer you're an adult and can make decisions like an adult. If you don't trust me feel free to research any of the information below yourself. Feel free to comment however I'm not here to help you buy a computer any further than this blog post.

Ok on to the advice:


What Brand - Buy a well known brand: Dell, HP, Compaq (made by HP), IBM/Lenovo, Apple etc.

New or Used - Computers are cheap, unless you're really strapped for cash and willing to take a gamble, buy new.

Build Your Own or Buy - If it's a hobby and you have the resources (time, knowledge, and money) to spend on it feel free to build your own system from buying all the individual parts. It's not rocket science but it will take some time and you do risk having problems along the way. You may save a little cash but if you factor in your time it's probably more expensive to build. Plus in buying you have one company to deal with if it breaks and one company that will ensure that all the components in the machine all work together.

Warranty - Get an appropriate warranty. Know what warranty you are buying! Some require you to ship the machine in which you may or may not like. There is also extra 'accidental' coverage that applies if you spill a drink on your laptop. Maybe you need it, maybe you don't. Match warranty to need and cost. Be emotionally ok with the machine breaking 1 day after your warranty is expired.

Cost - If you don't need it yesterday hunt for a deal. Check paper ads for your local electronics retailer, Dell Specials, slickdeals.net, Black Friday/Cyber Monday, that kinda stuff. Don't spend a lot. For the cost of 1 top-end machine you can buy a middle of the road machine and completely replace it with an even faster machine in 2 or 3 years.

Buy Online or From a Store
- Both have their pros and cons just be aware that there will be variance on the knowledge of sales people (just like with people on the Internet) and take everything they say with a grain of salt, like any sales person :) If you buy online, be sure to buy through a reputable retailer.

PC vs Mac - There's quite a bit of info/opinion out there but my 2 cents: Macs are nice esthetically and functionally and generally more polished (though PCs have gained on them in recent years if you ask me). While Macs seem to have less problems in general, they are more expensive, less flexible, and have less software options than PCs. One thing noteworthy about Macs is that if you're near a Mac store you can take your machine in to the 'genius bar' and have a real person help you with it if you're having problems. I haven't used this service myself but would bet that this is superior in most cases to calling someone in India or whatever other foreign country. Some of us are Macs, and some of us are PCs. The choice is yours.

32 vs 64 bit - Windows comes now in 32 or 64 bit editions. You only need 64 bit windows (x64) if you need more than 3 GB of memory. However having 64 bit windows on a system with less than 3 GB of memory isn't going to hurt anything either. Most programs and things today work on either but feel free to check if you have any things that HAVE to work on the new system.

Other Stuff - If you have a printer, scanner, camera, mp3 player, or anything else that you want to connect to your machine check that it will work with your new version of windows or mac!

Store Services - Don't buy add on crap or warranty from a store (aka Best Buy) unless you are really dumb or lazy or rich. Again, unless you're one of the previous adjectives, get your warranty branded from manufacturer. Realize that retail stores will lie and pressure you to purchase things you don't really need. Its one of the ways they make money. Half of what they do is probably explained out on the web. Google is your friend.

Memory - Memory upgrades are sometimes cheaper to buy separately instead of an upgrade when you're building/buying your system. www.crucial.com makes it quite easy to price memory upgrades and installation is usually about as hard as a screw or two. Most systems today run great on 2-3 GB of memory.

Programs - If you need office or other programs its usually best to buy it with the machine if available. ALWAYS run anti-virus protection. There are decent free ones out there at the very least. Don't forget to back up your important data! Computers and drives do fail! If you don't want to deal with having backup drives around www.Mozy.com is a good online backup service.

Size - For both desktops and laptops think about physical size of the machine. There is a lot of variance out there. Smaller desktop computers are nice however are not as easy to get into or upgrade. Laptops as well range in size from 9-inch up to 17-inch screens with everything in-between. Retail stores are great for getting a feel for the size of the machine and/or monitor that you will want.


Hopefully this post is useful to you if you're looking at buying a new computer. While it may not cover every single detail it should cover most of the points to consider in your decision. Happy computing.


FIN

Wednesday, June 17, 2009

Riverbed Note: Optimize (don't exclude) your KVM traffic

Discovered this interesting tip today. When connecting to our Dell (rebranded advocent) 2161DS KVM over the WAN it was taking up quite a bit of bandwidth. (up to about 1-2 Mb/s, depending on what was on the going on KVM)

I had previously added a rule to NOT optimize traffic to the KVM thinking that since it was interactive that it would be best if the Riverbeds didn't optimize the traffic. I suppose my subconscious mind also thought that the software had been designed a little better and this wouldn't be a problem.

So, after noticing the bandwidth used, I removed the exclusion rule I had previously set (thus allowing the Riverbeds to optimize that traffic) and then checked and saw that optimized was MUCH nicer on my WAN with no noticeable difference in experience.

In my 15 minutes or so of testing it showed 59% reduction


Moral of the story being DO optimize your KVM traffic over the WAN. (at least for the Dell 2161 DS KVMs)

Wednesday, April 29, 2009

2003 to 2008 Domain Controller Migration Checklist

So I am all done now removing our 03 AD server and replacing it with new hardware running server 08. Apart from a small exchange 2007 hiccup things went quite smoothly. Since I didn't find a short and concise checklist out there on this process I figured I would post one.

The following is my post-process brain-dump of the things to keep in mind along with a few comments and links I found helpful. It's by no means authoritative or comprehensive but should cover most of the process from a high level for upgrading a single DC in your average single domain environment with multiple domain controllers.

Removing old 2003 Server:
  • Verify you're getting good backups of the server to be retired
  • Migrate away any FSMO roles to another DC
  • Migrate radius/IAS to another server - Check IAS logs to test/confirm migration (located at %systemroot%\System32\LogFiles here's the format)
  • DHCP - In a multiple DHCP server environment with enough space in your other server's scope simply deactivate your scope on the server to be retired and let the other server pickup the leases as they expire. You'll want to make sure you wait till all eases are expired off the server before you stand up the replacement DC. In a single DHCP server environment (or if you don't want to wait for leases to expire) you'll have to do a hot cut over and migrate the database from the old to the new. Handy trick for migrating DHCP reservations here
  • DNS - Assuming your hosts have redundant DNS servers this should be straightforward.
  • Certificate Services - Microsoft Guide Here
  • AD - You'll want to make absolutely SURE the changes made with the demotion have fully replicated in your environment before you add the new DC.
  • KMS - If you have KMS running on your DC for activating OS installations you'll want to remove it (slmgr -ipk)
  • Anti-Virus
  • Any Monitoring Software
  • Backup Agent
  • Remove From Domain
Installing New 2008 Domain Controller:
  • Add server to domain - customize OS as desired - UAC, IE ESC, etc)
  • Turn off hibernation (why is this enabled by default Microsoft?) - powercfg.exe /hibernate off
  • Install Backup Agent and take full backup
  • Monitoring software
  • Anti-Virus
  • AD/DNS - dcpromo gives you the option to install DNS when it runs, no need to do separately
  • DHCP - See link above on migrating reservations
  • Activate KMS - (slmgr.vbs /ipk and then slmgr.vbs /ato)
  • Cert Services - Install per documentation
  • Migrate FSMO roles - Warning about infrastructure master not valid for single domain environments
  • Configure SNTP. If the new DC will be holding the PDC emulator role you'll want to configure external time syncing. See links at the bottom here. (w32tm /config /manualpeerlist:"ntp0.cornell.edu 0.pool.ntp.org 1.pool.ntp.org" /syncfromflags:manual /reliable:yes /update)
Again, I didn't meticulously document my procedure as I went through it so there may be a few small things missed. However if you have anything to add feel free to add a comment!

Saturday, September 20, 2008

KMS woes

What's really frustrating is that there is no tool or command to see which hosts are listed in the "count" displayed when you run slmgr on your KMS server.

I stood up some server 08 machines the other day (yes some were vms, yes I have read the piece about each physical machine being counted) and can't seem to get to the 5th host in the "count"

I stood up vms on 3 different physical servers, then 2 other physical hosts and still didn't get to 5. So then I load up a server 08 instance in vmware workstation on my desktop machine that has never activated 08 of course, and I still have 4 listed in my count. (yes I've also gone around and run the -rearm command on hosts, that doesn't do anything either)

Sure it shows in the event log that it is talking to the KMS server just fine but it's not incrementing my count as it should!

So currently I've got 6 different physical machines running 08 and KMS tells me I only have 4... Way to make my life more difficult MS. Why require 5 physical machines when virtualization is so prevelant these days, especially with new servers being deployed? Especially when which shops will be using KMS? Volume clients which are more likely to be using virtualization anyways!

If KMS could accurately seem to determine physical hosts then I'd be more ok with it.

If KMS could simply tell me which of my hosts out there are counted in the 'count' then I'd be more ok with it.

I really don't care about the lack of a gui, I care about the lack of functionality that has now cost me 3 hours of my time which provides NO benefit to my job.

Thanks Microsoft.

PS I'm going to really enjoy calling you to resolve this problem that could have been easily solved by simply making this tool better. I'll post back here what the problem was.