techthoughts2
1/14/2018 - 4:02 PM

PowerShell Profile Greeting

Adds a greeting to the CurrentUserAllHosts PowerShell profile that will greet you every time you open a PowerShell instance.

# create profile if it does not yet exist
$exists = Test-Path -Path $Profile.CurrentUserAllHosts
if (!$exists){
    New-Item -Path $Profile.CurrentUserAllHosts -ItemType File -Force | Out-Null    
}
# add code to profile
$greetings = 
'Hello there!',
'Glad to see you!',
'Welcome Back!',
'Happy coding!',
'Have a great day!',
'Be one with the Snover',
'May the PowerShell be with you!'

Write-Host -ForegroundColor Cyan ($greetings | Get-Random)