PowerShell 别名是使用参数快捷名称而不是编写参数全名的好方法。例如,您可以将 Server 称为 ServerName,将 AppID 称为 ApplicationID。这样您不必使用参数的全名,而且也更容易记住。例如:function Aliastest{ param( [parameter(Mandatory=$true)] [Alias("Server")] [string]$ServerName ) Write-Output "Server name is $ServerName" }现在,在传递参数时,我们可以使用 Server 代替 ServerName。PS C:\> Aliastest -server "Test1-Win2k16" Server name is Test1-Win2k16
PowerShell 中单引号(‘)和双引号(“)之间没有区别。它类似于 Python 等编程语言。我们通常使用这两种引号来打印语句。例如:PS C:\> Write-Output 'This will be printed using Single quote' This will be printed using Single quote PS C:\> Write-Output "This will be printed using double quote" This will be printed using double quote但是当我们评估任何表达式或打印变量时,它会产生明显的区别。$date = Get-Date Write-Output 'Today date is : $date' Today date is : $date Write-Output "Today date is : $date" Today date ... 阅读更多