Powershell script gci accesses weird folders -


i have following script runs ok, looks unzipped file, zip it, , deletes it.

[string]$pathtozipexe = "c:\program files\7-zip\7z.exe"; $items= gci -exclude *.zip e:\backup\myfolder | {!$_.psiscontainer}   # loop through files foreach ($file in $items) {   # run if there file in directory  if ($items.count) {      [array]$arguments = "a", "$file.zip", $file;       # zip file      &$pathtozipexe $arguments;      # delete file if compression succeeds      if($?){                 remove-item -force $file;      } else {         # later should changed send email                     write-host "error: file not deleted."      };  };  }; 

usually runs ok , returns output following:

.. .. 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 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 ok  .. .. 

but started behave in weird way , reports error output following:

.. .. 7-zip [64] 4.65  copyright (c) 1999-2009 igor pavlov  2009-02-03  scanning  logfiles\wmi\rtbackup\:  warning: access 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  .. <massive files>  ---------------- warning: cannot open 157 files error: file not deleted.  .. .. 

where wrong did go in code. cheers!


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -