次の方法で共有


ISEFileCollection オブジェクト

ISEFileCollection オブジェクトは、ISEFile オブジェクトのコレクションです。 たとえば、$psISE.CurrentPowerShellTab.Files コレクションです。

メソッド

Add( [FullPath] )

Windows PowerShell ISE 2.0 以降でサポートされています。

新しい無題のファイルを作成して返し、コレクションに追加します。 新しく作成されたファイルの IsUntitled プロパティが $true

[FullPath] - 省略可能な文字列 ファイルの完全に指定されたパス。 FullPath パラメーターと相対パスを含める場合、または完全パスの代わりにファイル名を使用すると、例外が生成されます。

# Adds a new untitled file to the collection of files in the current PowerShell tab.
$newFile = $psISE.CurrentPowerShellTab.Files.Add()

# Adds a file specified by its full path to the collection of files in the current PowerShell tab.
$psISE.CurrentPowerShellTab.Files.Add("$pshome\Examples\profile.ps1")

Remove( File, [Force] )

Windows PowerShell ISE 2.0 以降でサポートされています。

現在の PowerShell タブから指定したファイルを削除します。

ファイル - 文字列 コレクションから削除する ISEFile ファイル。 ファイルが保存されていない場合、このメソッドは例外をスローします。 Force スイッチ パラメーターを使用して、保存されていないファイルを強制的に削除します。

[Force] - 省略可能なブール値 $trueに設定すると、前回の使用後にファイルが保存されていない場合でも、ファイルを削除する権限が付与されます。 既定値は $falseです。

# Removes the first opened file from the file collection associated with the current PowerShell tab.
# If the file has not yet been saved, then an exception is generated.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.Remove($firstfile)

# Removes the first opened file from the file collection associated with the current PowerShell tab, even if it has not been saved.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.Remove($firstfile, $true)

SetSelectedFile( selectedFile )

Windows PowerShell ISE 2.0 以降でサポートされています。

SelectedFile パラメーターで指定されたファイルを選択します。

SelectedFile - Microsoft.PowerShell.Host.ISE.ISEFile 選択する ISEFile ファイル。

# Selects the specified file.
$firstfile = $psISE.CurrentPowerShellTab.Files[0]
$psISE.CurrentPowerShellTab.Files.SetSelectedFile($firstfile)

関連項目

  • ISEFile オブジェクト する
  • Windows PowerShell ISE スクリプト オブジェクト モデル の目的
  • ISE オブジェクト モデル階層 する