yan*_*taq 10 powershell powershell-3.0
这里串
有一些关于Powershell'here-string'的例子,但我很难遇到'here-string'扩展.所以我发布这个有一些帮助.
当你想添加一些带换行符的文字时,单引号和双引号都不需要转义,也不需要换行符"`r`n".'here-strings'在PowerShell中得到了拯救.他们应该从一开始
@"
和换行符应以换行结束
"@
For example: |Result:
|
@" |
Hello world! 09/25/2014 11:39:56 | Hello world! 09/25/2014 11:39:56
'(this will appear as is)' | '(this will appear as is)'
! | !
"@ |
Run Code Online (Sandbox Code Playgroud)
yan*_*taq 13
以下是如何引入CmdLet和日期变量来显示当前日期:
例如,以下是我们想要实现的目标:
Hello world! 09/25/2014 11:39:56
'(this will appear as is)'
!
Run Code Online (Sandbox Code Playgroud)
方法如下:
@"
Hello world! $(Get-Date)
'(this will appear as is)'
!
"@
Run Code Online (Sandbox Code Playgroud)
或者使用变量:
$myDate = Get-Date
@"
Hello world! ${myDate}
'(this will appear as is)'
!
"@
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16229 次 |
| 最近记录: |