PowerShell, It’s everywhere

Love it or hate it, you cannot avoid it.  if you are expecting to do any work in SharePoint 2013 then you simply need to have skills in Powershell, or at least a working knowledge of its capabilities.

Let’s assume you need to get out some stats because your manager is knocking on your door asking for Usage Reports.  These can be found under Site Settings -> Site Administration ->Popularity Trends -> View Usage Reports.

They are though a little constrained but you can get deep and dirty with powershell.  The web contains many a fine example of how to get more granular  (Example below is taken from the Technet forums so credit to R Tut)

Get the Usage Reports for a site collection in PoweShell

$searchApp = Get-SPEnterpriseSearchServiceApplication

$site = Get-SPSite “{SiteUrl}”

$result = $searchApp.GetRollupAnalyticsItemData(1,[System.Guid]::Empty,$site.ID,[System.Guid]::Empty)
$result

#for a specific date or for a specific month

$date = Get-Date “2013-01-18”
$result.GetHitCountForDay($date)
$result.GetHitCountForMonth($date)

Or using object model

SPSecurity.RunWithElevatedPrivileges(delegate
{

// You can use SPContext.Current.Site.ID if you have HttpContext

using (var site = new SPSite(siteId))
{
var context = SPServiceContext.GetContext(site);
var searchProxy = context.GetDefaultProxy(typeof(SearchServiceApplicationProxy)) as SearchServiceApplicationProxy;
var usageData= searchProxy.GetRollupAnalyticsItemData(1,Guid.Empty,site.ID,Guid.Empty);
// process it
}
});

….and in fact to enable us to schedule and script the output should we chose to do that, but we could also add code to upload this to a specific document library using powersehll for a fully automated solution for granular reporting.

You will find some impressiv examples in technet to help you manage 2013 with powershell here:

http://technet.microsoft.com/en-us/library/ee890108.aspx

You can even manage SQL server via powershell now and a whole raft of start examples abound here:

http://technet.microsoft.com/en-us/library/cc281954.aspx

So, no excuses.  Learn powershell.