Functions/Get-LicenseDetails.ps1
function Get-LicenseDetails { param( [string[]] $RawLicense ) $License = [ordered] @{'AccountNumber' = ''; 'LicensedTo' = ''; 'CreatedDate' = ''; 'ExpireDate' = ''; 'RawLicense' = ''} $License.RawLicense = $RawLicense $Regex = 'VOICE Account Number.*?:\s(?<AccountNumber>\d*)' $Match = $License.RawLicense | Select-String -Pattern $Regex $License.AccountNumber = $Match.Matches[0].Groups['AccountNumber'].Value $Regex = 'Created Date.*?:\s(?<CreatedDate>\d{1,2}\/\d{1,2}\/\d{2,4})' $Match = $License.RawLicense | Select-String -Pattern $Regex $License.CreatedDate = $Match.Matches[0].Groups['CreatedDate'].Value $License.CreatedDate = [datetime]::parseexact($License.CreatedDate, 'M/d/yyyy', $null) $Regex = 'Expires.*?:\s(?<ExpireDate>\d{1,2}\/\d{1,2}\/\d{2,4})' $Match = $License.RawLicense | Select-String -Pattern $Regex if(-not [string]::IsNullOrEmpty($Match)){ $License.ExpireDate = $Match.Matches[0].Groups['ExpireDate'].Value $License.ExpireDate = [datetime]::parseexact($License.ExpireDate, 'M/d/yyyy', $null) } $Regex = 'Licensed to.*?:\s(?<LicensedTo>.*)[\r\n]+' $Match = $License.RawLicense | Select-String -Pattern $Regex $License.LicensedTo = $Match.Matches[0].Groups['LicensedTo'].Value return $License } Export-ModuleMember -Function Get-LicenseDetails |