Posts Tagged ‘PowerShell’

Assign permissions for groups using PowerShell

site = get-spsite("http://MySPSite")
$web = $site.RootWeb
$list = $web.Lists["MyList"]
$listitem = $list.Items[0] 
$user = $web.AllUsers["Domain\User"]
$role = $web.RoleDefinitions["Full Control"]
$roleassignment = New-Object Microsoft.SharePoint.SPRoleAssignment($user)

I’m not sure if this will break inheritance automatically, you may have to explicitly do that for this to work.

Use set-spuser for site permissions

        Set-SPUser [-Identity] <SPUserPipeBind> [-AddPermissionLevel <String[]>] [-AssignmentCollection 
        <SPAssignmentCollection>] [-ClearPermissions <SwitchParameter>] [-Confirm [<SwitchParameter>]] 
        [-DisplayName <String>] [-Email <String>] [-Group <SPGroupPipeBind>] [-IsSiteCollectionAdmin 
        <SwitchParameter>] [-PassThru <SwitchParameter>] [-RemovePermissionLevel <String[]>] [-SyncFromAD 
        <SwitchParameter>] [-Web <SPWebPipeBind>] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]

        The Set-SPUser cmdlet configures properties of an existing user.

An Example:

Set-SPUser -Identity 'domain\name' -Web http://sp2test/site -AddPermissionLevel Read

Edit site title and description in powershell

Please test this first in a development environment

Get-SPWeb -Identity http://SPServer | Set-SPWeb -Description "PowerShell is Cool"

$spWeb = Get-SPWeb -Identity http://SPServer 
$spWeb.Title = "PowerShell" 
$spWeb.TreeViewEnabled = "True" 


Brandon Atkinson – Blog: