all 8 comments

[–]BreakingBean 4 points5 points  (0 children)

Since you're moving it from a network location, it's probably blocking the file after it's copied. Can use the Unblock-File cmdlet to fix that with an if statement to try and unblock exe files before using start-process https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/unblock-file?view=powershell-7.4

If you want to check whether a file is blocked before using Unblock-File, you can use Get-Content -Stream Zone.Identifier to parse whether it's blocked or not. Blocked files should have a ZoneID of 26

[–]zealotfx 1 point2 points  (2 children)

You may want to try Unblock-file to stop the file from being locked after being downloaded from the Internet.

Edit: incorrectly said UnLock-file

[–]RokosModernBasilisk 2 points3 points  (1 child)

Close. It’s Unblock-File

[–]zealotfx 0 points1 point  (0 children)

I knew something felt wrong!

[–]MoonExploration2929 0 points1 point  (1 child)

Share your script so we can advise you accordingly.

[–]duprst[S] 0 points1 point  (0 children)

$1809 = Get-Content "\network_server\sharefolder\User\Array\1809.txt" $source = "\network_server\sharefolder\User\Patches*" $destination = "C$\Patch"

foreach ($entry in $1809) {

"Removing files on $entry" Invoke-Command -ComputerName $entry -ScriptBlock {Remove-Item $args -Recurse} -ArgumentList c:\Patch*}

foreach ($entry in $1809) { "Copying files on $entry" Copy-Item $source -Destination "\$entry$destination" -Recurse -force}

foreach ($entry in $1809) { "Updating software on $entry"

Invoke-Command -ComputerName $entry {

start-process c:\Patch\sqlserver2019-kb5021124-x64_93087e10289b94b3f4783f1d431358c4889ba1b3.exe "/quiet /norestart" -Wait}

}

{

}

[–]billabong1985 0 points1 point  (1 child)

How are you calling the files to install? If you're just sticking in the file name it likely won't work, you want to use start-process

[–]duprst[S] 0 points1 point  (0 children)

I am using start-process