PowerShell_Scripts/Edit-MyProfiles.ps1

24 lines
655 B
PowerShell

[CmdletBinding(SupportsShouldProcess)]param(
[switch]$sudo,
[switch]$Force,
[Parameter(ValueFromRemainingArguments = $true)]
[ArgumentCompleter({ param (
$commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameters
)
[MyScript]::_GetValidValues($wordToComplete,$false)
})]
[string[]]$AlsoEditTheseScripts
)
$local:FilePaths = @() + $( Get-Profiles | Where-Object { $_.Exists -or $Force } | Select-Object -ExpandProperty Path )
foreach( $local:p in $AlsoEditTheseScripts ) {
$local:sp = Join-Path $MyPSScriptRoot "$p`.ps1"
$FilePaths += $sp
}
Edit-TextFile -sudo:$sudo $FilePaths