cmdlets/Update-PSBookmark.ps1
<# .Synopsis Update folder location in the bookmarks list .Description Update folder location in the bookmarks list .Parameter Name The bookmark name. .Parameter Path The Path to folder. .Example # Update bookmark with name. ./Update-PSBookmark [ bu ] BookmarkName (Opt)Directory .Example # Update bookmark from pipeline. $pwd | Update-PSBookmark -Name "ThisDirectory" #> function Update-PSBookmark () { Param ( [Parameter(Position = 0, Mandatory = $true)] [Alias("Bookmark")] $Name, [Parameter(Position = 1, ValueFromPipeline = $True)] [Alias("Path")] [string]$dir = $null ) if ( [string]::IsNullOrWhitespace($dir) ) { $dir = (Get-Location).Path } $_marks = Import-PSBookmarks if( -not $_marks.ContainsKey("$Name") ){ throw "Folder bookmark ''$Name'' doesn't exist" } $_marks["$Name"] = $dir Save-PSBookmarks $_marks Write-Output ("The bookmark {0} updated with location '{1}'" -f $Name, $dir) } |