2014-09-10 2 views
0

여기를 확인했는데 몇 가지 주제가 double clikc ps1 파일에 대해 이야기하고 있습니다. ,ps1 파일을 두 번 클릭하면 powershell 창이 사라집니다.

powershell.exe -command "& 'C:\A path with spaces\MyScript.ps1' -MyArguments blah" 

나는 PC의 이름을 입력 한 후,

$pw = convertto-securestring -AsPlainText -Force -String xxxxxx 
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist "xxxx\admin",$pw 
$pc = Read-Host -Prompt "Please Enter PC name" 
$session = new-pssession -computername $pc -credential $cred 
Enter-PSSession $session 

와 나는 그것을 두 번 클릭하여 실행하기 위해 this way을 시도 : 하지만 내 상황은이 같은 원격 세션을 여는 PS1 파일을 가지고있다 콘솔이 사라집니다 ....

이유가 무엇입니까?

답변

2

-NoExit 옵션을 사용해 보셨습니까?

powershell.exe -NoExit -command "& 'C:\A path with spaces\MyScript.ps1' -MyArguments blah" 
+0

덕분에, 그것은 -noexit 옵션과 함께 작동합니다. didnt는 noexit 옵션 lol이 있음을 안다. –

관련 문제