function Open-ParentFolder {
<#
.SYNOPSIS
- Opens File Explorer (explorer.exe) in the folder that contains a command.
+ Opens the native GUI file explorer (e.g., File Explorer on Windows) in the folder that contains a command.
.DESCRIPTION
Uses Get-Command to determine the path to an executable, then passes the path to Split-Path to get the
- parent folder. Finally, opens the parent folder by passing the path as an argument to explorer.exe.
+ parent folder. Finally, opens the parent folder by passing the path as an argument to Invoke-Item.
.PARAMETER Command
- The name of the executable to open the File Explorer to.
+ The name of the executable to open the file explorer to.
.EXAMPLE
PS> Open-ParentFolder curl
- Opens File Explorer to C:\Windows\system32\.
+ Opens file explorer to the folder containing the curl binary.
#>
[CmdletBinding()]
}
process {
- explorer.exe ((Get-Command $Command).Source | Split-Path -Parent)
+ Invoke-Item ((Get-Command $Command).Source | Split-Path -Parent)
}
}