Last active
August 29, 2015 14:17
-
-
Save sebastienlevert/81105fd7860bc7d8abcd to your computer and use it in GitHub Desktop.
Lundis PowerShell #1 - Charger les librairies clientes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.DESCRIPTION | |
Downloads the latest SharePoint Online Client Libraries (CSOM) from your SharePoint tenant. | |
Inspired by : http://modery.net/script-to-download-the-sharepoint-online-dlls/ | |
.NOTES | |
Version : 1.0 | |
Author : Sébastien Levert | |
Date : 2014/11/29 | |
.PARAMETER OutputDirectory | |
The directory where to save all the files | |
.EXAMPLE | |
.\Get-SPOClientLibraries.ps1 -OutputDirectory "ClientLibraries" | |
#> | |
#region Parameters | |
Param( | |
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()] | |
[String]$OutputDirectory | |
) | |
#endregion | |
#region References | |
#endregion | |
#region Private Methods | |
function Get-ClientLibrary() | |
{ | |
Param( | |
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()] | |
$Folder, | |
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()] | |
$LibraryName | |
) | |
Process { | |
$targetUrl = "https://github.com/OfficeDev/PnP/blob/master/Assemblies/16/{0}?raw=true" | |
$filePath = $Folder.FullName + "\" + $LibraryName | |
$libraryUrl = [String]::Format($targetUrl, $LibraryName) | |
Download-File -Url $libraryUrl -TargetPath $filePath | |
} | |
} | |
function Download-File() | |
{ | |
Param( | |
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()] | |
$Url, | |
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()] | |
$TargetPath | |
) | |
Process { | |
$webClient = (New-Object System.Net.WebClient) | |
$webClient.DownloadFile($Url, $TargetPath) | |
} | |
} | |
#endregion | |
#region Execution | |
$libraries = @("Microsoft.Office.Client.Policy.dll", | |
"Microsoft.Office.Client.TranslationServices.dll", | |
"Microsoft.Online.SharePoint.Client.Tenant.dll", | |
"Microsoft.SharePoint.Client.DocumentManagement.dll", | |
"Microsoft.SharePoint.Client.Publishing.dll", | |
"Microsoft.SharePoint.Client.Runtime.dll", | |
"Microsoft.SharePoint.Client.Search.Applications.dll", | |
"Microsoft.SharePoint.Client.Search.dll", | |
"Microsoft.SharePoint.Client.Taxonomy.dll", | |
"Microsoft.SharePoint.Client.UserProfiles.dll", | |
"Microsoft.SharePoint.Client.WorkflowServices.dll", | |
"Microsoft.SharePoint.Client.dll") | |
$folder = New-Item -Type Directory $OutputDirectory -Force | |
$libraries | ForEach-Object { | |
Get-ClientLibrary -Folder $folder -LibraryName $_ | |
} | |
#endregion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.DESCRIPTION | |
Loads all the Client Librairies into the PowerShell session | |
.NOTES | |
Version : 1.0 | |
Author : Sébastien Levert | |
Date : 2014/11/29 | |
.PARAMETER LibraryDirectory | |
The directory where the client libraries reside | |
.EXAMPLE | |
.\Load-SPOClientLibraries.ps1 -LibraryDirectory "ClientLibraries" | |
#> | |
#region Parameters | |
Param( | |
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()] | |
[String]$LibraryDirectory | |
) | |
#endregion | |
#region References | |
#endregion | |
#region Private Methods | |
function Load-ClientLibrary() | |
{ | |
Param( | |
[Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()] | |
$LibraryPath | |
) | |
Process { | |
Add-Type -Path $LibraryPath | |
} | |
} | |
#endregion | |
#region Execution | |
Get-ChildItem $LibraryDirectory | ForEach-Object { | |
Load-ClientLibrary $_.FullName | |
} | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment