PowerShell Script to Copy the contents to remote machine and trigger the installation

 # Define variables

$computers = "Machine1","Machine2","Machine3"

$sourcePath = "C:\temp\Client"  # source path

# Copy the file to each remote computer

foreach ($computer in $computers) {

    Copy-Item -Path $sourcePath -Destination "\\$computer\C$\temp" -Recurse

}

# Install the software on each remote computer

foreach ($computer in $computers) {

    $process = [WMICLASS]"\\$computer\ROOT\CIMV2:Win32_Process"

    $process.Create("C:\Temp\Client\Client_upgrade.bat") # cmd line here with path where it has been copied 

}



No comments:

Post a Comment