Hello,
I am trying to copy a file and execute on numerous servers remotely. the file copies successfully but unfortunately the exe doesn't executes. Can someone please identify where it goes wrong. below is script
#Variables
$computername=Get-Content servers2.txt
$sourcefile="C:\Users\username1\Downloads\app\folder2\app.exe"
$destinationFolder="\\$computer\C$\admin\scripts"
#This section will install the software
foreach ($computerin$computername)
{
#It will copy $sourcefile to the $destinationfolder. If the Folder does not exist it will create it.
if (!(Test-Path-path$destinationFolder))
{
New-Item$destinationFolder-TypeDirectory
}
Copy-Item-Path $sourcefile-Destination $destinationFolder}
Invoke-Command-ComputerName$computer-ScriptBlock {Start-Process"C:\Admin\Scripts\app.exe"}
Thank you,
MYM