Monthly Archives: July 2013

Send an email from PowerShell

I’ve used similar code in a few scripts, I have here – I’m putting this post here as a fast reference for those times when I want to copy/paste some email code…

Note this is just a basic example, as always get-help send-mailmessage is the best way to get some additional info on attachments, multiple recipients, credentials etc…

 

SharePoint 2010 Service Pack 2 (SP2) download links

SharePoint 2010 Service Pack 2 was released this month.

I’ve seen a few posts on blogs, but none so far were complete.

Here’s a list, I gathered this from: http://support.microsoft.com/kb/2687524
Note: This page took forever to load – in fact I almost closed it since it didn’t seem to have any relative information, then data showed up – they must build the page with an AJAX callback – it has quite a lot of detail!

I’ve organized the list below by product configurations so a few items are repeated (ie you’ll see the language packs in both the SP standard and Project server section)

Foundation / Free:

SharePoint 2010 Foundation SP2: wsssp2010-kb2687464-fullfile-x64-en-us.exe KB article: 2687464

SharePoint 2010 Foundation Language Pack SP2: wsslpksp2010-kb2687466-fullfile-x64-en-us.exe KB article: 2687466

Standard and Higher:

SharePoint 2010 Server (includes Foundation) SP2: oserversp2010-kb2687453-fullfile-x64-en-us.exe  KB article: 2687453

MS 2010 series Server products Language Pack SP2: oslpksp2010-kb2687462-fullfile-x64-en-us.exe  KB 2687462

Office Web Apps SP2: wacsp2010-kb2687470-fullfile-x64-en-us.exe  KB article: 2687470

FAST search for SP2010 SP2: fsserversp2010-kb2687446-fullfile-x64-en-us.exe  KB article: 2687446 (Fast search was a separate product offering, higher end than what came bundled with SharePoint 2010)

Project Server:

SharePoint/Project Server 2010 SP2: svrprjsp2010-kb2687452-fullfile-x64-en-us.exe KB article: 2687452

MS 2010 series Server products Language Pack SP2: oslpksp2010-kb2687462-fullfile-x64-en-us.exe  KB 2687462

“Other” servers/connectors etc:

FAST search for SP2010 SP2: fsserversp2010-kb2687446-fullfile-x64-en-us.exe  KB article: 2687446 (Fast search was a separate product offering, higher end than what came bundled with SharePoint 2010)

Microsoft Search Server 2010 SP2: sserversp2010-kb2687461-fullfile-x64-en-us.exe KB article: 2687461
(Note: Search Server 2010 SP2 was a separate offering by MS to allow search without needing sharepoint – if you are using the search features of SharePoint, you’ll just use either the foundation or server versions of SP2 above)

Microsoft Groove Server 2010 SP2: grssp2010-kb2687448-fullfile-x64-en-us.exe KB: 2687448

SharePoint 2010 Indexing Connector for Documentum SP2: dctmsp2010-kb2687459-fullfile-x64-en-us.exe KB: 2687459

MS Duet Ent. for SP2010 and SAP SP2: duetsrvsp2010-kb2687445-fullfile-x64-en-us.exe KB: 2687445

Installation tips: 

Much has been written about this, and I’ve seen some conflicting advice. I don’t have a “right answer” here – but I will say it’s a good idea to be prepared:

    • Practice on a test environment first.
    • take a backup of your IIS directory, especially the web.config files on your web front ends
    • Take a backup of your “hive” (c:\program files\common files\microsoft shared\web server extensions\14\*) there may be customization here.
    • Take backups of every DB, especially the content DB’s
    • Don’t forget about 3rd party DB’s like newsgator, K2, etc.

When possible:

    • If your SharePoint infrastructure is Virtualized, you can get a fool proof backup by doing this:
      • Shut down all your VM’s and then take a snapshot in the powered off state.
      • Take SQL backups while the VM’s are off.

The above steps might be a bit extreme, and maybe aren’t necessary, but they do give the best option of pain free recovery if you have to roll back. The logic being you can restore it to the exact same state (that of a shutdown system) – Every other backup method involves backing up (and subsequently restoring) a moving target…

Update:

This might be a good technique to follow when patching – basically it proposes shutting down the IISAdmin and SPTimerServces, and stopping or pausing the Search Services prior to patching then starting them back up afterwards.

http://blogs.msdn.com/b/russmax/archive/2013/04/01/why-sharepoint-2013-cumulative-update-takes-5-hours-to-install.aspx

– Jack

 

 

 

 

 

 

 

PowerShell to send an email when something happens in the Event Log.

Most larger companies have SCOM or some other monitoring tool in place to watch over SharePoint servers and let the right people know when things go wrong.

That said, there are times when you just need a quick and dirty way to get notified when something shows up in the event log – It might be something temporary, or something you are asked to watch – but to keep under the radar – Or maybe the SCOM team has a backlog and you need to know you’ll be alerted before you go home for the day.

Here is an extremely simple script that can be used in conjunction with Event Viewer to send an email.

Here’s how it works:

1) In Event viewer, find the event log you want to watch. Find the event you are looking for and right click it and choose “Attach a Task To this Event…”

2) Follow the wizard and when you get to the part about what to do, you can choose the default email option, or if you want to add some additional logic, choose to “Run a program”

