Powershell script write to one file simultaneously Out-File -FilePath -InputObject -Append -
i made powershell script writes data 1 text file.
script being executed 3rd party software deploying program. thing waits when computer online , executes job, bad thing when script being executed on 100+ online computers got information 8 computers , 2 empty lines.
most happened because powershell script running simultaneously on 100+ computers , file in use.
no way use "wait script being executed on first computer" in 3rd party software deployment program.
the problem line -
$srvpath = [path text file] $computer = "name of computer" $data = "some data not more ~30 characters" out-file -filepath $srvpath -inputobject "$computer - $data" -append
my current solution make temporary file each computer separately , later launch 2nd script read files write 1 file (sort alphabetically) , delete temporary files.
but stick 1 script possible check if data written file or check if text file in use , wait? nice avoid empty lines well, that's not big issue.
Comments
Post a Comment