<# .SYNOPSIS Enable tab completion to invoke for functions if you do not know function name .VERSION 7.1.4 .DATE 24.02.2026 .COPYRIGHT (c) 2014—2026 Team Sophia .DESCRIPTION Dot source the script first: . .\Import-TabCompletion.ps1 (with a dot at the beginning) Start typing any characters contained in the function's name or its arguments, and press the TAB button .EXAMPLE Sophia -Functions Sophia -Functions temp Sophia -Functions "DiagTrackService -Disable", "DiagnosticDataLevel -Minimal", Uninstall-UWPApps .NOTES Use commas to separate funtions .LINK https://github.com/farag2/Sophia-Script-for-Windows #> #Requires -RunAsAdministrator #Requires -Version 7.5 #region Initial Actions $Global:Failed = $false # Checking if function wasn't dot-sourced, but called explicitly # ".\Import-TabCompletion.ps1" instead of ". .\Import-TabCompletion.ps1" if ($MyInvocation.Line -ne ". .\Import-TabCompletion.ps1") { Write-Information -MessageData "" -InformationAction Continue Write-Warning -Message $Localization.DotSourcedWarning Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "https://github.com/farag2/Sophia-Script-for-Windows?tab=readme-ov-file#how-to-run-the-specific-functions" -Verbose Write-Verbose -Message "https://t.me/sophia_chat" -Verbose Write-Verbose -Message "https://discord.gg/sSryhaEv79" -Verbose exit } $Global:Failed = $false # Unload and import private functions and module Get-ChildItem function: | Where-Object {$_.ScriptBlock.File -match "Sophia_Script_for_Windows"} | Remove-Item -Force Remove-Module -Name SophiaScript -Force -ErrorAction Ignore Import-Module -Name $PSScriptRoot\Manifest\SophiaScript.psd1 -PassThru -Force Get-ChildItem -Path $PSScriptRoot\Module\private | Foreach-Object -Process {. $_.FullName} # Dot-source script with checks InitialActions # Global variable if checks failed if ($Global:Failed) { exit } #endregion Initial Actions function Sophia { [CmdletBinding()] param ( [Parameter(Mandatory = $false)] [string[]] $Functions ) foreach ($Function in $Functions) { Invoke-Expression -Command $Function } # The "PostActions" and "Errors" functions will be executed at the end Invoke-Command -ScriptBlock {PostActions} } $Parameters = @{ CommandName = "Sophia" ParameterName = "Functions" ScriptBlock = { param ( $commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters ) # Get functions list with arguments to complete $Commands = (Get-Module -Name SophiaScript).ExportedCommands.Keys foreach ($Command in $Commands) { $ParameterSets = (Get-Command -Name $Command).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames} # If a module command is OneDrive if ($Command -eq "OneDrive") { (Get-Command -Name $Command).Name | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} # Get all command arguments, excluding defaults foreach ($ParameterSet in $ParameterSets.Name) { # If an argument is AllUsers if ($ParameterSet -eq "AllUsers") { # The "OneDrive -Install -AllUsers" construction "OneDrive" + " " + "-Install" + " " + "-" + $ParameterSet | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} } continue } } # If a module command is UnpinTaskbarShortcuts if ($Command -eq "UnpinTaskbarShortcuts") { # Get all command arguments, excluding defaults foreach ($ParameterSet in $ParameterSets.Name) { # If an argument is Shortcuts if ($ParameterSet -eq "Shortcuts") { $ValidValues = ((Get-Command -Name UnpinTaskbarShortcuts).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues foreach ($ValidValue in $ValidValues) { # The "UnpinTaskbarShortcuts -Shortcuts " construction "UnpinTaskbarShortcuts" + " " + "-" + $ParameterSet + " " + $ValidValue | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} } # The "UnpinTaskbarShortcuts -Shortcuts " construction "UnpinTaskbarShortcuts" + " " + "-" + $ParameterSet + " " + ($ValidValues -join ", ") | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} } continue } } # If a module command is Uninstall-UWPApps if ($Command -eq "Uninstall-UWPApps") { (Get-Command -Name $Command).Name | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} # Get all command arguments, excluding defaults foreach ($ParameterSet in $ParameterSets.Name) { # If an argument is ForAllUsers if ($ParameterSet -eq "ForAllUsers") { # The "Uninstall-UWPApps -ForAllUsers" construction "Uninstall-UWPApps" + " " + "-" + $ParameterSet | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} } continue } } # If a module command is Install-DotNetRuntimes if ($Command -eq "Install-DotNetRuntimes") { # Get all command arguments, excluding defaults foreach ($ParameterSet in $ParameterSets.Name) { # If an argument is Runtimes if ($ParameterSet -eq "Runtimes") { $ValidValues = ((Get-Command -Name Install-DotNetRuntimes).Parametersets.Parameters | Where-Object -FilterScript {$null -eq $_.Attributes.AliasNames}).Attributes.ValidValues foreach ($ValidValue in $ValidValues) { # The "Install-DotNetRuntimes -Runtimes " construction "Install-DotNetRuntimes" + " " + "-" + $ParameterSet + " " + $ValidValue | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} } # The "Install-DotNetRuntimes -Runtimes " construction "Install-DotNetRuntimes" + " " + "-" + $ParameterSet + " " + ($ValidValues -join ", ") | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} } continue } } # If a module command is Set-Policy if ($Command -eq "Set-Policy") { continue } foreach ($ParameterSet in $ParameterSets.Name) { # The "Function -Argument" construction $Command + " " + "-" + $ParameterSet | Where-Object -FilterScript {$_ -like "*$wordToComplete*"} | ForEach-Object -Process {"`"$_`""} continue } # Get functions list without arguments to complete Get-Command -Name $Command | Where-Object -FilterScript {$null -eq $_.Parametersets.Parameters} | Where-Object -FilterScript {$_.Name -like "*$wordToComplete*"} continue } } } Register-ArgumentCompleter @Parameters Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Sophia -Functions " -Verbose Write-Verbose -Message "Sophia -Functions temp" -Verbose Write-Verbose -Message "Sophia -Functions 'DiagTrackService -Disable', 'DiagnosticDataLevel -Minimal', Uninstall-UWPApps" -Verbose Write-Information -MessageData "" -InformationAction Continue Write-Verbose -Message "Sophia -Functions 'Uninstall-UWPApps, 'PinToStart -UnpinAll'" -Verbose Write-Verbose -Message "Sophia -Functions `"Set-Association -ProgramPath '%ProgramFiles%\Notepad++\notepad++.exe' -Extension .txt -Icon '%ProgramFiles%\Notepad++\notepad++.exe,0'`"" -Verbose