Posts

Showing posts from September, 2014

SQL Server Scripts: Restart the SQL Service through a batch file

My SQL instance also has a tendency to consume all the memory on the VM (even 16GB is not enough), so I keep another script on the desktop to restart the SQL. My first problem was finding the name of the service. A simple 'net start' command in the command prompt listed all the services. The following script solved my problem: ECHO "Stopping SQL Server" net stop "MSSQLSERVER" /Y ECHO "Starting SQL Server" net start "MSSQLSERVER" @PAUSE I have found this to be very helpful when the machine is struggling and opening up services.msc seems to take an eternity. I have rekindled my love of batch files - they certainly solve the problem quickly and efficiently.

PowerShell: How do I remove a module by force?

I recently added a module to my PowerShell  version and things (to put it mildly) did not go well. I tried using  Remove-Module  but that also failed. I ended by bypassing tact and using a sledgehammer. I navigated to My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 and removed the module entry manually.

SharePoint 2010: Why cant I deploy my timer job to the specific Web Application?

Writing a timer service is easy ans there are many examples available. However, while following the instructions I encountered several problems deploying the job to a single web application. I followed the basic instructions (set the feature scope to WebApplication and the 'Assembly Deployment Target' to GlobalAssemblyCache) but the timer job was being activated across all web applications. Here is how I resolved it: 1. Set the project property 'Include Assembly In Package' to false. This removes the 'Assembly Deployment Target' option. 2. Add the output assembly as an 'Additional Assembly' in the 'Advanced' section of the package manifest. 3. Change the 'Activate on Default' in the feature properties to false. The feature will be deployed to the Web Application, but not activated. Use PowerShell to activate it.

SharePoint Online: How do I set the IRM settings for a Document Library in PowerShell?

I have used the CSOM approach to resolve the problem. Here  is an excellent post outlining the available methods that I based this script on. Import-Module 'C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell' -DisableNameChecking $loadInfo1 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client") $loadInfo2 = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Client.Runtime") $webUrl = "https://mytestsite.sharepoint.com/mysubsite" $username = "richard.leeman@mysharepointonlinelogin.com" $password = Read-Host -Prompt "Password for $username" -AsSecureString $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl) $ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) $web = $ctx.Web $lists = $web.Lists $ctx.Load($lists) $ctx.Load($web) $ctx.ExecuteQuery() $li