Thursday, August 16, 2012

Powershell - Get bitlocker keys from AD

Today I was aksed to help write a script to get a list of all the computers in our domain and show which ones had their bitlocker keys backed up to AD.

I googled around to find where in AD the information was stored, and proceeded to write this beauty of a script.  Feel free to modify as you see fit and let me know if you found it useful.

# Load AD tools
import-module ActiveDirectory
## Initialize Variables
$searchBase = "ou=Workstations,dc=mycompany,dc=com"
$RecoveryInfoPresent = 0
$MyCount = 0
$MaxCount = 5000
##Inform the user what is about to take place
Write-Host "Searching " $searchBase " for computer accounts with bitlocker keys.........."
Write-Host ""

##Create Table - ResultsTable
$ResultsTable = New-Object system.Data.DataTable "ResultsTable"
$col1 = New-Object system.Data.DataColumn ("HostName", [string])
$col2 = New-Object system.Data.DataColumn ("CanonicalName", [string])
$col3 = New-Object system.Data.DataColumn ("RecoveryPassword", [string])
$ResultsTable.columns.add($col1)
$ResultsTable.columns.add($col2)
$ResultsTable.columns.add($col3)
$computers = Get-ADComputer -Searchbase $searchBase -filter *
foreach ($computer in $computers)
{
    $RecoveryInformation = get-ADObject -ldapfilter "(msFVE-Recoverypassword=*)" -Searchbase $computer.distinguishedname -properties canonicalname,msfve-recoverypassword

 ##Loop through as their may be multiple saved
 foreach ($RecoveryInfo in $RecoveryInformation)
 {
  $output = $ResultsTable.Rows.Add($computer.name, $RecoveryInfo.canonicalname, $RecoveryInfo."msfve-recoverypassword")
  $RecoveryInfoPresent = 1
 }

 if($RecoveryInfoPresent -eq 0)
 {
  $output = $ResultsTable.Rows.Add($computer.name, "", "")
 }
 else
 {
  $RecoveryInfoPresent = 0
 }

 #Loop protection
 $MyCount = $MyCount + 1
 if ($MyCount -ge $MaxCount)
 {
  break
 }
}
##Write txt/csv file
#$ResultsTable | Out-File bitlockerinfo.txt
$ResultsTable | Export-Csv bitlockerinfo.csv -notype

##Inform the user that processing is complete
Write-Host "processing complete"

Tuesday, August 14, 2012

Going back to WSS 3.0 from MOSS 2007

Back in 2009 I switch departments at the company i work for and was placed in charge of the sharepoint farms.  i had been getting a lot of people complaining about an inability to edit user information within site collections on our WSS farm.  Normally, you would just click a users name in the top right of the screen, click My Settings, and then edit the information about yourself in the text boxes that would appear.  Intead, only the readonly account field was displayed in edit mode.  If I created a new site collection, the issue was not reproducable, but on most existing sites i was able to reproduce.  This cause me to scratch my head and I started googling...  a lot!  Try as i might, i couldnt find anyone else having this issue.

Read on to find out why and how I fixed it.....

Right before I was in charge of our SharePoint farms a coworker of mine decided to attach a WSS 3.0 content database to a MOSS 2007 instance in order to gain some backup capabilities of some third party software.  Problem was, the DB was still attached to WSS 3.0, and the organization never had any interest in using the paid version of SharePoint for that particular farm....  I quickly proceeded to detach the database from the MOSS farm, but the damage was already done and too much time had passed to make restoring from backups a viable option.

Any site collection that was in the database at the time the DB was attatched to MOSS was upgraded to a new schema that affected the user information for each site collection.  Newly created site collections functioned normally, but all the old site collections were broken: meaning that all user information on the site was read only.  This did not go over well with some of our users (some external to our company).

I literally tried everything i could think of to fix the broken sites, including a support case to Microsoft.  It made its way really far up the chain until months into the case the senior engineering staff i worked with gave me two solutions:  live with it, or manually edit the DB each time a user wanted to change a property.  Wow.  Really?  MS has no db scripts to reverse the changes made?

Backing up and restoring the site still left the site in a bad condition.  Attempts at a fresh new farm did nothing to help the cause either, as the site collections were themselves to blame.  I worked this problem for months and the best solution i could come up with was to rebuild the problem sites by hand or just leave them broken.

