Sh别名等效于PowerShell Set-Alias
Sh alias equivalent of PowerShell Set-Alias
Sh 中此 PowerShell 代码的等价物是什么:
Set-Alias -Name PS7 -Value "C:\Program Files\PowerShell\7\pwsh.exe"
PS7 {
$PSVersionTable
1..5 | ForEach-Object -Parallel { Write-Host $_ } -ThrottleLimit 5
}
我尝试了以下方法:
alias ps="C:/Program Files/PowerShell/7/pwsh.exe"
ps {
$PSVersionTable
1..5 | ForEach-Object -Parallel { Write-Host $_ } -ThrottleLimit 5
}
但这似乎行不通。有可能吗?我希望它是内联的,而不是在脚本中。
假设你在 WSL
:
alias ps=\"$(wslpath -u 'D:\Program Files\PowerShell\pwsh.exe')\"
alias ps
alias ps='"/mnt/d/Program Files/PowerShell/7/pwsh.exe"'
ps -nopro -c '& {
$PSVersionTable
1..5 | ForEach-Object -Parallel { Write-Host $_ } -ThrottleLimit 5
}'
Name Value
---- -----
PSVersion 7.0.3
PSEdition Core
GitCommitId 7.0.3
OS Microsoft Windows 10.0.19041
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
1
2
3
4
5
仅供参考,我在下面(运行 来自 cmd
):ver & wsl --list
Microsoft Windows [Version 10.0.19041.508]
Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)
Ubuntu-18.04
Sh 中此 PowerShell 代码的等价物是什么:
Set-Alias -Name PS7 -Value "C:\Program Files\PowerShell\7\pwsh.exe"
PS7 {
$PSVersionTable
1..5 | ForEach-Object -Parallel { Write-Host $_ } -ThrottleLimit 5
}
我尝试了以下方法:
alias ps="C:/Program Files/PowerShell/7/pwsh.exe"
ps {
$PSVersionTable
1..5 | ForEach-Object -Parallel { Write-Host $_ } -ThrottleLimit 5
}
但这似乎行不通。有可能吗?我希望它是内联的,而不是在脚本中。
假设你在 WSL
:
alias ps=\"$(wslpath -u 'D:\Program Files\PowerShell\pwsh.exe')\"
alias ps
alias ps='"/mnt/d/Program Files/PowerShell/7/pwsh.exe"'
ps -nopro -c '& {
$PSVersionTable
1..5 | ForEach-Object -Parallel { Write-Host $_ } -ThrottleLimit 5
}'
Name Value ---- ----- PSVersion 7.0.3 PSEdition Core GitCommitId 7.0.3 OS Microsoft Windows 10.0.19041 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0 1 2 3 4 5
仅供参考,我在下面(运行 来自 cmd
):ver & wsl --list
Microsoft Windows [Version 10.0.19041.508]
Windows Subsystem for Linux Distributions:
Ubuntu-20.04 (Default)
Ubuntu-18.04