Skip to content

Instantly share code, notes, and snippets.

@vgrem
Created January 5, 2015 08:13
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/34d0e65b0732a1b368ce to your computer and use it in GitHub Desktop.
Save vgrem/34d0e65b0732a1b368ce to your computer and use it in GitHub Desktop.
Function Invoke-LoadMethodV2() {
param(
$Context = $(throw "Please provide an Client Context"),
$Object = $(throw "Please provide an Client Object instance on which to invoke the generic method")
)
$load = [Microsoft.SharePoint.Client.ClientContext].GetMethod("Load")
$type = $Object.GetType()
$clientObjectLoad = $load.MakeGenericMethod($type)
$clientObjectLoad.Invoke($Context,@($Object,$null))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment