title: Using powershell with 7zip - password protect each file in a folder
body: <p>I am trying to password protect 10 files (using the same password) in a folder.  Once completed, i would like to have 10 individual zip files each with the same password.  My script is as follows but it errors out saying it cant open the file as archive.  </p>
  
  <pre><code>$list=gci "C:\temp\test"
  foreach ($file in $list)
  {
     $file1=$file|select -ExpandProperty name
     &amp; 'c:\program files\7-zip\7z.exe' a $file1.zip $file1 -p123
  }
  </code></pre>
  
  <p>This is the error i get:</p>
  
  <pre><code>Open archive: testfile.pdf
  7z.exe : ERROR: testfile.pdf
  At line:6 char:5
  +     &amp; 'c:\program files\7-zip\7z.exe' a $file1.zip $file1 -p123
  +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  + CategoryInfo          : NotSpecified: (ERROR: testfile.pdf:String) [], RemoteException
  + FullyQualifiedErrorId : NativeCommandError
  Can not open the file as archive
  System ERROR:
  Incorrect function.
  </code></pre>
  
  <p>Any help would be greatly appreciated. Thanks</p>