| description | An ISEFile object represents a file in Windows PowerShell ISE. |
|---|---|
| ms.date | 03/27/2025 |
| title | The ISEFile Object |
An ISEFile object represents a file in Windows PowerShell Integrated Scripting Environment
(ISE). It's an instance of the Microsoft.PowerShell.Host.ISE.ISEFile class. This topic lists its
member methods and member properties. The $psISE.CurrentFile and the files in the Files collection
in a PowerShell tab are all instances of the Microsoft.PowerShell.Host.ISE.ISEFile class.
Supported in Windows PowerShell ISE 2.0 and later.
Saves the file to disk.
[saveEncoding] - optional System.Text.Encoding An optional
character encoding parameter to be used for the saved file. The default value is UTF8.
- System.IO.IOException: The file couldn't be saved.
# Save the file using the default encoding (UTF8)
$psISE.CurrentFile.Save()
# Save the file as ASCII.
$psISE.CurrentFile.Save([System.Text.Encoding]::ASCII)
# Gets the current encoding.
$myfile = $psISE.CurrentFile
$myfile.EncodingSupported in Windows PowerShell ISE 2.0 and later.
Saves the file with the specified file name and encoding.
filename - String The name to be used to save the file.
[saveEncoding] - optional System.Text.Encoding An optional
character encoding parameter to be used for the saved file. The default value is UTF8.
- System.ArgumentNullException: The filename parameter is null.
- System.ArgumentException: The filename parameter is empty.
- System.IO.IOException: The file couldn't be saved.
# Save the file with a full path and name.
$fullpath = "C:\temp\newname.txt"
$psISE.CurrentFile.SaveAs($fullPath)
# Save the file with a full path and name and explicitly as UTF8.
$psISE.CurrentFile.SaveAs($fullPath, [System.Text.Encoding]::UTF8)Supported in Windows PowerShell ISE 2.0 and later.
The read-only property that gets the string that contains the display name of this file. The name is
shown on the File tab at the top of the editor. The presence of an asterisk (*) at the end of
the name indicates that the file has changes that haven't been saved.
# Shows the display name of the file.
$psISE.CurrentFile.DisplayNameSupported in Windows PowerShell ISE 2.0 and later.
The read-only property that gets the editor object that's used for the specified file.
# Gets the editor and the text.
$psISE.CurrentFile.Editor.TextSupported in Windows PowerShell ISE 2.0 and later.
The read-only property that gets the original file encoding. This is a System.Text.Encoding object.
# Shows the encoding for the file.
$psISE.CurrentFile.EncodingSupported in Windows PowerShell ISE 2.0 and later.
The read-only property that gets the string that specifies the full path of the opened file.
# Shows the full path for the file.
$psISE.CurrentFile.FullPathSupported in Windows PowerShell ISE 2.0 and later.
The read-only Boolean property that returns $true if the file has been saved after it was last
modified.
# Determines whether the file has been saved since it was last modified.
$myfile = $psISE.CurrentFile
$myfile.IsSavedSupported in Windows PowerShell ISE 2.0 and later.
The read-only property that returns $true if the file has never been given a title.
# Determines whether the file has never been given a title.
$psISE.CurrentFile.IsUntitled
$psISE.CurrentFile.SaveAs("temp.txt")
$psISE.CurrentFile.IsUntitled