ps/Modules/Alkami.DevOps.Common/Public/Get-SecurityGroupPrefix.ps1

28 lines
954 B
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
function Get-SecurityGroupPrefix {
<#
.SYNOPSIS
Easily return human-readable name for the Security Group in which a host belongs.
.DESCRIPTION
Query the host's Machine.config to determine the Security Group for a host and return in a format people can use.
.PARAMETER ComputerName
Optional Parameter. If specified, gets the Security Group for that server's pod, lane, designation, etc. Defaults to local computer.
.EXAMPLE
Get-SecurityGroup -ComputerName APP169671
#>
[CmdletBinding()]
param (
[Parameter(Mandatory = $false)]
[ValidateNotNullOrEmpty()]
[string]$ComputerName="$env:computerName"
)
# get the FQDN no matter what for simplicity
$ComputerName=[System.Net.Dns]::GetHostByName($ComputerName).HostName
$securityGroup=Get-AppSetting -Key Environment.UserPrefix -ComputerName $ComputerName
return $securityGroup
}