Thursday, October 21, 2010

Basic Folder Maintenance... Or, "how to zip a folder"

Basic Folder Maintenance... Or, "how to zip a folder"

OK, for those of us who have experience in the *NIX world, the lack of native abilities or tool sets that should just be... "duh", included in an OS is a continual source of aggravation when working in a "Windows" world.

Let's leave behind difference between "dir" and "ls", or the ability to manipulate files and streams directly from the "command line" without having to open a different "shell".  *and yes, of course, some *NIX aficionados would argue, "Well, I don't like bash, so i open a ksh anyway" would be valid arguments to the Windows proponents of "PowerShell".

To not be able to "grep" and pipe to another command, without then invoking a GUI operation, or to have to spend massive amounts of time investigating which switches, options, and syntactic anomalies are, or are not allowed can also be seen as forgivable or explained away as "differences" and "limitations" of one or both platforms.

But, what is not excusable is the "limitation" that Windows has built into the OS with regard to "compression".  Their first attempt is a built in function/method and can be invoked fairly easily, but was never as economical as PKZip, or other 3rd party "zip" compression methods.  These are easily invoked on the *NIX command line, either having been integrated via:

[user@localhost ~]# tar -czvf archive.tgz *.txt; rm -f *.txt

Or something along those lines; I haven't touched my Linux system in ages, and I just ran that to archive my "home" folder within minutes.

Now, think about how powerful that can be on a production server!

Being able to quickly and easily (either manually at the command prompt, or schedule as a maintenance activity via a *.sh script fired off by your crontab) manage your server's file system is a basic duty of server administration.

Well, I have spent this entire morning, attempting to do the very same thing on one of my Windows Server 2008 machines.

Rather than continue a rant about the difficulty involved, here it is:

Mike Hodnick has contributed to the PowerShell community a nifty *.ps1 script that does exactly what you would expect - a quick and easy way to "zip" up a directory.

http://blogs.inetium.com/blogs/mhodnick/archive/2006/08/07/295.aspx

I will post the code at the bottom in case this link ever drifts into the ether...

The difficulty was that with VBS code, I could not get consistent results whether using a 3rd party Zip tool, or via Windows scripted methods.

This PowerShell script however, does exactly what it should.

Here is the code:
all propr and rights to Mike Hodnick

########################################################
#
# out-zip.ps1
#
# Usage:
#
# To zip up some files:
# ls c:\source\*.txt | out-zip c:\target\archive.zip $_
#
# To zip up a folder:
# gi c:\source | out-zip c:\target\archive.zip $_
########################################################

$path = $args[0]
$files = $input

if (-not $path.EndsWith('.zip')) {$path += '.zip'}

if (-not (test-path $path)) {
set-content $path ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
}

$ZipFile = (new-object -com shell.application).NameSpace($path)
$files | foreach {$zipfile.CopyHere($_.fullname)}

Wednesday, December 16, 2009

Exchange 2007 / AD 2008 Schema "Living... in a material world"

Ok, so granted it's been awhile since we originally build our AD 2003 and Exchange 2003 infrastructure, and the subsequent Exchange 2K7 update, and recently the AD 2008 Schema extenstions, but still the process is supposed to be pretty straightforward...

Log on as Schema Admin, run the Exchange CD setup with the /ps switch, right?  Not so fast brother!

Remember that

  • You may need to flip the bit in the registry for "Schema Update Allowed" to 1
  • Ensure your DC is COMPLETELY healthy, run dcdiag, etc.
  • Lastly, the kicker for us, even though I am logged on as a delegated administrator account (not the builtin), who has Schema, Enterprise, Domain and Adminsitrators groups.... we were still failing... why?
    • You must also run the command prompt with "Run as Administrator" due to UAC.
/sigh

Monday, November 3, 2008

HOWTO

I will post helpful "howto's" here

SharePoint DST job timer/definition problems

Not sure how prevalent this problem is, but I have run into this on my "devlab" system.

“One-time timer jobs in Windows SharePoint Services 3.0 or in SharePoint Server 2007 are delayed by at least one hour when the jobs are scheduled to occur during daylight saving time (DST)”
http://support.microsoft.com/kb/938663

I am trying to run a large (23GB) restore job; taking the production stsadm *.bak file and back populate my devlab. In order to do so, you must first create the site and site collection first, and then overwrite with the restore *.bak file. One problem i found in doing this, was that the site did not get created (this worked prior to Wednesday, but then began to "fail", or so i thought.)

I could see a job definition for "Provisioning" the site listed, but unfortunately there is not a choice to "Run now"... (*feature?) and so i deleted the job definition, thinking there was a bug and that it would not run. *btw, "Unprovisioning" is also a one-time job that would get stuck as well, so i had to go old school on the IIS server to release all the files/directories and definitions in IIS to get it to clear; oddly enough the database was deleted as expected, just not the IIS site, as it was waiting for this Unprovisioning job to run.

After finding this KB article, I once again created the site, but then left it alone over the weekend and found it had been created.

Now... we will have to test whether or not, since we are now on Standard Time, if this is a null issue w/o applying the KB. Of course, once i have done my restore (/x-fingers that it works) I will apply the kb!

Welcome to SharePoint (Hit and) Missives

Welcome to, what i hope, will be a useful site for other Enterprise level SharePoint Admins.