Note that there are some explanatory texts on larger screens.

plurals
  1. POPowershell script gci accesses weird folders
    primarykey
    data
    text
    <p>I have the following script which usually runs OK, it simply looks for any unzipped file, zip it, and then deletes it.</p> <pre><code>[string]$pathToZipExe = "C:\Program Files\7-zip\7z.exe"; $items= gci -exclude *.zip E:\backup\MYFOLDER | where {!$_.PsIsContainer} # loop through the files foreach ($file in $items) { # run only if there is any file in the directory if ($items.count) { [Array]$arguments = "a", "$file.zip", $file; # zip the file &amp;$pathToZipExe $arguments; # delete the file ONLY if the compression succeeds if($?){ Remove-Item -Force $file; } else { # later this should be changed to send an email write-host "Error: The file could NOT be deleted." }; }; }; </code></pre> <p>Usually it runs OK and returns output like the following:</p> <pre><code>.. .. 7-Zip [64] 4.65 Copyright (c) 1999-2009 Igor Pavlov 2009-02-03 Scanning Creating archive E:\backup\MYFOLDER\ARC_T813021320_S536_P1_C1.zip Compressing ARC_T813021320_S536_P1_C1 Everything is Ok 7-Zip [64] 4.65 Copyright (c) 1999-2009 Igor Pavlov 2009-02-03 Scanning Creating archive E:\backup\MYFOLDER\ARC_T813021387_S537_P1_C1.zip Compressing ARC_T813021387_S537_P1_C1 Everything is Ok .. .. </code></pre> <p>but recently it started to behave in weird way and reports error output like the following:</p> <pre><code>.. .. 7-Zip [64] 4.65 Copyright (c) 1999-2009 Igor Pavlov 2009-02-03 Scanning LogFiles\WMI\RtBackup\: WARNING: Access is denied. Updating archive .zip.zip Compressing .zip.zip Compressing 0401\rusb3co.dll.mui Compressing 0404\rusb3co.dll.mui Compressing 0405\rusb3co.dll.mui Compressing 0406\rusb3co.dll.mui Compressing 0407\rusb3co.dll.mui Compressing 0408\rusb3co.dll.mui Compressing 0409\iisext.ini Compressing 0409\IIsScHlp.ini Compressing 0409\rusb3co.dll.mui Compressing 040A\rusb3co.dll.mui Compressing 040B\rusb3co.dll.mui .. &lt;massive files&gt; ---------------- WARNING: Cannot open 157 files Error: The file could NOT be deleted. .. .. </code></pre> <p>Where wrong did I go in my code. Cheers!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload