Skip to content

Instantly share code, notes, and snippets.

@vgrem
Last active December 28, 2015 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vgrem/7552775 to your computer and use it in GitHub Desktop.
Save vgrem/7552775 to your computer and use it in GitHub Desktop.
Function Invoke-LoadMethod() {
param(
$ClientObject = $(throw "Please provide an Client Object instance on which to invoke the generic method")
)
$ctx = $ClientObject.Context
$load = [Microsoft.SharePoint.Client.ClientContext].GetMethod("Load")
$type = $ClientObject.GetType()
$clientObjectLoad = $load.MakeGenericMethod($type)
$clientObjectLoad.Invoke($ctx,@($ClientObject,$null))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment