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. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access