With PowerShell, you can execute scripts as commands if they are placed in the directories contained in the PATH environment variable. To find out which directories are in the Path, you can use:
$env:Path -split ';'| sort
" Windows", , script. , :
$ScriptRoot = Split-Path $SCRIPT:MyInvocation.MyCommand.Path
if(($env:Path -split ';') -notcontains $ScriptRoot) {
$env:Path += ';' + $ScriptRoot
}
:
PS >$timer = New-Object Timers.Timer
PS >Register-TemporaryEvent $timer Disposed { [Console]::Beep(100,100) }
. , Register-TemporaryEvent.ps1, ".ps1", .