Functions/Invoke-Launch.ps1
function Invoke-Launch { [CmdletBinding()] param ( [Parameter(Mandatory = $true)] [ArgumentCompleter( { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters ) $gci1 = Get-ChildItem "$($env:ProgramData)\Microsoft\Windows\Start Menu" -Recurse -File -Filter *.lnk $gci2 = Get-ChildItem "$($env:APPDATA)\Microsoft\Windows\Start Menu" -Recurse -File -Filter *.lnk $Links = $gci1 + $gci2 $Links | Where-Object BaseName -Like "$wordToComplete*" | ForEach-Object { "`"$($_.BaseName)`"" } } )] # [ValidateScript( { # $_ -in (Get-ChildItem "$($Path)" -Directory -Name) # } ) ] [string] $Program ) Write-Verbose $Program $ShortCut = Get-ChildItem "$($env:ProgramData)\Microsoft\Windows\Start Menu" -Recurse -File -Filter "$($Program).lnk" if(!($ShortCut)) { $ShortCut = Get-ChildItem "$($env:APPDATA)\Microsoft\Windows\Start Menu" -Recurse -File -Filter "$($Program).lnk" } Write-Verbose $ShortCut.FullName Start-Process $ShortCut.FullName } |