-
Notifications
You must be signed in to change notification settings - Fork 4
/
EyeCandy.ps1
67 lines (53 loc) · 1.46 KB
/
EyeCandy.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# if ($IsAdmin -and ([System.Environment]::OSVersion.Version.Major -gt 5)) {
# $foreColor = 'White'
# $backColor = 'DarkRed'
# }
# else {
$foreColor = 'White'
$backColor = 'Black'
# }
$hostTitle = {
if (-not $IsAdmin) { 'WARNING: (Not Admin)' }
($pwd)
}
$banner = {
$MachineArchitecture = $(if([IntPtr]::Size -eq 8) { "64-bit" } else { "32-bit" })
$PSVersionString = (Get-FileVersionInfo "$PSHome\PowerShell.exe").ProductVersion
"Microsoft Windows PowerShell $PSVersionString ($MachineArchitecture)"
$user = "Logged in on $([DateTime]::Now.ToString((get-culture))) as $($NTIdentity.Name)"
if($IsAdmin) { $user += ' (Elevated!)' }
else { $user += '.' }
$user
}
function Update-HostTitle {
$title = & $hostTitle
$host.UI.RawUI.WindowTitle = "$title"
}
function Start-EyeCandy {
$isTerminal = ($host.Name -eq 'ConsoleHost')
if ($isTerminal) {
if ($foreColor) {
$Host.UI.RawUI.ForegroundColor = $foreColor
}
if ($backColor) {
$Host.UI.RawUI.BackgroundColor = $backColor
if($Host.Name -eq 'ConsoleHost') {
$Host.PrivateData.ErrorBackgroundColor = $backColor
$Host.PrivateData.WarningBackgroundColor = $backColor
$Host.PrivateData.DebugBackgroundColor = $backColor
$Host.PrivateData.VerboseBackgroundColor = $backColor
}
}
}
if ($Error.Count -eq 0) {
Clear-Host
}
if ($isTerminal) {
& $Banner | Write-Host -ForegroundColor $foreColor
}
else {
& $Banner | Write-Host
}
Update-HostTitle
}
Start-EyeCandy