We have a LOT of site collections, and have lived with this issue on the old sites for years now.  Our solution has been to migrate by hand all the content on the site to a new site (losing all versioning, last modified by, created by, etc data) in order to fix the problem when the userbase of that site complaned loudly enough.



Fast forward a few years, and well last week one of the last few sites (there are only about 26 bad sites left) needed to be upgraded.....  but it was HUGE!  I deceded to try my hand at hacking the backup files to see what i could manually change in order to get the backup/restore to succeed.  I'll spare you the details of everything i tried, but i wasnt able to get that to work either....

Cue the best solution i have come up with thus far:  In all my attempts I tried something i never tried before: export/import.  If i performed a basic export, and a basic import, all the files and site structure moved over, and the user information list worked again, but the metadata on who touched each file didnt persist.  After a bunch more attempts, this is the best i was able to do:

stsadm -o export -url https://site.mycompany.com/sites/brokensitecollection -filename d:\brokenSiteCollection.bak -quiet -versions 4
stsadm -o import -url https://site.mycompany.com/sites/fixedsitecollection -filename d:\brokenSiteCollection.bak -quiet -includeusersecurity -updateversions 2

by exporting with versions and NOT including user security, the brokenness of the site was not carried over.  by importing WITH security the user information of who last edited a file and all ther version information still transfered over.  The only thing missing was the actual permissions to the site, which given how much work i used to have to do, this is not a big deal to finish out by hand.


So, moral of the story:  If you find yourself in this unique situation (I hope you dont), use the export/import command with the switches indicated above to get the site in a proper state again.

Wednesday, May 30, 2012

WSS 3.0 Search Issues and SSL

So today I had to battle some issues with WSS 3.0 search.  (yeah i know, its sad that we still have an environment running code that old)

The issue was that the search service went belly up while i was away on vacation.  It was still running, but no search results in the application.  After trying just about everything I could find online, I had an epifany of what might have gone wrong based on the errors i was seeing in the logs within the 12 hive.

Somehow the root certificate for our wildcard ssl cert was no longer trusted on the box.  After retrusting the cert within the mmc snap-in certificates, search finally worked.

I am writing this blog post merely for my own knowledge of some of the steps i took to troubleshoot the problem should something in the future arise.


Check the obvious
  • Is search actually running? 
    • Operations --> Services on Server --> Windows SharePoint Services Search
  • Make sure the content DB is using the search server
    • Application Management --> Content Databases --> Click your content db --> Pick the search server.  Sometimes you may have to set the content db to offline, hit OK, then put it back online to get things running.  Dont worry, no downtime is percieved by this.
  • Force a full crawl
    • stsadm -o spsearch -action fullcrawlstart

Then check the event viewer and the logs in the 12 hive for clues.

Another useful check, and the main reason i wrote this post is the following queries against the search DB.   These will give you an indication that search is working and if errors are being thrown the first query will show them to you.


select msscrawlurllog.lasttouchstart as Time, msscrawlurllog.displayurl as URL,msscrawlurllog.errorid as Error, msscrawlerrorlist.errormsg as Description
from msscrawlurllog
join msscrawlerrorlist on msscrawlurllog.errorid = msscrawlerrorlist.errorid
where msscrawlurllog.lasttouchstart >= DATEADD(mi, -5, getdate())
order by msscrawlurllog.lasttouchstart desc

SELECT [CrawlID],[RequestTime],[Status],[StartTime],[EndTime]
FROM [MSSCrawlHistory]
order by starttime desc

SELECT [HostID],[HostName],[SuccessCount],[ErrorCount],[WarningCount]
FROM [MSSCrawlHostList]

Wednesday, May 2, 2012

Powerview Icon in SharePoint 2010

So you got PowerView installed and configured for your SharePoint 2010 instance.  You finally have figured out how to create a data source and you create your first report in a document library.  You click save and return to said document library, only to find the hideous blank icon next to the report instead of the PowerView icon.



I can help you fix that, and its really easy!

