Skip to content

TIPS: Run the script as a command from everywhere

Fred Vatin edited this page Oct 10, 2025 · 2 revisions

Well, it is not really from everywhere but from every default terminal session

In case you want to call the yt-download.ps1 not from the browser using the user script but from a terminal, it is not very user friendly if you have to run it using its full path every time like:

& 'path\to\yt-download.ps1' -url "https://some-url"

Once your script is “installed” and won’t move…

Create an alias

Here is the way to do it.

Open the Windows Terminal and set your powershell 7 profile as default.

image

Open a new powershell 7 tab.

If you have VS Code installed, run

Code $Profile

else run

notepad $Profile

or use any editor you want to edit your pwsh profile with.

Now your pwsh profile should be open in an editor. Add this line and save the file.

Set-Alias -Name 'yt' -Value (Get-Item "$env:OneDrive\Documents\ytdl\yt-download.ps1").FullName -Description 'UserAlias: call "$env:OneDrive\Documents\ytdl\yt-download.ps1"'

Replace $env:OneDrive\Documents\ytdl\yt-download.ps1 with the actual path where you put the yt-download.ps1 script.

Open a new pwsh tab or run . $Profile in the current tab to reload the profile in the current pwsh session.

Use the alias

Now you can use yt alias in any pwsh session instead of & 'path\to\Set random Wallpaper.ps1'

yt -url "https://some-url"

NEXT

Clone this wiki locally