我是Powershell Runbook的新手,所以請原諒我,如果我失去了明顯的東西。我正在嘗試從我的腳本中記錄Application Insights請求,但甚至無法加載DLL,儘管我已經看到其他代碼非常類似。請注意,這是一個Powershell Runbook,而不是Powershell Workflow Runbook。Azure自動化Powershell Runbook默默無法LoadAssembly
這裏是我的代碼:
Write-Output "Starting"
$assemblyPath = "C:\Modules\Global\Azure\Compute\Microsoft.ApplicationInsights.dll"
dir $assemblyPath
Write-Output "1"
[System.Reflection.Assembly]::LoadFrom($assemblyPath)
Write-Output "2"
而這裏的產量在測試窗格中運行它時,我得到:
Starting
Directory: C:\Modules\Global\Azure\Compute
Mode LastWriteTime Length Name
---- ------------- ------ ----
------ 1/11/2016 1:59 PM 152824 Microsoft.ApplicationInsights.dll
1
Starting
Directory: C:\Modules\Global\Azure\Compute
Mode LastWriteTime Length Name
---- ------------- ------ ----
------ 1/11/2016 1:59 PM 152824 Microsoft.ApplicationInsights.dll
1
Starting
Directory: C:\Modules\Global\Azure\Compute
Mode LastWriteTime Length Name
---- ------------- ------ ----
------ 1/11/2016 1:59 PM 152824 Microsoft.ApplicationInsights.dll
1
它似乎變得儘可能的LoadAssembly,然後擲骰子出來,在放棄之前運行腳本三次。任何想法我做錯了什麼?該DLL顯然存在於該位置,並且我沒有收到任何錯誤輸出來幫助我進行調試。謝謝!
@BenH感謝您的回覆,我真的看到了這篇文章,我應該提到我也嘗試過這條路徑,但程序集甚至不存在: dir:找不到路徑'C :\ Modules \ Azure \ Microsoft.ApplicationInsights.dll'因爲它不存在。 – UnionP
我能夠通過切換到Powershell Runbook解決我的問題,並將所有.NET調用封裝在InlineScript塊中。不是最優雅的,但它的作品。仍然會喜歡聽到有沒有辦法讓這個工作不需要做, – UnionP
好,嘗試做嘗試和輸出錯誤? – 4c74356b41