On each of your WFE's (web front ends) make the following change:
  1. Verify that this file exists: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\IMAGES\ReportServer\16reportx_sp.gif
  2. Open C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\XML\DOCICON.xml with your favorite text editor (Notepad++ is my favorite)
  3. Add the following line directly beneath the entry for rdl extensions:
    <Mapping Key="rdlx" Value="ReportServer/16reportx_sp.gif" />
  4. The final file should look something like this:
  5. Save your changes.
  6. Perform an IISReset.
Now, refresh you browser and you will see the PowerView specific icon.

 Hopefully this was a big help.  Leave a comment letting me know your experiences.

Thursday, February 23, 2012

My Custom Bed

A little over 4 years ago my wife and I decided to purchase a new bed, as we were waking up very sore on the free mattress we were currently sleeping on.  We had decided to go ahead and buy a very nice mattress, since we both thought at the time that if we spent a lot of money on a nice mattress it would last a long time.  $2400 and 4 years later i wake up more sore than when i was sleeping on the free mattress.

Over the past few months i have been doing a lot of research as to what our next mattress should be.  Our options:

Coil Spring
I knew if i went with another coil spring mattress, it would have to be considerably cheaper, since all spring mattresses appear to last about the same amount of time unless you buy a really cheap one.

Air
My father has one of the air based beds, the sleep by number, and my wife and i had the opportunity to sleep on it for a week.  I was not happy with how it slept, and very annoyed that the firmness changed at random each night, and the pump seemed to always cycle on and off.  The bed was basically falling apart as well.  A lot of research also led me to find out that they tend to have issues with mold growing between the air chamber and the foam topper that is placed on them.  Yuck.

Water
People still use water beds!  Kinda weird i thought.  Ive slept on water beds, but have never liked them.  We didnt give them much consideration at all.

Foam
There are a lot of foam beds out there, and after asking around to a lot of people I have found out that most people really like their foam beds.  They seem to last a lot longer than coil spring, and provide proper support during the lifetime of the bed.  They can be made from simple foam, memory foam, or synthetic/natural latex foam. 


Foam definitely seemed to be the way we wanted to go.  We started shopping for our next bed, but quickly discovered one thing: people like to charge a LOT of money for a foam bed.  As in $1500-$3000 and up for a Cal-King sized bed.  Being the engineer that I am, I about died seeing what they charged for a bed versus the cost of foam.  What could possibly make them so expensive?

NOTHING!

After exhaustive research, every single one of the beds was made of as little has 2 and as many as 7 layers of foam.  Some had 'bolsters' added to the bottom layer of foam, but most were just simple pieces of foam.

I started to research where i could buy each of the layers and was shocked at how cheap the foam can be obtained.  There are many websites that sell foam, and we decided to order ours from http://www.foambymail.com/ and http://www.amazon.com

We decided to model our mattress loosely off of the iComfort line by Serta, as we really liked the feel of their mattresses the best.  I would suggest before you embark on creating your own mattress, that you first try out some at your local mattress stores so that you know which mattress you are going to recreate.

We really liked Sertas gel memory foam, so we actually ordered their name brand foam.  How you ask?  A mattress topper!  We purchased the mattress topper from Amazon.com.  The rest of our mattress was standard foam that can be ordered from foambymail.com (FBM from now on).

This is the layout we went with:
2.5" Gel Memory Foam (Serta)
2.5" HD36-High Quality Eggcrate
2.5" LUX-High Quality Eggcrate
4" LUX-High Quality Foam

Shipping is free from FBM on orders over 100 bucks, and most amazon orders ship free and luckily the mattress topper was one of those items.  We placed our order and a week later we had all the pieces to make our mattress.

The foam comes highly compressed for shipping reasons, and per the manufacturer needs to be opened up ASAP in order to prevent it from permanently being deformed.

 Here is what came in the mail:

Foam in packaging.  Left package is both eggcrate, and the right one is the 4" lux.

Serta memory foam and cover.
The memory foam took the longest to regain its shape (4 hours) and had quite a smell to it.
Unrolling the memory foam.

Corners stayed smashed for a while.  Patience is key here.

Another shot of the corner after more time elapsed.

Almost there....

All the way expanded.  Amazing how small they can squish this stuff for shipping.
Here is the foam.  You can see how much larger it is after unpacking.
Before removing the plastic... 
And after....

