Search code examples
powershellvariablespopupcomobject

Powershell -comobject wscript.shell New Line Syntax


I am writing a script that sets a few variables and pops up a window that displays those variables with a confirmation button. I am able to get to window to display text followed by one variable but cant figure out the syntax to go to the next line in the notification window.

`$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")`

I have tried different combinations of `n and am not able to figure it out.

Thanks in advance


Solution

  • I have tried different combinations of `n and am not able to figure it out.

    Have you tried just `n - and nothing else - in the middle of a double-quoted string? :-)

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

    linebreaks...