I am trying to install McAfee Virus Scan with Powershell.
I am using the following Script.
$file = '\\fileserver\share\SetupVSE.exe'
$computerName = 'server01'
Copy-Item -Path $file -Destination "\\$computername\c$\windows\temp\SetupVSE.exe"
Invoke-Command -ComputerName $computerName -ScriptBlock {
c:\windows\temp\SetupVSE.exe /silent
}
The problem is that Mcafee SetupVSE.exe calls on other files in the folder to do the install.
So it will run but not install and does not give any errors.
Is there a way I can copy the whole folder and not just the file?
Or better yet I way to simply install it right from the network share without having to copying any files?
Thank you
I’m not sure if you can install that right from the network share. I would think it would depend on the software itself. As for how to copy the entire (share) folder that the .exe sits in, just add the -Recurse parameter to the Copy-Item cmdlet. The entire folder, and everything underneath it, will be copied.
If you don’t want to copy the “share” folder itself into the “temp” folder, but rather you just want the contents of what’s in the “share” folder to be copied into the “temp” folder, then replace:
$file = ‘\fileserver\share\SetupVSE.exe’
with
$file = “\fileserver\share*”
If there are folders under the “share” folder whose contents all need to be copied as well, then, as mentioned earlier, you’ll need to add the -Recurse parameter to the Copy-Item command.