Werbung

Herkunft

Kurzinformation

Saves a file within the Integrated Scripting Enviroment with an automatically generated name

Syntax

<# .Synopsis Saves a file within the Integrated Scripting Enviroment with an automatically generated name .Description Saves a file within the Integrated Scripting Enviroment with an automatically generated name. The Name of the file will be the first function found .ps1 .Example Get-FunctionFromFile $psise.CurrentFile #> param( # The File in the Windows PowerShell Integrated Scripting Environment # (i.e. $psise.CurrentFile) [Parameter(ValueFromPipeline=$true)] [Microsoft.PowerShell.Host.ISE.ISEFile] $File ) process { $tokens = Get-TokenFromFile -file $file if (-not $tokens) { return } for ($i = 0; $i -lt $tokens.Count; $i++) { if ($tokens[$i].Content -eq "function" -and $tokens[$i].Type -eq "Keyword") { $functionName = $tokens[$i + 1].Content break } } if ($functionName) { $fileName = Join-Path $pwd "$functionName.ps1" $file.SaveAs($fileName) } else { $file.Save() } }

Beschreibung

Saves a file within the Integrated Scripting Enviroment with an automatically generated name.The Name of the file will be the first function found .ps1

Links

Liste aller Commandlets Mehr über die Windows PowerShell

Bücher zur PowerShell

Buchcover Windows PowerShell 5.0 - Das Praxishandbuch (1. Auflage 2016/5. Auflage Gesamtreihe) Windows PowerShell 5.0 - Das Praxishandbuch (1. Auflage 2016/5. Auflage Gesamtreihe)
Autoren: Dr. Holger Schwichtenberg
erschienen 2016, 996 Seiten, 49,99 €
ISBN: 3446446435
Bestellung: Amazon.de oder im Buchhandel über ISBN 3446446435

Schulungen/Seminare

Offene Seminare zur PowerShell
In-House-Seminare zur PowerShell