How to Save a Script

Use the following steps to save and name a script. An asterisk appears next to the script name to mark a file that has not been saved since it was altered. The asterisk disappears when the file is saved.

Note:

Windows PowerShell file types, namely, script files (.ps1), script data files (.psd1), and script module files (.psm1) are saved as Unicode.  However, some file types such as command scripts (.cmd) must be saved in the ANSI (ASCII) format to run properly.  If you create a command script using Windows PowerShell ISE, in order to save the file, use the SaveAs method on the $psISE.CurrentFile object. 

To save a script

On the toolbar, click Save, or on the File menu, click Save.

To save and name a script

  1. On the File menu, click Save As. The Save As dialog box will appear.

  2. In the File name box, enter a name for the file.

  3. In the Save as type box, select a file type. For example, in the Save as type box, select “PowerShell Scripts (* .ps1)”.

  4. Click Save.

See Also