3) Copy the contents of the script below to a file with a .ps1 extension and alter the script to fit your specific use case.

4) Specify c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe as the name of the executable (do this even if you are using a later version of powershell)

5) Specify the path and name of the script file you created above as the parameter.

Now, anytime the event you specified is found in the log, your script will be triggered.

The first line of the script fetches the most recent log item that matches some core criteria, it’s important to refine this as much as possible, so that you’re not emailing yourself details of event you want and not an event that showed up a split second later.

Final Thoughts:

This is a simple solution, for simple scenarios. I can attest that it’s worked great for me, for my limited scope scenario.  My company also uses SCOM to alert us on the more normal SharePoint issues – I’m not advocating this as a replacement for proper monitoring, but used in the right scenarios, it can be an extra tool available to you.

– Jack

Automating SharePoint Deployments in Windows Azure using PowerShell

There’s a nice article on MSDN titled “Automating SharePoint Deployments in Windows Azure using PowerShell

The article talks about building up a sharepoint environment in Azure. The main difference between this and setting up an office 365 instance that I wrote about in my last post, is that in Azure, you’re in complete control over all the VM’s that make up your environment. If you have MSDN you get a monthly spending allowance on Azure, so you should be able to play around with this stuff without incurring any costs (So long as you don’t leave everything running 24×7) – Seems perfect for test environments. At the bottom of the article are links to a few articles that discuss using PowerShell with Azure.

 

 

First steps – How to get an office 365 account to start learning SharePoint in the cloud

I’ve been playing around with Office 365 a little bit. I signed up for the preview a while back and have been using that free of charge since then…

If you’re a SharePoint person then I’m sure you’re aware that SharePoint in the cloud Aka Office 365 is where things are heading. At first this can be a little scary, especially if your company doesn’t currently subscribe to Office 365. Office 365 subscriptions come in a variety of flavors, and a variety of per month costs! – how do you get involved, how do you learn it, without breaking the bank?

It turns out there are a few ways to get involved, that you can have 100% control of, without needing a corporate account, and you can do it right n o w.

Step1: Visit Dev.office.com

On this page as of this writing Click the Big Start Button:
dev.office.com

Step2: On this page we have a few options:
dev.office.com_step2

Expand “Sign up for an Office 365 Developer Site”
Now:

This last option is the most interesting one… I’ve had my free trial for at least 6 months now. In talking with various Microsoft people at the SharePoint Conference last year, several of them mentioned that it’s possible to renew the free trial, and that if your company has a Microsoft TAM (Technical Account Manager) then that person can assist on getting this extended. I got the impression they could extend it pretty much forever, and that’s certainly been the case with my trial, It’s still live 6 months later and I’ve not even called my TAM yet!

Summary:
There are a few ways to sign up for a test account on Office 365, most of them are free, but worst case scenario, you’re only out $99/yr ($8.25 a month)

Tip:
All the office 365 accounts are tied to “Microsoft Accounts” – these have had different names throughout the years (Windows Live, LiveID, Zune, xbox, etc) So… you probably already have one of these and if so you may run into a few problems, as I did, so I want to share a few tips…

When you log in to any Microsoft service using a Microsoft Account, you have the option to “remain logged in” If you do this, a Cookie is saved in your browser – this can cause confusion if you have multiple accounts, which you’re likely to have once you sign up for the services above. So here are a few tips-

  • It’s always helpful to save the URL to sign in with – this is typically sent in a welcome email for the service in question. I’ve found that if I go to my o365 site and am unable to sign in using the sights “Sign in” page, I can always use that original URL to sign in, and that works every time.
  • Almost all problems with sign on are cookie related – meaning you can fix them easily by deleting all your cookies
  • If you have lots of work to do and need to be logged in to two accounts at once, you can try one of these approaches:
    • Use different browsers ie one ID is logged into IE and another into Chrome.
    • Sign in but don’t check the “remember me” option.

Ok so now that the mechanics are out of the way, You probably can’t wait to get started. There is a cool Development environment in the browser called Napa, which you’ll want to install. Step 2 in the above screenshot outlines it, but you might run into trouble (I did) and if so this article by Krunal Patel might be helpful: Enable Napa App for Office Online Development with SharePoint

With that installed and out of the way, here’s an article to get you started developing your first app for SP2013 in Office 365:

How to: Create a basic app for SharePoint by using “Napa” Office 365 Development Tools

Powershell to check SSL certificates Expiration dates

SSL certificates expire every now and again.

After getting caught off guard about an expired SSL certificate, I thought I’d search and see if I could find a powershell script I could run on the web front ends where the certs are installed.

I found a post on stack overflow that was a good starting point:
http://stackoverflow.com/questions/16181725/powershell-script-to-find-currently-bound-expiring-certificates-in-iis

I made a few simple modifications, formatting the output slightly differently, and adding email to the script, but basically what you see below is mostly from the above post, credit goes to Ansgar Wiechers for posting the solution I used.

You’ll want to test the script as is, then change the $DaysToExpiration to something more reasonable such as 30.

I added this script to the “Scripts” folder on my Web servers, and then created a windows “Scheduled task” to run PowerShell along with the script, scheduled nightly. I let it run a few times with $DaysToExpiration set to 700 (to confirm I would actually get the email.) After I knew that it worked I changed the number to a more reasonable 45.