The first post in this series covered the basics of PowerShell including variables, loops, and decisions. It also introduced a few scripts I’ve used over the last several weeks. In this post, we’ll discuss how to use PowerShell in a SharePoint farm, some of the more useful capabilities (especially to developers), and a few more scripts that I’ve written to bring the topics covered together.

Integrating PowerShell With SharePoint

PowerShell has been natively supported in SharePoint since SharePoint Foundation 2010 and SharePoint Server 2010. When SharePoint is installed, in addition to the Product Configuration Wizard and Central Administration shortcuts, a shortcut for the SharePoint Management Shell is available. This application is a PowerShell console with a blue background and the SharePoint Snap-in loaded. The PowerShell Snap-in is a PowerShell version 1 object that, when loaded, makes additional functions (or cmdlets) available to call in the current PowerShell session. To do this, simply execute the following:

Add-PSSnapin "Microsoft.SharePoint.PowerShell"

This will allow you to access the SharePoint cmdlets in any PowerShell session. It’s also important to run the PowerShell or SharePoint Management Shell console as administrator as the logged-in user may only have limited access to the SharePoint farm.

Read More…

When I apply for speaking engagements, I usually submit at least one session that will require me to learn a new language or technology.  I did this with the upcoming SharePoint Saturday Austin with a session titled “PowerShell for Developers: IT Pros Need to Share.”  This session is the catalyst for this three-part blog series, which will be published over the next few Fridays. This first post is intended to get everyone up to speed with the basics of PowerShell.

What is PowerShell?

PowerShell is a command-line language built on the Microsoft .NET Framework. This is a ridiculously simplified explanation, though. PowerShell is a task automation tool that takes common command-line languages and magnifies their power exponentially through the use of Cmdlets.  Cmdlets are verb-noun commands that perform computer and application management tasks. These tasks can be as simple as restarting the computer or changing the time zone.

PowerShell is a sophisticated development language that contains many of the constructs found in other modern languages. Variables, functions, looping, and decision statements are all present among other important features. We will discuss these features and how they function in this post. Read More…

I was recently working on an automation task that involved opening an XML document, reading the values its contents, and passing them as arguments to install a variety of processes, etc., etc. All rather routine and mundane. Of course, my XML document was littered with environment variables and other special monikers that would be replaced after the file had been loaded. So I reached for my PowerShell editor and started putting together a solution. Then I got to thinking…why don’t I just embed PowerShell variables directly in the file?

Well, why not indeed. The problem was as PowerShell read the file in, it simply ignored my variables and I was stuck with an XML attribute value of something like $Domain\$User. It didn’t help me one whit. Surely there must be some way to convince PowerShell to evaluate that.

As luck would have it, there is! Or I should say, there are! Because it turns out there are multiple ways to do this, none of which are specific to XML (that was just my target data). So, let’s review the options…

Read More…

I’ve been working with Powershell lately, and I wrote a couple of functions to help verify server permissions in Microsoft SQL Server.

Why would I want to verify server permissions instead of verifying server roles? In my case, I’m interested in knowing if a particular user is able to create a database on a SQL Server. While the dbcreator role does allow a user to create a database, there are other roles that will also allow a user to create a database, such as sysadmin. Additionally, if a user is a member of an AD Group that has the role assigned, then the role is not directly assigned to the user. In the end, I found it simplest to check for the actual CREATE ANY DATABASE permission.

In this post, we will see how to check if the current AD user has a specific server permission and how to check if an AD account other than the current user has a specific server permission.

Read More…

This week, many AIS team members are attending the Microsoft SharePoint Conference in Las Vegas, Nevada. We’ll be posting blog posts from each of them as they learn what’s new and what’s exciting during sessions, demonstrations and other conference highlights.

We’re out at the SharePoint Conference 2012 this week and learning a ton about the new features of SharePoint 2013. One of particular interest to the IT pros should be the introduction of PowerShell 3.0. There are a number of new features available in PowerShell 3.0 not to mention the cmdlets!

Read More…

Some end-of-the-week reads from AIS employees’ personal blogs:

Windows Azure Planning: A Post-Decision Guide to Integrate Windows Azure in Your Environment: AIS’ CTO Vishwas Lele posted a complete planning guide on how to best adopt and integrate Windows Azure into your organization. (Fleeting Thoughts)

SharePoint Saturday Cincinnati Session: Clint Richardson (who wrote the excellent three-part series on The Best New Features of SQL Server 2012) presented a Voluntold admin session at last week’s SharePoint Saturday Cincinnati. His presentation, relevant links and PowerShell code are all available at his blog. (pointblankadmin)

Understanding and Using System.Transactions: Ash Tewari has compiled an excellent library of resources to help you understand and effectively use System.Transactions functionality in your .NET projects. (tewari.info)

Adaptive Problems Require Responding to Change Over Following a Plan: More deep thoughts on the Scrum framework and Agile values from Ryan Cromwell. (cromwellhaus)

Aliasing Multiple Properties in Knockout JS Bindings: David Benson figured out another handy use for Knockout JS’s “with” statement: you can emulate c# style “using” directives. (dben codes)

Teach Your Kid to Code: Steve Michelotti (and his 5th grade son!) will be co-presenting a great, fun session called Teach Your Kid to Code at the CMAP meeting next Tuesday evening in Columbia, MD. (Don’t forget to get out and vote early, too.) (Steve Michelotti)

I was recently asked to write my own custom performance metric and publish it to Amazon’s CloudWatch using PowerShell.

Part I: How do I get this thing running already?

I initially used this blog post as a general guide, but since I had some experience with PowerShell already, the real learning part for me was how to call the API through .NET. (There is a second part, which actually shows you how to publish the metric. Unfortunately, his test “Tutorial” namespace ended up in the wrong region [US East] as compared to my instance [US West Oregon].

I figured out the correct way to do this by teasing apart the free community scripts available on AWS, which I will discuss later (see Part 2).

Read More…

I recently learned a trick for deploying a folder of report templates in TFS to a handful of development team folders: PowerShell.

Being new to PowerShell, I won’t attempt to explain its usefulness or much of its mechanics because those of you who know, already know. (And those of you who don’t know should definitely check it out.) Basically, PowerShell is a handy tool for performing batch tasks that might otherwise cause unsightly bald spots.

Read More…

In addition to contributing to AIS’ brand-new corporate blog, many members of our team have their own personal blogs. We may be biased, but we certainly think they’re worth a spot in your bookmarks or reader feed. Here’s what some of them have been writing about lately:

Beyond the Agile Programmer: Innovative Teams: Ryan Cromwell attended illustrator Brad Colbow’s session on Building a Design Culture at Midwest UX (where AIS was a sponsor). It got him thinking about how Scrum can enable a culture of innovation.

Using Windows Azure IaaS to host SharePoint 2010: Harin Sandhoo shares the time-saving PowerShell script he uses to set up the infrastructure for SharePoint farms in Azure’s IaaS offering. (sandhoo.wordpress.com)

Update Azure DB Firewall Rules with PowerShell: Here’s another handy PowerShell from Tom McKearney for work-from-home Azure developers who are tired of constantly updating their SQL Azure Firewall settings.  (Codemares)

Setting Up SharePoint 2010 in Amazon Web Services (AWS)
: Chris Hettinger has absolutely everything you need to know about migrating a SharePoint environment to Amazon’s great big datacenter in the cloud. (messor.com)