Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function Get-CustomLoadParameter {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[Microsoft.SharePoint.Client.ClientObject]$Object,
[Parameter(Mandatory=$true)]
[string]$PropertyName
)
# Reference: http://sharepoint.stackexchange.com/questions/126221/spo-retrieve-hasuniqueroleassignements-property-using-powershell
$Context = $Object.Context
$Load = [Microsoft.SharePoint.Client.ClientContext].GetMethod("Load")
$Type = $Object.GetType()
$ClientLoad = $Load.MakeGenericMethod($Type)
$Parameter = [System.Linq.Expressions.Expression]::Parameter(($Type), $Type.Name)
$Expression = [System.Linq.Expressions.Expression]::Lambda(
[System.Linq.Expressions.Expression]::Convert(
[System.Linq.Expressions.Expression]::PropertyOrField($Parameter,$PropertyName),
[System.Object]
),
$($Parameter)
)
$ExpressionArray = [System.Array]::CreateInstance($Expression.GetType(), 1)
$ExpressionArray.SetValue($Expression, 0)
return $ExpressionArray
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.