#
# bat
# PowerShell
#
function Get-BatchFile( $batFile ) {
$command = "`"$batFile`" & set"
cmd /c $command | Foreach-Object {
$name, $value = $_.split('=')
Set-Item -path env:$name -value $value
}
}
#
# PowerShell Visual Studio 2008 Command Prompt
#
function SetupVisualStudio2008Prompt( ) {
#
$batFile = [System.IO.Path]::Combine( $env:VS90COMNTOOLS, "vsvars32.bat" )
Get-BatchFile $batFile
$title = "Visual Studio 2008 Windows PowerShell"
#
$wid = [System.Security.Principal.WindowsIdentity]::GetCurrent( )
$principal = new-object System.Security.Principal.WindowsPrincipal($wid)
$isAdmin = $principal.IsInRole( [System.Security.Principal.WindowsBuiltInRole]::Administrator )
if( $isAdmin ) {
$title = $title + " (Administrator)"
}
else {
$title = $title + " (Non-Administrator)"
}
#
[System.Console]::Title = $title
}
#
# PowerShell
#
SetupVisualStudio2008Prompt
cls
Source: https://habr.com/ru/post/72035/