2016-08-11 8 views
1

다른 워크 스테이션에서이 작업을 실행할 수 있기를 원합니다. 나는 이것을 아래에 가지고있다. 그러나 그것은 일하는 것처럼 보이지 않는다. 틀린 것을 볼 수 있습니까?PowerShell로 인증하여 프로세스 죽이기

get-content .\killprocess.PS1 

$username = 'je\leigh' 
$password = cat 'U:\Accounts\Synergy Tools\securestring.txt' | convertto-securestring 
$cred = new-object -typename System.Management.Automation.PSCredential `-argumentlist $username, $password 

(Get-Content 'U:\Accounts\Synergy Tools\Computers.txt') | ForEach-Object {Get-WmiObject -computer $_ -class win32_process -filter "name='synergy.exe' or name='booking9.exe' or name='acl_apps.exe' or name='pos.exe' or name='booking.exe'" -credential $cred| %{$_.terminate()} | out-null} 
+0

무엇이 오류 메시지입니까? – Avshalom

답변

0

securestring.txt 예컨대 읽을 수있는 암호가 포함 된 경우 [email protected]!123. ConvertTo-SecureString-AsPlainText & -Force 매개 변수를 사용하여보십시오 :

$password = Get-Content 'U:\...\securestring.txt' | ConvertTo-SecureString -AsPlainText -Force 

$Password | ConvertFrom-SecureString으로 볼 수있는 읽을 수 SecureStringsecurestring.txt에 텍스트를 변환합니다 :

01000000d08c9ddf0115d1118c7a00c04fc297eb010000000a65b1b20fe4e0418aece793d7242358 
0000000002000000000003660000c00000001000000082e9a55adb7c90d9bed5946aed69e5380000 
000004800000a000000010000000932bccf24879272d36536f6ef98e1be4180000006fb092d673a8 
1f84b5954f9cb35daee2addb2d325ec25112140000005c8982b4cd15503000796213c3e0d3869780 

그런 다음 바로 $password 변수 직선을 제공 ~ -argumentlist $username, $password

당신이 원한다면 securestring.txtConvertFrom-SecureString의 utput 다음 스크립트에서 다음을 사용

$password = Get-Content 'U:\...\securestring.txt' | ConvertTo-SecureString  

을 : securestring.txt에서 한 줄 이상이있는 경우 오류가 발생할 수 있습니다 그것은 $password 문자열 배열을 켜집니다있다.

+0

@ leigh-carmichael이 답변으로 귀하의 질문에 도움이되었거나 답변을 구했거나 수락 하시길 바랍니다. – Richard