Joel Martinez Joel Martinez - 4 months ago 28
ASP.NET (C#) Question

Download powershell (.ps1) file via ASP.NET

I've got a

file that I would like to link readers to. Unfortunately, navigating to that URL only results in a 404. If memory serves, this is being "blocked" just like
files, but there's a way to change that configuration in
... but I can't seem to find the correct thing via search.

TL;DR, how can I expose a
powershell script so that it's accessible (though not executable, obviously) via HTTP.


I believe you need to add a MIME type for .ps1. In your IIS Manager, select the server node on the tree, and click "MIME Types". Then click "Add..." on the right panel. For extension, set it to .ps1, and set the MIME type to text/plain.

Now IIS should serve .ps1 files.

You could use a MIME Type of application/octet-stream instead of text/plain. Using the former will cause most browsers to download it rather than try to display it.

You can do this for a specific web application or virtual directory, too. If you are doing this through web.config, it would look something like this:

            <mimeMap fileExtension=".ps1" mimeType="text/plain" /><!-- or application/octet-stream -->