There is a System.Windows.Messagebox...
https://learn.microsoft.com/en-us/dotnet/api/system.windows.messagebox?view=windowsdesktop-6.0
And a System.Windows.Forms.Messagebox...
https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.messagebox?view=windowsdesktop-6.0
It would appear that ISE loads the first assembly, I would guess for it's own user interface. If your script loads the System.Windows.Forms assembly, then use the Forms.Messagebox.
Add-Type -assembly System.Windows.Forms
[System.Windows.Forms.MessageBox]::Show("Can't resolve $($Name) into FQDN. Check spelling", "Failure", "OK", "Error")
I see what you mean about the different variable data. ISE is being deprecated, so I tried VSCode too. It acts like ISE. I guess it's something to do with running in a debugger.
@Rich Matheisen any ideas on this? What did I miss?
Function DoSomething() {
"Doing something."
"DS - I see your name is {0}" -f $UserCredentials.UserName
$global:UserCredentials = Get-Credential -Message "Enter login and password for globalcredentials."
"DS - Your global name is {0}" -f $Global:UserCredentials.UserName
"DS - I see your name is {0}" -f $UserCredentials.UserName
}
$UserCredentials = Get-Credential -Message "Enter login and password for script level credentials."
"Your name is {0}" -f $UserCredentials.UserName
DoSomething