Skip to main content

Posts

Showing posts from August, 2008

renaming files with powershell or for loop …

i have a directory of scripts with names like mom_myScript.vbs or sms_myScript.vbs.  this is all so that i can do a relatively simple directory search to see what kind of scripts i have for a particular technology i’m working with.  the problem is, i flip-flip on my use of hyphens and underscores and have apparently done it often enough to warrant a little a clean up.first, the old way i would have done this in cmd shell.  it’s basically a for loop to go through the list of files in a directory that matches where the script has a hyphen.  to pull back just the file name, i’m using the dir /b command.  i’ve broken down the file name into tokens that’s separated by the hyphen and then renaming the files, positioning underscore between the tokens.for /f "tokens=1-2 delims=-" %a in ('dir /b mom-*.*') do @ren %a-%b %a_%b here’s my new, preferred way to do it in powershell.  basically, i’m pulling back the list of files i want to work with and passing it through to the rena…

sql server 2005 database health script noise…

out of the box, the sql server 2005 db health script is amazingly noisy.  here’s a description of a sample event that you don’t need to see (unless you report on them).The database myDatabase in instance myInstance is in a healthy state. aside from reporting on the value, you probably don’t care.  if you want to make this events stop for normal database state, you’ll need to modify the script sql server 2005 database health.to begin with, look for this line:Public Function CheckDBHealth(sInstance, sHighSevDatabases) if you search far enough down (around line 2400), you’ll see a block of code that looks like the following:Set objEvent = ScriptContext.CreateEvent() objEvent.EventSource = SCRIPT_NAME objEvent.EventNumber = iEventId objEvent.EventType = iEventType objEvent.Message = message objEvent.SetEventParameter(sInstance) objEvent.SetEventParameter(oDatabase.Name) objEvent.SetEventParameter(sState) ScriptContext.Submit objEvent to quiet down the script, we just need to put some…

default refresh periods for dynamic dns

i wrote this article on dns aging/scavenging simplified awhile back.  one of my coworkers recently asked me what the default refresh period was.  wow, i had totally forgotten since i had written it and since i had forgotten to put it in the original post, it was more time on google than i wanted to spend to find it.  that means – blog it.  so here it is… the default refresh periods.  you can find this information from this article: http://technet.microsoft.com/en-us/library/cc757041.aspx.servicedefault refresh periodnet logon24 hoursclustering24 hoursdhcp client24 hoursThe DHCP Client service sends dynamic updates for the DNS records. This includes both computers that obtain a leased Internet Protocol (IP) address by using Dynamic Host Configuration Protocol (DHCP) and computers that are configured statically for TCP/IP.dhcp serverFour days (half of the lease interval, which is eight days by default).Refresh attempts are made only by DHCP servers that are configured to perform DNS dyn…

imaged machines and the dnsapi event id 11163

i wonder if this is going to end up a long-winded post.  i never intend for that to happen because somewhere i picked up that technical information should be succinct.  however, when i started looking into this problem, it seemed like there just wasn’t good information on it.
synopsis a user in your environment needs to have their machine reimaged.  as a loyal IT citizen, you promptly do so by any manner that happens to be your favorite (e.g. mdt, swimage, ghost, etc).  you bring up this machine as the same name.  later on, you try to remotely manage the machine but realize that the ip it once had is different.  you spin your wheels a bit trying to figure out why the new ip hasn’t registered in dns.  upon reviewing the event log of the machine, you discover events that look eerily similar to these:
Event Type: Warning Event Source: DnsApi Event Category: None Event ID: 11163 Date: 8/12/2008 Time: 5:32:32 PM User: N/A Computer: myComputer Descript…

show vmware snapshots script

here’s a simple, little powershell script to show all of your snapshots.  you have to use the vmware vi toolkit and virtual center to do this.  i have mine going to a html file, in this example.# =============================================================================# NAME: VMSnapshots# AUTHOR: Marcus C. Oh, Cox Communications, Inc.# DATE : 8/5/2008# COMMENT: A real simple script to pull back snapshots of a VM.# ============================================================================= $myVC = $Args[0] If ($Args[0] -eq $null) { Write-Warning "Please provide a server name as an argument." } else { $VCServer = Connect-VIserver -server $myVC -credential (Get-Credential $_.username) Get-VM -Server $VCServer | Get-Snapshot ` | ConvertTo-Html -Property created,quiesced,powerstate,` @{label = "Note";expression = {If ($_.Description -ne''){$_.Description}else{"None"}}},vm ` -Title "VM Snapshots Report&q…

don’t roll vmware update 2 … yet (updated – fixed!)

if you’ve had the displeasure of applying update 2, here’s what you’re in for.An issue has been uncovered with ESX/ESXi 3.5 Update 2 that causes the product license to expire on August 12. VMware engineering has isolated the root cause of this issue and will reissue the various upgrade media including the ESX 3.5 Update 2 ISO, ESXi 3.5 Update 2 ISO, ESX 3.5 Update 2 upgrade tar and zip files in the next 36 hours (by noon, August 13, PST). They will be available from the page: http://www.vmware.com/download/vi. Until then, we advise against upgrading to ESX/ESXi 3.5 Update 2. The Update patch bundles will be released separately later in the week. The issue is being tracked on KB 1006716 on http://kb.vmware.com/. WHAT TO DO: Reference this community article and have them reset your ESX clocks back. http://communities.vmware.com/thread/162377?tstart=0 The work-around: turn off NTP (if you're using it), and then manually set the date of all ESX 3.5u2 hosts back to 10th of August…

background information on active directory

i was watching this interesting thread about the history of active directory and its roots going along the activedir.org mailing list. looks like joe captured it here: http://blog.joeware.net/2008/08/11/1420/ if you’re interested in reading it.while i’m at it, he also posted a link to active directory’s ldap compliance. this is something, i too, lose all the time. so here it is for reference: http://www.microsoft.com/windowsserver2003/techinfo/overview/ldapcomp.mspx

how to query for slash and backslash in active directory

often times when integrating with other idm solutions or using directory sync or some sort, the other system may not be able to parse the slash or backslash properly. here’s one way to root out where those objects may be residing and what they are. if you want to find objects in AD that may contain a slash (/) or a backslash (\) in the object cn, you can use a simple query like this:adfind -default -f "(|(cn=*\2f*)(cn=*\5c*))" dn cn same thing with dsquery, if you prefer that:dsquery * domainroot -filter"(|(cn=*\2f*)(cn=*\5c*))" -attr distinguishedname cn you can find this and more in the list of escapable characters at: http://msdn.microsoft.com/en-us/library/aa746475.aspx. don’t miss joe richards’ comment in the community section. :)and of course, you can find this information in rfc2254. (the msdn list is more complete, oddly.)