How to make powershell tell me about missing DLLs?

后端 未结 3 544
有刺的猬
有刺的猬 2021-02-06 08:28

I use powershell as shell in Windows. When I\'m trying to launch some application who\'s dll dependencies are missing in PATH environment variable, then nothing happens, powersh

3条回答
  •  一生所求
    2021-02-06 08:54

    I am afraid there is no way to get that info... But try to read

    An Introduction to Error Handling in PowerShell http://blogs.msdn.com/b/kebab/archive/2013/06/09/an-introduction-to-error-handling-in-powershell.aspx

    or PowerShell Tutorial – Try Catch Finally and error handling in PowerShell http://www.vexasoft.com/blogs/powershell/7255220-powershell-tutorial-try-catch-finally-and-error-handling-in-powershell

    Try
    {
        $AuthorizedUsers = Get-Content \\ FileServer\HRShare\UserList.txt -ErrorAction Stop
    }
    Catch [System.OutOfMemoryException]
    {
        Restart-Computer localhost
    }
    Catch
    {
        $ErrorMessage = $_.Exception.Message
        $FailedItem = $_.Exception.ItemName
        Send-MailMessage -From ExpensesBot@MyCompany.Com -To WinAdmin@MyCompany.Com -Subject "HR File Read Failed!" -SmtpServer EXCH01.AD.MyCompany.Com -Body "We failed to read file $FailedItem. The error message was $ErrorMessage"
        Break
    }
    Finally
    {
        $Time=Get-Date
        "This script made a read attempt at $Time" | out-file c:\logs\ExpensesScript.log -append
    }
    

提交回复
热议问题