Returning a file from PowerShell ASP

PowerShell ASP works in much the same way that ASP.NET would. Transferring a file to the user is no different. Below is an example showing how to allow the user to download a file:

        <link href="stylesheet.css" rel="stylesheet" type="text/css"></link>
        $filepath = "C:\test\test.txt"
        $file = Get-Item $filepath
        $Response.ContentType = "text/plain"
        $Response.AddHeader("Content-Disposition", "attachment; filename=$($file.Name);")
        $Response.AddHeader("Content-Length", $file.Length)

We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at