-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOptimize-PSFavorite.ps1
More file actions
27 lines (24 loc) · 1.03 KB
/
Optimize-PSFavorite.ps1
File metadata and controls
27 lines (24 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<#
.SYNOPSIS
Optimize the favorites list
.DESCRIPTION
Optimize the favorites list. This will sort the list and remove duplicates.
The favorites list is stored in the `AppData\Local\PSFavorite\Favorites.txt` file in the PSFavorite module directory.
.EXAMPLE
Optimize-PSFavorite
Sorts and removes duplicates from the favorites list.
#>
function Optimize-PSFavorite {
[CmdletBinding(SupportsShouldProcess)]
param (
# The path to the favorites list file.
[Alias("Path", "Name", "FullName", "FullPath", "Config", "ConfigPath", "ConfigFile", "FavoritesFile")]
[ValidateScript({ Test-Path -Path $_ -PathType Leaf })]
[string] $FavoritesPath = $Script:FavoritesPath
)
$Favorites = Get-Content -Path $FavoritesPath | Sort-Object -Unique
if ($PSCmdlet.ShouldProcess("Optimizing favorites list at path '$FavoritesPath' by sorting and removing duplicates")) {
$Favorites | Out-File -FilePath $FavoritesPath -Encoding UTF8 -Force
}
[PSFavorite.PSFavoritePredictor]::Reload()
}