Hello,
I have the following script to run an application on remote computers, the script runs indefinitely, I see the new folder created on the remote computer and the installation file copied there, I also see the process "wsmprovhost.exe" running on the remote computer, however it just does not end. Can you please take a look at my script. Thanks in advance.
------------------------------------------------------------------------------------------
#Servers path
$ServerName = Get-content -path "C:\list\computers.txt"
$sourcefile = "C:\Software\NDP451-KB2858728-x86-x64-AllOS-ENU.exe"
#This section will install the software
foreach ($Computer in $Servername)
{
$destinationFolder = "\\$Computer\C$\Software\Temp"
#This section will copy the $sourcefile to the $destinationfolder. If the Folder does not exist it will create it.
if (!(Test-Path -path $destinationFolder))
{
New-Item $destinationFolder -Type Directory
}
Copy-Item -Path $sourcefile -Destination $destinationFolder
# Install the app
$setup=Invoke-Command -ComputerName $Computer -ScriptBlock {$temp=Start-Process "C:\Software\temp\NDP451-KB2858728-x86-x64-AllOS-ENU.exe" -ArgumentList "/SILENT" -wait -PassThru;$temp}
if ($setup.exitcode -eq 0) {
$result = "The Installation of DN is Successful"
$date = get-date -format g
}
else
{
$result = "The Installation of DN is Failed"
$date = get-date -format g
}
write-host $result
#Output the install result to the Local D Drive
Out-File -FilePath C:\Software\DN.txt -Append -InputObject ("ComputerName: $computerName Result: $result $Date")
}
---------------------------------------------------------------------------------------------