1
0
Files
Repository/Tools/PS2EXE-GUI/Examples/Basisdemo.ps1
2025-10-31 08:58:36 +01:00

69 lines
3.4 KiB
PowerShell
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Write-Host "Console demo for PS2EXE" -f Yellow
Write-Host
$intptrSize = [System.IntPtr]::Size
if ($intptrSize -eq 4)
{
Write-Host "This is a 32 bit environment" -ForegroundColor DarkYellow
} else {
Write-Host "This is a 64 bit environment" -ForegroundColor Green
}
Write-Host
if ($PSVersionTable.PSVersion.Major -eq 5)
{
Write-Host "This is PowerShell 5.x" -fore Yellow
}
elseif ($PSVersionTable.PSVersion.Major -eq 4)
{
Write-Host "This is PowerShell 4.0" -fore Cyan
}
elseif ($PSVersionTable.PSVersion.Major -eq 3)
{
Write-Host "This is PowerShell 3.0" -fore Red
}
else
{
if ($PSVersionTable.PSVersion.Major -eq 2)
{
Write-Host "This is PowerShell 2.0" -fore DarkCyan
}
else
{
Write-Host "This is a unknown PowerShell version." -fore Blue
}
}
Write-Host
Write-Host "Thread Appartment State is $([System.Threading.Thread]::CurrentThread.GetApartmentState())"
Write-Host
# keep following windows in foreground with -noConsole:
$Host.UI.RawUI.FlushInputBuffer()
$credential = Get-Credential -Credential "$ENV:USERNAME"
#$credential = $host.ui.PromptForCredential("Authentication required", "Please type user and passwort.", "$ENV:USERNAME", "$ENV:COMPUTERNAME")
$Host.UI.RawUI.FlushInputBuffer()
if ($credential)
{
Write-Host "`n`nYour authentication data:" -Fore Magenta
$credential
Write-Host
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($credential.Password)
$PlainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
"Your password: " + $PlainPassword
Write-Host
}
else
{
Write-Output "Input aborted"
}
$Value = Read-Host "Type in a string"
"Your input was: $Value"
$NULL = Read-Host "Press enter to exit"