38 lines
1.3 KiB
PowerShell
38 lines
1.3 KiB
PowerShell
function Get-Designations {
|
|
<#
|
|
.SYNOPSIS
|
|
Get the list of designations for a given ProfileName
|
|
|
|
.PARAMETER ProfileName
|
|
A valid ProfileName
|
|
#>
|
|
[CmdletBinding()]
|
|
[OutputType([string[]])]
|
|
param (
|
|
[Parameter(Mandatory = $false)]
|
|
[string]$ProfileName = (Get-LocalCachedAWSProfile)
|
|
)
|
|
|
|
$logLead = (Get-LogLeadName)
|
|
|
|
Assert-ValidAWSProfileName -ProfileName $ProfileName
|
|
|
|
$cachePath = Get-CachePathDesignations -ProfileName $ProfileName
|
|
|
|
if (!(Test-Path -Path $cachePath)) {
|
|
Write-Warning "$logLead : No file found at [$cachePath]. You probably should call Checkpoint-EC2Instances -ProfileName $ProfileName"
|
|
return @()
|
|
}
|
|
|
|
$item = Get-Item -Path $cachePath
|
|
if (Test-WasFileModifiedWithin -Path $cachePath -Last Week) {
|
|
if (Test-IsCurrentAWSUserSessionValid -ProfileName $ProfileName) {
|
|
Write-Information "$logLead : Instance information is more than 7 days out of date, and you have a valid session token. Updating EC2 instance information."
|
|
Checkpoint-EC2Instances -ProfileName $ProfileName
|
|
} else {
|
|
Write-Warning "$logLead : Your $ProfileName designations file is more than 7 days out of date. Do you need to run [Checkpoint-EC2Instances -ProfileName $ProfileName] again?"
|
|
}
|
|
}
|
|
|
|
return (Get-Content $cachePath)
|
|
} |