Monday, May 10, 2010

Batch Feature Installation w/ Logging (Expanded)

Michael Greene wrote an excellent script earlier today.  Since I like to try what I see, I took the script a bit further and added a bit more of logic.  You can see the original script here Batch Feature Installation w/ Logging.  I’ve added more logic to the URL input, EVENTCREATE, and it’ll install every .wsp that you have in the directory.  Here’s how to use this script:

  1. Copy and paste the script into a batch file
  2. Place the batch file in the directory that has all of your .wsp’s
  3. Run the batch file and type the URL of the Site Collection (don’t worry if you mistype the http:// portion of the URL, I have an error checker for that ;-) )

So what will this do? Add the solution(s), deploy the solution(s), install them, and activate all of them in one fell swoop.  Cool eh?  Great for deployment scenarios or setting up those test box vm’s.  Feel free to add more… As I’m posting this, I already have thought of a way to bulk add .stp’s.  Maybe another post?

@echo off
setlocal enabledelayedexpansion
color 0E
Title Auto .wsp Deploy
rem *******************  Deploys all .wsp's in the current directory to the Site Collection ***************************
rem ******************* How to use?  Put this batch file in the same directory as your .wsp's *********************
rem ******************* The script will find every .wsp and deploy it to the Site Collection of your choice ********
rem ******************* I guarantee this will destroy your sharepoint farm unless you know what this ***********
rem ******************* code does.  Please make sure you test this before production usage. *********************
rem ****************** Sets vars *********************************************************************************************
set "path=C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\;%PATH%"
set _http=http://
set /P _inputURL="Please enter the url the site collection to activate the feature(s) to: "
rem ******************* Checks the URL and appends http:// if needed **************************************************
IF /I %_inputURL:~0,7% == %_http% (
echo URL is in correct format
set _URL=%_inputURL%
) ELSE (
set _URL=%_http%!_inputURL!
)
echo.
echo.
Echo ************* Finding .wsp files *************
for %%a in (*.wsp) do call :ROUTINE "%%a"
GOTO :EOF
:ROUTINE
Echo Adding Solution
stsadm.exe -o addsolution -filename %1
Echo Deploying Solution
stsadm.exe -o deploysolution -name %1 -allowGacDeployment -immediate -force
Echo Installing Feature
stsadm.exe -o installfeature -name %~n1 -force
IF errorlevel == 0 (
EVENTCREATE /L System /T Success /SO "SharePoint" /ID 3 /D "%1 Installed"
) else (
EVENTCREATE /L System /T Error /SO "SharePoint" /ID 3 /D "%1 didn't install properly"
)
Echo Activating Feature
stsadm.exe -o activatefeature -name %~n1 -url %_URL% -force
IF errorlevel == 0 (
EVENTCREATE /L System /T Success /SO "SharePoint" /ID 4 /D "%1 Activated"
Echo Activation of feature %1 COMPLETE!
) else (
EVENTCREATE /L System /T Error /SO "SharePoint" /ID 4 /D "%1 didn't activate properly"
)
echo Running timer jobs to finish deployment
stsadm.exe -o  execadmsvcjobs
PING 127.0.0.1 -n 12 -w 100 2>NUL | FIND "TTL=" >NUL


You can also copy the script from this link: Batch Feature Installation w/ Logging (Expanded)

Wednesday, April 14, 2010

HTML5 is changing more than the web

This is more of an observation of what I see the internet will be in the next 10 years. Think back to 2000 and how the web used to look then, compared to now. It’s almost a laughable matter. I would’ve never been able to pull of my Twitter Marriage Proposal. ^_^ HTML5 will change how software is developed, with database caching and drag and drop being the biggest catalyst.

Microsoft has dedicated itself to creating a browser that is capable to handle HTML5. Lucky for us it’s the next iteration of Internet Explorer. And yes if you opened the last link up with IE8, it doesn’t work that well unfortunately… With everything computer related, there is always a better way to do it. That’s why the HTML5 standard is so important. It’ll open so many possibilities. One major capability will be to run applications from the cloud and have direct access to everything when you aren’t connected. That’s absolutely HUGE! I see the ability to use a computer without ever installing an application natively. This could work so well, that this may never be an offering again…

How will Microsoft compete?

Currently there are licensing costs for Microsoft’s O.S. as well as SQL Server for that matter. With the transformation of the web, Microsoft will have to rethink how they license their software in order to position themselves as the web platform of choice. LAMP (Linux, Apache, MySQL, PHP) servers can be downloaded freely and setup with relatively no costs. There are compelling reasons for using these types of deployments for the web (e.g., here and here) Did I mention it’s free?; Because it’s free… That doesn’t mean there isn’t any hope in securing the top spot. Microsoft has been focusing on allowing new startups to compete for relatively no costs as well. It’s also making it very easy to deploy major applications on top of IIS.

Licensing, Licensing, Licensing!!!

One of the most compelling reasons for using a LAMP deployment is licensing. Costs can make or break companies these days. How to get off the ground with little costs is a question I’ve asked myself. Maybe you have too… There are many entry level ways (as I’ve shown above) to get up and running with Microsoft but scaling those out to handle millions of connections can become very expensive, very quickly. MySQL is so popular because it’s scalable without the hefty price tag of SQL. For licensing revenue to continue rolling in for both O.S. and SQL, they’ll have to compete in this market as it exists today.

As the web grows…

You’ll continue to hear more stories such as “Cloud Computing” and “I only watch TV online”. You’ll also see Microsoft persuade young developers more and more that it’s the platform of choice for the web. Making IT personnel more comfortable with hosting their web apps on Microsoft is only the start in my eyes. I’m sure this hasn’t been overlooked within the walls of Redmond either. Either way HTML5 is pushing this forward.

I’m excited to see what’s in store over the next 10 years and expect my life to be easier because of a server side app, not a client side app…

Friday, March 26, 2010

My first go around with PowerShell

Figured I’d start with math since I was good at it in school…

Well, school was a long time ago!  And I’ve come to find out DateTime math via computers, really isn’t my forte.  What I’m trying to do is setup a simple stop-watch like function.  When I start any of my scripts, I always love to have time involved~~~ somehow, someway…  This particular script (when completed) will give me the ability to set the start time of a script and the end time.  With those variables set, I’ll then be able to do a time difference to determine how long the script ran.  Here’s my first go around:

Function StartTimeD {

    [int] $day = (Get-Date).Day
    Return $day
}

Function StartTimeH {

    [int] $hour = (Get-Date).Hour
    Return $hour
}

Function StartTimeM {

    [int] $minute = (Get-Date).Minute
    Return $minute
}

Function StartTimeS {

    [int] $second = (Get-Date).Second
    Return $second
}

Function EndTimeD {

    [int] $endday = (Get-Date).Day
    Return $endday
}

Function EndTimeH {

    [int] $endhour = (Get-Date).Hour
    Return $endhour
}

Function EndTimeM {

    [int] $endminute = (Get-Date).Minute
    Return $endminute
}

Function EndTimeS {

    [int] $endsecond = (Get-Date).Second
    Return $endsecond
}

 

Function HelloWorld {

    $startday = StartTimeD
    $starthour = StartTimeH
    $startminute = StartTimeM
    $startsecond = StartTimeS
}

Function EndOfTime {

    $endday = EndTimeD
    $endhour = EndTimeH
    $endminute = EndTimeM
    $endsecond = EndTimeS

}

HelloWorld
Start-Sleep 5
EndOfTime

Write-Output $startday $starthour $startminute $startsecond EndTimes are $endday $endhour $endminute $endsecond

New-TimeSpan $(Get-Date -day $startday -hour $starthour -minute $startminute -second $startsecond) $(Get-Date -day $endday -hour $endhour -minute $endminute -second $endsecond)

 
 

Unfortunately for me, it’s not working properly.  The Write-Output spits out the same numbers for both StartTime and EndTime functions.  There’s gotta be a much simpler way…  Maybe there’s something already under the hood for what I’m trying to do.  So far, I haven’t found it, but I am working on it! ^_^

Sunday, February 7, 2010

How to alternate row color using DVWP’s

I was on twitter the other day (like that is a surprise to anyone) and came across a question.  How do you alternate color for each row within a DVWP.  This is very easy when configuring the webpart within the list view and as it turns out, painless as well within the DVWP’s too.

Assuming you already have been schooled in making DVWP’s, let’s hop right into it.  After adding you DVWP to the page, put your cursor in the first row of the data that is displayed.  Make sure you do *NOT* put your cursor in the Column Title row…

DVWP Row

Next you’ll want to right click within that cell and hover over the Select option, then pick Row.  This will highlight the entire row for you.  Now we can setup conditional formatting on our DVWP to display a color for every row.  By clicking on the chevron off to the right of the DVWP, you’ll get a fly-out menu with a lot of different options:

DVWP - Conditional Formating

Click on Conditional Formatting from this menu, so we can setup the formatting for each row.  Click on Create and select Apply Formatting from this menu:

Conditional Formating

What we need to do is tell the DVWP a condition that we will expect to occur within our DVWP.  This could be a pretty much anything and it’s not bound to just what I’m showing.  Since we want each row to have a different color, choose [Row Number] is Odd from the Condition Criteria.

DVWP - [Row Number]

After clicking on OK, we’ll be prompted for the formatting we’d like to see when the condition is met.  We need to set the background to a certain color.  Select background from the left side and click on the drop down for background-color.

DVWP - Formatting - Modify Style

I’ve selected a very light grey because it’s easy on the eyes and looks good with my color scheme.  Feel free to play around with all of these options.  Conditional formatting is a very powerful tool when displaying data and I’ve only scratched the surface myself…

Here is my end result:

DVWP - Conditional Formating - Alternating Row Style

Feel free to ask questions!  P.S. I’ve also tested this with joins and merges and it works just fine.