2017-04-21 1 views
0

매개 변수가있는 Office 2010을 설치하는 중 스크립트를 배포 할 수있는 관리자 권한이있는 PSSession을 만들었지 만 여러 사용자에게 문제가 있습니다.Powershell foreach in pssession

설치가 시작되지 않으므로 invoke를 사용할 수 없습니다.

이 스크립트를 여러 컴퓨터에 배포하는 다른 방법이 있습니까?

CLS 
Start-Job -Name Job1 -ScriptBlock { 
$domainuser = "$env:USERDNSDOMAIN\administrator" 
$domainpassword = 'Credential' | ConvertTo-SecureString -AsPlainText -Force 
$domaincredentials = New-Object System.Management.Automation.PSCredential ($domainuser, $domainpassword) 
$ip = "192.168.10.75" 

Enter-PSSession -ComputerName $ip -Credential $domaincredentials } 
Wait-Job -Name Job1 
Start-Process -FilePath "powershell" -Verb runAs 
Start-Process -FilePath "C:\temp\32 Bit\setup.exe" -ArgumentList "/adminfile Office2010.MSP" 

답변

0

바로 실행하려면 setup.exe (관리자 등), 원격 컴퓨터에서 :

$domainuser = "$env:USERDNSDOMAIN\administrator" 
$domainpassword = 'Credential' | ConvertTo-SecureString -AsPlainText -Force 
$domaincredentials = New-Object System.Management.Automation.PSCredential ($domainuser, $domainpassword) 
$ip = "192.168.10.75" 

Enter-PSSession -ComputerName $ip -Credential $domaincredentials 
Start-Process -FilePath "C:\temp\32 Bit\setup.exe" -ArgumentList '/adminfile "C:\temp\32 Bit\Office2010.MSP"' -Verb runAs -Wait 
Exit-PSSession 

나는 설정과 같은 폴더에있는 MSP 가정, 그래서 나는 전체 경로를 포함 시켰습니다 MSP 파일에 ... 스페이스 폴더 이름으로 인해 큰 따옴표를 사용했습니다.