Video of the foam expanding.


This is the final product.

And with a cover...

 


The smell is not as bad as when we first assembled the bed about 2 weeks ago, but it is still there.  The first few nights were rough, and I really think we probabaly should have let it air out longer before we started to sleep on it.  I'm expecting it to completely dissapate in another week.

Sleep
The most important part of this whole thing.  How are we sleeping on it?  GREAT!  We both love it and are getting absolutely great sleep. 

Test of time
We shall see how this bad boy holds up over time.  I'll keep this blog post up to date as time goes on with developments on if we still like the mattress and how it is holding up. 

Monday, December 19, 2011

Get XPATH of element in IE

Ever had the need to get the XPATH of an element and you are using IE.  Well, here is how you can:  Create a bookmarklet with the following javascript:

javascript:function getNode(node){var nodeExpr=node.tagName;if(!nodeExpr)return null;if(node.id!=''){nodeExpr+="[@id='"+node.id+"']";return "/"+nodeExpr;}var rank=1;var ps=node.previousSibling;while(ps){if(ps.tagName==node.tagName){rank++;}ps=ps.previousSibling;}if(rank>1){nodeExpr+='['+rank+']';}else{var ns=node.nextSibling;while(ns){if(ns.tagName==node.tagName){nodeExpr+='[1]';break;}ns=ns.nextSibling;}}return nodeExpr;}function getXPATH(){var currentNode=document.selection.createRange().parentElement();var path=[];while(currentNode){var pe=getNode(currentNode);if(pe){path.push(pe);if(pe.indexOf('@id')!=-1)break;}currentNode=currentNode.parentNode;}var xpath="/"+path.reverse().join('/');clipboardData.setData("Text", xpath);}getXPATH();

Bookmarklets are just a simple bookmark and you use the script as the url to the site instead of an actual url.  Hope someone else finds this useful.

The code above was adapted from http://functionaltestautomation.blogspot.com/2008/12/xpath-in-internet-explorer.html


Thursday, December 1, 2011

Random thought for the day... Programming in other countries

I had a random thought today while helping someone on my codeplex project (http://spdactivities2010.codeplex.com/):

What language is used to program stuff in other countries?  do they still use english to write their code?  I would assume javascript has to be, since it isnt compoled code, but what about compiled code such as c#?

Hopefully someone with internation experience will hop on here and enlighten me.

-R

Wednesday, October 5, 2011

SPC2011 Lab

The lab here at the conference is pretty cool.  There are a ton of great lab exercises available to run through to help you get the best out of the product.  I'm hoping to find a way to offload some of the source and the walkthough documentation so that I can use it later.

The lab at SPC2011.  This is a few of half the lab, there are just as many machines to the left of the frame of this photo.

There are quite a few machines available to use, and they even spent the effort to put some cool lighting in the room. Each machine is a thin client with dual displays, which I believe is the same concept the VP of IT at where I work is looking to go to for a lot of the associates at our company.

Disney!!

Last night was our trip to disneyland.








Tuesday, October 4, 2011

Dinner

Had dinner tonight with the guys from Winwire, and met lots of new people.  Had a great time, and ate lots of great food.

Dessert....  yummy :-)
Now im off to bed, tomorrow will be a long day ending in a long night at disneyland.

Winner winner chicken dinner

So at lunchtime I walked into the vendor booth area, and Quest Software was having an instant raffle to win 25 bucks, so I grabbed a ticket.  3 minutes later they announced the number and lo and behold it was mine :-) 

There was also a free book giveaway, but the line was long and i was hungry.  By the time i got lunch and came back, the books were all gone.  I'm going to have to roam that room more often to make sure i dont miss out on more free stuff.

Denali

So MS has been hyping the new sql server a lot at the confernce.  Its codename is denali, and they have been showing demos of it.  I have to say, it seems quite impressive.  It has way better failover capabilites from previous versions, and they have made it even easier to setup/configure.


You can find out more by checking out the website: http://www.microsoft.com/sqlserver/en/us/future-editions.aspx

Keynote



