title: send mail attachment powershell
body: <p>I'm working on a project(bonus points) for my intro CyberSec class and I have a cmd script to create a file with info in a usb drive i was trying to use powershell to send the email to myself but keep getting this error:</p>
  
  <pre><code>At D:\mail.ps1:6 char:16
  + $att= $USBDRIVE\file.zip
  +                ~~~~~~~~~
  Unexpected token '\file.zip' in expression or statement.
      + CategoryInfo          : ParserError: (:) [], ParseException
      + FullyQualifiedErrorId : UnexpectedToken
  </code></pre>
  
  <p>here is my powershell script in the entirety.</p>
  
  <pre><code>$USBDRIVE= Get-WMIObject Win32_Volume | ? { $_.label -eq 'ARNOLDHMW' } | 
  select -expand driveletter
  
  Compress-Archive -Path $USBDRIVE\file -DestinationPath $USBDRIVE\file.zip
  
  $email = "*"
  
  $pass = "*"
  
  $att= $USBDRIVE\file.zip
  
  $smtpServer = "smtp.gmail.com"
  
  $msg = new-object Net.Mail.MailMessage
  $smtp = new-object Net.Mail.SmtpClient($smtpServer)
  $smtp.EnableSSl = $true
  $msg.From = "$email"
  $msg.To.Add("$email")
  $msg.IsBodyHTML = $true
  $msg.Subject = "Files Captured"
  $msg.Body = "
  &lt;/br&gt;
  Hi there
  "
  $msg.Attachments.Add($att)
  $SMTP.Credentials = New-Object System.Net.NetworkCredential("$email", 
  "$pass");
  $smtp.Send($msg)
  </code></pre>
  
  <p>email and password blanked out for obvious reasons
  i'm at a loss here. thanks for the help in advance!</p>