PowerShell

PowerShell Modules Maintenance

Introduction From time-to-time I am updating all installed PowerShell modules on my dev-machines. This can lead to a large amount of used disk space, as old versions are kept on the drive. In this post, I want to share the scripts for the two tasks. After updating modules, I noticed a large amount of data is stored in my C:\Users\<username>\Documents\PowerShell\Modules folder. To be specific, the folder eats up 3.1GB of space.

No Default Subscription?

Set-AzureWebsite : No default subscription has been designated. Use Select-AzureSubscription -Default to set the default subscription. *doh* Again I’ve used PowerShell comandlets for Azure classic instead of Resource Manager 🙁 Reminder: Always check for the magic “Rm” chars in the command, if a resource cannot be found.

HowTo use Azure cmdlets in Azure Schedule

A Runbook schedule can be triggered every hour. If you need a smaller interval, like every minute, you can use the Azure Scheduler to do so. So I went to the Azure Portal, created an Azure Schedule instance (with a job collection tier of at least basic, to be able to create schedules that are triggered every minute) and called a Runbook via webhook. The Runbook contains a cmdlet that results in an error 🙁

Connection Problems to a Secure Service Fabric Cluster

To be able to connect to a secure Service Fabric Cluster via PowerShell, you need to import the certificate specified into your personal certificate store. Otherwise an Exception will be thrown. Unfortunately the Exception does not point into the right direction 🙁 So in case you get an Exception like this Connect-ServiceFabricCluster : An error occurred during this operation. Please check the trace logs for more details. At line:1 char:1

Need users in your dev environment?

Often, you’ll need some users with data like picture and manager in your new development environment. Since you usually recycle your dev AD, this doesn’t happen frequently. But if you have to set up a new domain, you’ll want testusers with data. I don’t want to search again, because I found a great resource for creating users here: http://mrhodes.net/2011/10/25/adding-285-contoso-users-with-pictures-to-your-development-environment-active-directory/ Have fun with PowerShell

Create the default groups via PowerShell

If your site is missing the three default groups “Visitors”, “Members” and “Owners”, you can create them easily with PowerShell or the Object Model. Add-PSSnapin Microsoft.SharePoint.PowerShell $web = Get-SPWeb https://your.site.url if ($web.AssociatedVisitorGroup -eq $null) { Write-Host 'The Visitor Group does not exist. It will be created...' -ForegroundColor DarkYellow $currentLogin = $web.CurrentUser.LoginName if ($web.CurrentUser.IsSiteAdmin -eq $false){ Write-Host ('The user '+$currentLogin+' needs to be a SiteCollection administrator, to create the default groups.') -ForegroundColor Red return } $web.

Update to the SharePoint Solution Deployer

A new version is out. If brings some great new extensions (two of them are from me 🙂 ) v5.0.4.6440 (2015-04-04) New: All extensions added: Blocked file extensions, content type hub, custom crawl connector, features, logging configuration, managed metadata, re-ghost, search schema, secure store, site structure, CSOM extensions for files and 2013 workflows Updated: SharePointVersions.xml Updated: Typos in comments fixed and some code clean-up First release based on GitHub repository Grab your version from http://spsd.

The SharePoint Solution Deployer

Deploying Solutions can be a …. (fill in as you wish). The SharePoint Solution Deployer offers a great opportunity to writing your own scripts. The existing functionality should match your needs to deploy SharePoint Solutions. If not, the “framework” can be extended with custom Extensions or simple PowerShell code. I’ve written two Extensions, which let you enable and disable features upon deployments and reset files to their site definitions (aka ReGhost).

Use a XML-file for configuration in PowerShell scripts

Time for some PowerShell! Almost every PowerShell script need some configuration parameters. With this post I want to show one way, there are others ;-), to parse a config file in XML format and use the values later. The solution I’m going to show to you contains three files. A PowerShell script, a XML configuration file and a helper PowerShell file that contains a function to parse the config file.

Start / Stop SharePoint Services via PowerShell

If you have installed SharePoint on your workstation, you might want to start the services only in case of active development. Otherwise the services consume memory and other resources. The PowerShell script in this post will allow you to easily start and stop all required services for a local SharePoint Installation. It will detect if you’ve installed SharePoint 2007/WSS, SharePoint 2010 or SharePoint 2013. Just copy the code below to a file, name it StartStopSharePoint.