Functions/Set-Mylocation.ps1


function Set-Mylocation {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory)] [ValidateSet("Git", "OneDrive", "WindowsPowershell", "WindowsPowershellProgramFiles", "Downloads", "MyDocuments")] [string] $Folder,
        [Parameter()] [switch] $OpenInExplorer
    )


    switch ($Folder) {
        "Git" {
            $Path = "$([Environment]::GetFolderPath("UserProfile"))\Git"
        }
        "OneDrive" {
            $Path = $env:OneDrive
        }
        "WindowsPowershell" {
            $Path = "$([Environment]::GetFolderPath("MyDocuments"))\WindowsPowerShell"
        }
        "WindowsPowershellProgramFiles" {
            $Path = "$([Environment]::GetFolderPath("ProgramFiles"))\WindowsPowerShell"
        }
        "Downloads" {
            $Path = "$([Environment]::GetFolderPath("UserProfile"))\Downloads"
        }
        "MyDocuments" {
            $Path = "$([Environment]::GetFolderPath("MyDocuments"))"
        }
    }


    Set-Location $Path

    if ($OpenInExplorer) {
        explorer.exe $Path
    }

}