Modules/Greeter/greeter.psm1
<# .SYNOPSIS Displays greeting information. .DESCRIPTION Displays information selected in a configuration file. .EXAMPLE Show-APSGreeting #> function Show-APSGreeting{ [CmdletBinding(HelpUri="https://github.com/akotu235/APS/blob/master/Docs/Modules/Greeter/Show-APSGreeting.md")] param() if(-not ($Config = Get-Config $PSScriptRoot)){ $Config = Set-APSGreeting -Default } if($Config.EnableAPSGreeting){ if($Config.Clear){ Clear-Host } if($Config.APSLogo){ try{ $version = (Import-Clixml "$PSScriptRoot\..\..\PSGetModuleInfo.xml").Version } catch{ $version = (Get-Content "$PSScriptRoot\..\..\APS.psd1" | Select-String "ModuleVersion = ").ToString().Trim().TrimStart("ModuleVersion = ").Trim("'") } Write-Host " _ ___ ___ `n /_\ | _ \ / __|`n / _ \ | _/ \__ \`n /_/ \_\ |_| |___/" -NoNewline if($version){ Write-Host "v.$version" -ForegroundColor DarkGray } } if($Config.Date){ Write-Host "Hi! It is $(Get-Date -Format g)" } if($Config.Weather){ Write-Host $(Get-Weather) } if($Config.UserName){ Write-Host "You are working as " -NoNewline if(Test-Admin){ Write-Host "$env:UserName" -ForegroundColor Red } else{ Write-Host "$env:UserName" } } Write-Host "" } } <# .SYNOPSIS Saves in the configuration file which information is to be displayed using the ``Show-APSGreeting`` function. .DESCRIPTION The ``Set-APSGreeting`` cmdlet running without parameters will help the user select the items to display. .PARAMETER Default Restores the default settings. .PARAMETER Disable Disables ``Show-APSGreeting`` functions. .EXAMPLE Set-APSGreeting #> function Set-APSGreeting{ [CmdletBinding(SupportsShouldProcess, DefaultParameterSetName="NoParameter", HelpUri="https://github.com/akotu235/APS/blob/master/Docs/Modules/Greeter/Set-APSGreeting.md")] param( [Parameter(ParameterSetName='Default')] [switch]$Default, [Parameter(ParameterSetName='Disable')] [switch]$Disable ) if($Default){ $Config = New-Object PSObject -Property @{ EnableAPSGreeting = $true Clear = $true APSLogo = $true Date = $true UserName = $true Weather = $true } return (Save-Config $PSScriptRoot $Config) } elseif($Disable){ Set-ConfigField $PSScriptRoot "EnableAPSGreeting" $false } else{ $clear = Read-Host "Do you want to clear the screen?(yes)" $logo = Read-Host "Do you want to see the APS logo?(yes)" $date = Read-Host "Do you want to see the date and time?(yes)" $username = Read-Host "Do you want to see the username?(yes)" $weather = Read-Host "Do you want to see the weather?(yes)" $Config = New-Object PSObject -Property @{ EnableAPSGreeting = $true Clear = $($clear.ToLower() -notlike "n*") APSLogo = $($logo.ToLower() -notlike "n*") Date = $($date.ToLower() -notlike "n*") UserName = $($username.ToLower() -notlike "n*") Weather = $($weather.ToLower() -notlike "n*") } Save-Config $PSScriptRoot $Config } } # SIG # Begin signature block # MIIIWAYJKoZIhvcNAQcCoIIISTCCCEUCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUlsfYKQLURH2b2MN7BjkOi3Xz # srigggT6MIIE9jCCAt6gAwIBAgIQYYPyfUBBC6pE/rAfOslXOzANBgkqhkiG9w0B # AQsFADATMREwDwYDVQQDDAhha290dSBDQTAeFw0yMjA5MjAxOTQ4MDFaFw0zMjA5 # MjAxOTU4MDFaMBMxETAPBgNVBAMMCGFrb3R1IENBMIICIjANBgkqhkiG9w0BAQEF # AAOCAg8AMIICCgKCAgEAvGcae/FCZugTbghxO7Qv9wQKvRvp9/WvJyJci/SIsPr1 # /Mf5wfBTJ3aCvyjFvHfcsDH4NdHZubHO531tc1NHCDh+Ztkr5hbOdl3x46nEXm6u # e4Fiw23SB02dU3dAnFvNSGEE5jhQDOApGX/u7xEW4ZXrvMC5yLCBa3Kva1abPx5b # owvQlHhiSsn039/K2xSNhR+x4QcgEIo9JYdcob0f7ZY3AhXT+f1PNyYe075SY+t2 # y1YMlPlq4THolVUB4yB5MknAOG7IoxFt0U9vXhMSjbb06LZ/I/2RpAJd/qcaC/aX # CBvKYQbbmEq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