This morning was the keynote.  Normally keynotes are full of excitement and new announcements....  This one was not.  I'm hoping the rest of the conference doesnt fall so flat.  The setup in the main ballroom was impressive (see the pic below), and the speakers held my interest for the most part.  A vast majority of the keynote was spent tooting their own horn on how much functionality they packed into office 365.  There was one redeeming part of the keynote - they demonstrated live a SQL failover with the new not yet release SQL server.  They had a monster sharepoint farm (1 TERRABYTE of ram, 80 processors, 100 TB of disk space) and they failed over the entire farm by unplugging the primary SQL server.  The whole farm came back up on its own within 40 seconds.  Given that they had a user load of 7500 concurrent users, and a 14 terrabyte content database attached, that was extremely impressive.

Anaheim Conference Center

In a word: impressive.
From the outside



This place is huge (my feet hurt from all the walking)

Here is another pic of the place:

Looking out from the escalator

Arrival

When i arrived in LA, i started to remember why i left CA.  The smog, the traffic, and some really crazy people.  Even so, I was still very excited because In-N-Out was in my near future.


After I picked up my rental car and started to drive from the airport to my hotel, I was pleasantly surprised to see how close my hotel was to disneyland.  As I neared my hotel, there were fireworks going off in there air, and as I pulled in I realized that disneyland is literally just a few blocks from my hotel.

The hotel im staying at is awesome.  The room is a  spacious two room suite, and the entire center area of the hotel is wide open.

Inside the hotel

First floor

From the outside

Friday, September 30, 2011

Microsoft SharePoint Conference 2011

I'm so excited!!!  I just found out yesterday that I get to go to SharePoint Converence 2011.

http://www.mssharepointconference.com/pages/default.aspx

I plan on posting my thoughts on each session I attend as a blog post, and ill try my best to include pictures.  Want to know one of the coolest things about this event beside all the awesome tech I'm going to get to learn?  Its at Disneyland!


I've never been to Disneyland, but i have been to Disneyworld when I was really young.  This should be a lot of fun.

Tuesday, August 30, 2011

Boxed Music Drums

So the guy i bought my TD-12 from actually makes hand drums commonly called tongue drums.  They are pretty cool and wanted to share his site with everyone.  So without further adieu...

http://www.boxedmusicdrums.com/


Monday, August 29, 2011

SharePoint 2010 - Hide recently modified section on wiki pages

Want to hide that pesky recently modified section? Well, you can!
All you have to do is add a content editor web part to your page and then drop in the following code.
<style type="text/css">
.s4-recentchanges {
DISPLAY: none
}
</style>

Check out my other post on hiding the quick launch.

Sunday, August 28, 2011

SharePoint 2010 - Completely Hide Quick Launch

Ever wanted to completely hide the quicklaunch on a page or two in sharepoint but just didnt know how? Well, its EASY!
All you have to do is add a content editor web part to your page and then drop in the following code.
<style type="text/css">
#s4-leftpanel {
DISPLAY: none
}
.s4-ca {
MARGIN-LEFT: 0px
}
</style>

Saturday, August 27, 2011

Bought a new to me TD-12

So a few weeks ago I bought a new (to me) TD-12 as an upgrade to my TD-9.  Let me first say, wow!  I love this thing.  Its amazing how much better it sounds than my TD-9 and the crazy amount of customizations you can do.

One thing I am a little disappointed in is the community surrounding the TD-12.  There really doenst seem to be many people that like to share their customized kits.  There is even a company out there (vexpressions) that sells the config files.  I'm a bit shocked that people actually pay for configurations they could do themselves and simultaneously curious as to how good the kits are.  The few kits i found online that others have shared really werent that great, so im quite skeptical.

This has led me to want to get much more involved in the vdrum community and to try to encourage others to share their kits.  I'm not sure how much storage wordpress will let me use up, but i would like to start a post on here to start sharing the syx (sysex) files that contain the custom kits so that others can use them.

If im feeling really bored, i also want to recreate the vdrumlib software and make it freeware, as i think something like this should be readily available to the masses for free, not something you have to pay 20 bucks for.

 

If youve stumbled across this post, and have some kits you want to share, please comment and share them!!!  I will be starting a new thread that just contains customized kits and will keep it up to date with all user provided kits.  I will link to that post from here when it gets created.

 

Thats all for now...  -Rob