Task Schedule: This task requires that the user account specified has Log on as batch job right

When creating a new Task within Task Scheduler and attempting to set the “When running the task, use the following user account” option, you may receive the following error message:

Task Schedule: This task requires that the user account specified has Log on as batch job rights

This can be resolved by ensuring the user account has the correct permissions on the server.

  1. Click the Start button.
  2. Within the Search field, type secpol and, when displayed, click Local Security Policy.
  3. Within the Local Security Policy window, expand the Local Policies node.
  4. Expand the User Rights Assignment node.
  5. In the right-hand panel, right-click Log on as a batch job and select the Properties option.
  6. In the Log on as batch job Properties window, click the Add User or Group… button and add the user or group you want to give access.
  7. Click the OK button to close the window.
  8. Click the OK button to close the Log on as batch job Properties window .

Extra: Task Scheduler Error and Success Constants


Task Scheduler & PowerShell

To manage repeating tasks, its common for us (the team I work with 9-5) to automate things with a PowerShell script and then schedule it to repeat at specific times using a scheduled task.

When I create the task I use a specific set of parameters , which I always forget – so I’m noting them here for future reference.

PowerShell.exe -NoProfile -ExecutionPolicy ByPass -File C:\PowerShell\Get-SomethingNice.ps1


Upload limits within IIS7

By default, IIS7 will restrict uploaded greater than 30mb. To overcome this, the following settings can be added to the web.config file within your web application.

            <requestLimits maxAllowedContentLength="157286400" />

The value for the maxAllowedContentLength attribute should be specified in bytes (MB to Bytes Conversion).

See Error message when you visit a Web site that is hosted on a server that is running Internet Information Services 7.0: “HTTP Error 404.13 – CONTENT_LENGTH_TOO_LARGE”.

It can also be helpful to define the maxRequestLength and executionTimeout attributes.

    <customErrors defaultRedirect="~/Error.aspx" mode="On">
        <error statusCode="404" redirect="~/Error.aspx" />
    <pages />
    <globalization culture="en-GB" uiCulture="en-GB" />
    <sessionState timeout="60" cookieless="AutoDetect" />
    <httpRuntime executionTimeout="300" maxRequestLength="150000" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" />

Trouble Shooting SharePoint Errors

For viewing in command prompt:

Get-SPLogEvent | ?{$_.Correlation -eq "<GUID>"} | SELECT Area, Category, Level, EventID, Message | Format-List

Export the results as text file:

Get-SPLogEvent | ?{$_.Correlation -eq "<GUID>"} | SELECT Area, Category, Level, EventID, Message | Format-List > C:\Error.log

Results can be retrieved faster if the time span is limited:

Get-SPLogEvent -StartTime YYYY-MM-DDTHH:mm:ss | ?{$_.Correlation -eq "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"} | SELECT Area, Category, Level, EventID, Message | Format-List

Synching Event Categories Between Outlook and SharePoint

Oddly, within SharePoint 2010 at least, when you connect a calendar to Outlook it will not synchronise the category information for the event. It seems that Outlook uses a field named Categories to store this information and SharePoint uses Category.

Although not ideal, we can resolve the issue by visiting the List Settings page for the calendar, opening the Event content type and adding Categories from the list of pre-existing columns.


Upload a .STP Template File

This is a quick way to programmatically upload a .STP template file within SharePoint using PowerShell – useful if you’re transferring list templates from a development to a live environment.

$web = Get-SPWeb "http://mydomain"
$folder = $web.GetFolder( "List Template Gallery" )
$files = $folder.Files
$file = Get-ChildItem "C:\MyListTemplate.stp"
$newfile = $files.Add( "_catalogs/lt/MyListTemplate.stp", $file.OpenRead(), $true )

Sharing permissions for Authenticated Users

Note to self: When setting permissions and sharing content stored within SharePoint 2013, Microsoft have now hidden the “All Authenticated Users” option that was present in 2010. To get around this, just type “NT AUTHORITY\AUTHENTICATED USERS” and click the Share button.


“Access Denied”

Every so often I receive a helpdesk call from a user who, although their account is a member of the SharePoint site’s Owners, Members or Visitors group, is still presented with the generic “Access Denied” page when they attempt to visit the site.

After a bit of Googling, I found this post that seemed to have the answer.

The trick is to flush the user’s access permissions and recreate them. This can be done by:

  1. Remove the user’s account from the SharePoint group.
  2. Add the account into the Site Collection Administrators group (Site Actions > Site Settings > Site collection administrators).
  3. Remove the account from the Site Collection Administrators group.
  4. Add the account back into the original SharePoint group.

Seems to do the trick!

Update: 4 September 2013

If the above fails to work, you can also try completely removing the user’s profile from the Site Collection.

  1. Open an existing group, e.g. Owners. Its web address will be along the lines of http://domain/_layouts/people.aspx?MembershipGroupID=4.
  2. Change the value for the MembershipGroupId parameter to 0.  This should display the People and Groups – All People list.
  3. Locate and delete the troublesome user from the list (Actions > Delete Users from Site Collection).
  4. Add the deleted user back into the necessary group.

Windows Server 2008 Disk Cleanup

SharePoint Central Admin has been prompting me, each time I’ve logged in, that one of my drives is running out of space. To be honest, there isn’t a lot that I can do – a small initial system drive and successive Windows updates have gradually eaten away at the free space – but I needed to free-up what I could.

The default install of Server 2008 doesn’t come with a disk clean-up option. You would normally have to install the “Desktop Experience” feature to get this option.

Handily, I found this post from Microsoft: Disk Cleanup option on drive’s general properties and cleanmgr.exe is not present in Windows Server 2008 or Windows Server 2008 R2 by default


Downloading Solutions from Central Administration

This is a handy little PowerShell snippet that I needed to use today. There were two .WSP solutions installed within the SharePoint farm and I couldn’t locate the original source code.

$farm = Get-SPFarm
$solution = $farm.Solutions.Item("MySharePointSolution.wsp").SolutionFile