close
假設要使用一個別人所寫的dll檔
可由以下步驟達成
(1)載入該dll檔
PS D:\> $SampleAssembly = [Reflection.Assembly]::LoadFrom("drive:\\the location of the dll file")
(2)檢查該dll檔是否被載入
PS D:\> [AppDomain]::CurrentDomain.GetAssemblies() |select Fullname,Location|format-list
(3)查看該dll檔有何class及其namespace
PS D:\> $SampleAssembly.GetTypes() | select Name,IsClass,Namespace
(4)宣告某物件
PS D:\> $obj = New-Object Namespace.ClassName
(5)查看某物件有何屬性及方法可用
PS D:\> $obj | get-member
參考資料
http://msdn2.microsoft.com/zh-tw/library/1009fa28(VS.80).aspx
Load a Custom DLL from PowerShell
PowerShell and SharePoint - Oh Yes
全站熱搜