Referencing an Assembly

Scenario/Problem: You want to be able to call methods and/or use objects within a trusted assembly (DLL).

Solution: Use a reflection declaration, and then use a variable to instantiate an object.

You can reference an assembly in your PowerShell script and then use any objects available by assigning them to a variable. Then you can use any methods or properties within your script. No intellisense exists, so you need to know the object model beforehand. Listing 2.5 demonstrates an example assembly reference and usage.

Listing 2.5. Referencing and Using a SharePoint Assembly

[Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")[Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft. ...

Get PowerShell™ for SharePoint® 2013 How-To now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.