Qu'est-ce que Windows Powershell ? Windows PowerShell est un nouvel outil en ligne de commandes et langage de script de Microsoft qui complète Cmd.exe dans le contexte de l'administration de Windows. Dans le contexte de l'administration de SharePoint, Windows PowerShell remplace l'outil d'administration Stsadm.exe. De plus, vous devez désormais utiliser la technologie de scripting Windows PowerShell pour développer des scripts en ligne de commande pour SharePoint Foundation 2010. Tout d'abord nous devons charger dans la console PowerShell l'assembly SharePoint, qui est la référence pour tous les objets de SharePoint. PS C:\Users\sunil> [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Sharepoint") GAC Version Location --- ------- -------- True v2.0.50727 C:\Windows\assembly\GAC_MSIL\Microsoft.SharePoint\12.0.0.0__71e9bce111e9429c\Microsoft.SharePo... Créer un objet "site" qui contient la référence au SPSite. PS C:\Users\sunil> $site=new-object Microsoft.Sharepoint.SPSite("http://mossportal") Obtenir une référence au site web qui est associé à l'URL utilisée dans un constructeur SPSite. PS C:\Users\sunil> $web=$site.OpenWeb() Now defines the role assignments for a user. PS C:\Users\sunil> $spRoleAssignment=new object(SPRoleAssignment("mossportal\sunil", "sunilyadav165@gmail.com", "Sunil Yadav", "Sharepoint developer") Get the role from the web and set the base permission for a role definition.
>> $spRoleDefinition=$web.RoleDefinitions["Read"]
>> $spRoleAssignment.RoleDefinitionBindings.Add($spRoleDefinition)
Finally add the RoleAssignments to the current we and update the spweb object.
>> $web.RoleAssignments.Add($spRoleAssignment)
>> $web.Update()
This articles is also available in the following languages: