Functions/Display/Show-Headline.ps1
<# .SYNOPSIS Show the current host headline on screen. .DESCRIPTION Show information about the Windows operating system like name and version, the PowerShell host name and version and at the end about the current session with informations about the user, the system and the uptime. .INPUTS None. .OUTPUTS None. .EXAMPLE Show-Headline Show the current host headline on screen. .NOTES Author : Claudio Spizzi License : MIT License .LINK https://github.com/claudiospizzi/Spizzi.Profile #> function Show-Headline { [CmdletBinding()] param ( ) # Get Windows version from registry. Update the object for non Windows 10 # or Windows Server 2016 systems to match the same keys. $WindowsVersion = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' if ($WindowsVersion.ReleaseId -eq $null) { $WindowsVersion | Add-Member -MemberType NoteProperty -Name 'ReleaseId' -Value $WindowsVersion.CurrentVersion } if ($WindowsVersion.UBR -eq $null) { $WindowsVersion | Add-Member -MemberType NoteProperty -Name 'UBR' -Value '0' } # Rename the ConsoleHost string to a nice understandable string $PowerShellHost = $Host.Name.Replace('ConsoleHost', 'Windows PowerShell Console Host') # Use string formatting to bring all informations together to nice strings $SystemInfo = '{0}, Version {1} (Build {2}.{3})' -f $WindowsVersion.ProductName, $WindowsVersion.ReleaseId, $WindowsVersion.CurrentBuildNumber, $WindowsVersion.UBR $PowerShellInfo = '{0}, Version {1}.{2} (Build {3}.{4})' -f $PowerShellHost, $PSVersionTable.PSVersion.Major, $PSVersionTable.PSVersion.Minor, $PSVersionTable.PSVersion.Build, $PSVersionTable.PSVersion.Revision $LogonInfo = '{0}\{1} on {2}, Uptime {3:%d} day(s) {3:hh\:mm\:ss}' -f $Env:USERDOMAIN, $Env:USERNAME, $Env:COMPUTERNAME.ToUpper(), [System.TimeSpan]::FromMilliseconds([System.Environment]::TickCount) Write-Host $SystemInfo Write-Host $PowerShellInfo Write-Host "" Write-Host $LogonInfo Write-Host "" } |