이 스크립트를 사용하여 원격 컴퓨터에 Python을 설치하려고합니다. 이 파일을 서버에서 직접 실행하면됩니다. 이것은 Python_Pip_Proxy_PyWinAuto.ps1
파일입니다. 그것은 작동합니다. 나는 파일이 를 실행하지만, 파이썬이 설치되지 않음을 알 수 있도록Invoke-Command를 사용하여 Powershell을 사용하여 Python 원격 설치를 수행 할 수 없습니다.
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
Write-Host("Hi")
$installer="C:\temp\python-3.6.2.exe"
& $installer /quiet PrependPath=1 InstallAllUsers=1 TargetDir="C:\Python36"
나는 동일한 서버에서 원격으로이 작업을 실행하려면 다음 스크립트를 사용하여 Invoke-Command
을 실행하지만 경우에, 그것은 인쇄는 Hi
메시지입니다.
# Getting the list of servers from a .txt file to an array #
$SRVListFile = "C:\Scripts\ServerList.txt"
$SRVList = Get-Content $SRVListFile -ErrorAction SilentlyContinue
# Copying the .exe file from a shared location to each server in the array #
# Invoking the .ps1 file which runs natively on each server #
Foreach($computer in $SRVList) {
Get-Service remoteregistry -ComputerName $computer | start-service
Copy-item -Path "E:\Software\python-3.6.2.exe" -Destination \\$computer\c$\temp -Recurse
Copy-item -Path "C:\My Files\Work\Episode 003 - MongoDB Back Up\Python_GUI.py" -Destination \\$computer\c$\temp -Recurse
Invoke-Command -ComputerName $computer -FilePath "C:\My Files\Work\Episode 003 - MongoDB Back Up\Python_Pip_Proxy_PyWinAuto.ps1"
}
잘못된 것입니다. 코드를 어떻게 변경해야합니까?
고마워요! 귀하의 솔루션은 효과가있었습니다. 내 길을 왜 실패했다고 생각하니? 내 방식으로 Alteryx라는 다른 소프트웨어를 설치했습니다. –
먼저 -Filepath 매개 변수를 사용하여 실행하려는 원격 컴퓨터가 아닌 로컬 컴퓨터 (스크립트를 실행하는 컴퓨터)에 스크립트 파일을 지정합니다. 원격 컴퓨터에있는 스크립트 파일을 실행하려고하므로 -scriptblock 매개 변수를 사용해야합니다. 또는 로컬 시스템에 스크립트를 넣고 시도해보십시오. 원격 컴퓨터에서 액세스 할 수있는 네트워크 공유에 설치 파일이있는 한 계속 작동해야합니다. –