Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

install .exe\.bat file on remote servers using powershell

$
0
0

Hello,

I am having an application which i need to install on multiple servers. in the list of server i have windows x86 and x64

for windows x86 it should install from c:\temp\abce_x86.bat /s

for windows x64 it should install from c:\Temp\abcd_x64.bat /s

i will be providing list of serers to the script through serverlist.txt

out put should be save to .csv file (servername, architecture and IPAddress)

Note: it should use local credentials or domain credentials to connect to server

foreach($i in (gc ".\serverlist.txt"))
{
$path = '\\' + $i + '\c$\abcd\execut.bat'
if(Test-Path $path){
  new-remoteprocess -computername '$i' -wait -cmd"c:\abcd\execut.bat/s"
}
else
{
Copy-Item "\\servername\e$\software\abcd\execute.bat""\\$i\c$\abcd\execut.bat"
new-remoteprocess -computername '$i' -wait -cmd"c:\abcd\execut.bat /s"
}
}
foreach ($i in (gc in ".\serverlist.txt"))
How to use same for x64 and x86


Thanks, jeevan


Viewing all articles
Browse latest Browse all 15028

Trending Articles