Powershell -comobject wscript.shell新行语法

时间:2016-02-03 21:17:35

标签: powershell variables popup comobject

我正在编写一个脚本,设置一些变量并弹出一个窗口,用一个确认按钮显示这些变量。我能够到窗口显示文本后跟一个变量,但无法找出语法转到通知窗口中的下一行。

`$user = Read-Host "Enter User Name"
$password = Read-Host "Enter Password"
$domain = Read-Host "Enter Domain. Local name is $env:COMPUTERNAME"
$a = new-object -comobject wscript.shell 
$a.popup("User Name:$user" & "Password:$password")`

我尝试过不同的`n组合,但我无法弄明白。

提前致谢

1 个答案:

答案 0 :(得分:1)

  

我尝试过不同的`n组合,但我无法弄明白。

您是否在双引号字符串中间尝试了`n - 而没有其他任何内容? : - )

$WShell = New-Object -ComObject WScript.Shell
$WShell.Popup("I wonder whether this`nlinebreak thing works")

linebreaks...