Créer un site internet

Sharepoint Powershell tips

fredericdietrich By On 28/09/2018

In Powershell

To add your assembly in powershell script / console

Add-Type -AssemblyName System.Web

 

Copy string to clipboard

"your datas" | c:\windows\system32\clip.exe

 

Reference sharepoint in powershell console

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

 

Set your execution policy if you see this message

Impossible de charger le fichier D:\FDI\wordPress\ps1\EncodeHtml.ps1, car l’exécution de scripts est désactivée sur ce système. Pour plus
d’informations, consultez about_Execution_Policies à l’adresse https://go.microsoft.com/fwlink/?LinkID=135170.
+ CategoryInfo : Erreur de sécurité : (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess

set-executionpolicy -executionpolicy unrestricted

powershell.exe -executionpolicy unrestricted -command .\test.ps1

 

Sort and filter your collections

$l.Fields | select internalname, title, type, hidden | Where-Object {$_.Hidden -eq $false} | Sort-Object -Property internalname | Format-Table

get spfields by group

$w.Fields | Where-Object {$_.Group -eq "Site colums FDI"} | select internalName, typeasstring

List files in folder and copy to clipboard

$files = ls | select name

$files | c:\windows\system32\clip.exe

 

Regular expression to check file names

"toto.spx" -match "^[a-zA-Z0-9._ -]+$"

 

Load an assembly

Import-Module ".\Microsoft.SharePoint.Client.Runtime.dll"

 

Get logs from all servers on sharepoint farm

Merge-SPLogFile -Path "C:\temp\FarmMergedLog41.log" -Overwrite -Level Unexpected -StartTime (Get-Date).AddMinutes(-20)

Merge-SPLogFile -Path "C:\temp\FarmMergedLog22.log" -Overwrite -Correlation "52b2019e-d446-70aa-8f27-8efc5ec7f143" -StartTime (Get-Date).AddMinutes(-90)

 

Open a powershell console as another account

Start-Process powershell.exe -Credential "domain\spadmin" -NoNewWindow -ArgumentList "Start-Process powershell.exe -Verb runAs"

 

Export webpart from page

http://fdi-sp2013-1/_vti_bin/exportwp.aspx?pageurl=http://fdi-sp2013-1/Lists/Pratique/PratiqueHome.aspx&guidstring=84e04c62-3eb5-424e-a7f9-3219ff89d51c

 

Create a site collection

New-SPSite -Template STS#0 -OwnerAlias fdi\spdev -Url http://fdi-sp2013-1/sites/test6541 -Verbose -Confirm:$false -Language 1036 -Name test987 -Description oio

 

Do not use jquery $(document).ready(function () {

Use instead :

_spBodyOnLoadFunctionNames.push("loadAnnonce");//loadAnnonce is function loadAnnonce() called

 

Edit page on url change

?ControlMode=Edit&DisplayMode=Design

 

List assemblies

[AppDomain]::CurrentDomain.GetAssemblies() | Where-Object {$_.Location -ne $null -and $_.Location -like "*t.Client.*"}

 

Use stringBuilder to mange string concat

$stringBuilder = New-Object System.Text.StringBuilder

 

List of all sharepoint features

csv format

xlsx format

 

powershell

  • 4 votes. Average: 4.8 / 5.