반응형
    
    
    
  오류 수정방법 "Microsoft에서 PowerShell 스냅인을 로드할 수 없습니다.파워쉘.다음 오류로 인한 진단: 파일 또는 어셈블리를 로드할 수 없습니다."
asp.net 웹 페이지에서 Powershell 스크립트를 실행하려고 하는데 스크립트를 실행하려고 하면 이 오류가 계속 나타납니다.스크립트를 실행하는 방법은 두 가지를 시도해 보았는데 두 가지 모두 같은 오류가 발생합니다.전체 오류는 다음과 같습니다.
요청 PSSnapInException: PowerShell 스냅인을 Microsoft에서 로드할 수 없음을 처리하는 동안 처리되지 않은 예외가 발생했습니다.파워쉘.다음 오류로 인해 진단: 'C:\source\repos\' 파일 또는 어셈블리를 로드할 수 없습니다.웹앱\WebApp\Microsoft.파워쉘.명령'.지정한 파일을 찾을 수 없습니다.
PowerShell powershell = PowerShell.Create();
            using (Runspace runspace = RunspaceFactory.CreateRunspace())
            {
                runspace.Open();
                powershell.Runspace = runspace;
                System.IO.StreamReader sr = new System.IO.StreamReader("C:\\Desktop\\test.ps1");
                powershell.AddScript(sr.ReadToEnd());
                var results = powershell.Invoke();
                if (powershell.Streams.Error.Count > 0)
                {
                    // error records were written to the error stream.
                    // do something with the items found.
                }
            }
    using (PowerShell PowerShellInstance = PowerShell.Create())
                {   
  PowerShellInstance.AddScript("C:\\Users\\RSpotton\\Desktop\\test.ps1");
                    PowerShellInstance.Invoke();
                }
저도 비슷한 문제와 함께 오류 메시지가 있었습니다.다음에 대한 NuGet 패키지 설치Microsoft.PowerShell.SDK내 프로젝트에 성공했습니다.
언급URL : https://stackoverflow.com/questions/57166406/how-to-fix-error-cannot-load-powershell-snap-in-microsoft-powershell-diagnostic
반응형
    
    
    
  'programing' 카테고리의 다른 글
| Elixir Ecto SQL comments /* comment /* 선택 1; (0) | 2023.09.08 | 
|---|---|
| 새 TTY로 이미 실행 중인 도커 컨테이너에 입력하는 방법 (0) | 2023.09.08 | 
| Hibernate HQL에서 Oracle의 regexp_like를 사용하는 방법은 무엇입니까? (0) | 2023.09.08 | 
| ASP에서 "runAll Managed Modules For All Requests"의 올바른 사용법은 무엇입니까?NET MVC 2/3? (0) | 2023.09.08 | 
| iOS7 탭에 UI 버튼이 하이라이트로 표시되지 않음 (0) | 2023.09.08 |