-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a peoplestage function to get lists for #13
- Loading branch information
Showing
1 changed file
with
99 additions
and
0 deletions.
There are no files selected for viewing
99 changes: 99 additions & 0 deletions
99
AptecoPSFramework/plugins/InxmailPro/Public/PeopleStage/get-groups.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
|
||
|
||
function Get-Groups { | ||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory=$false)][Hashtable] $InputHashtable | ||
#[Parameter(Mandatory=$false)][Switch] $DebugMode = $false | ||
) | ||
|
||
begin { | ||
|
||
|
||
#----------------------------------------------- | ||
# LOG | ||
#----------------------------------------------- | ||
|
||
$moduleName = "GETGROUPS" | ||
|
||
# Start the log | ||
Write-Log -message $Script:logDivider | ||
Write-Log -message $moduleName -Severity INFO | ||
|
||
# Log the params, if existing | ||
Write-Log -message "INPUT:" | ||
if ( $InputHashtable ) { | ||
$InputHashtable.Keys | ForEach-Object { | ||
$param = $_ | ||
Write-Log -message " $( $param ) = '$( $InputHashtable[$param] )'" -writeToHostToo $false | ||
} | ||
} | ||
|
||
#----------------------------------------------- | ||
# DEPENDENCIES | ||
#----------------------------------------------- | ||
|
||
#Import-Module MeasureRows | ||
#Import-Module SqlServer | ||
#Import-Module ConvertUnixTimestamp | ||
#Import-Lib -IgnorePackageStructure | ||
|
||
} | ||
|
||
process { | ||
|
||
# Load mailings data from CleverReach | ||
$groups = Get-List -Type STANDARD | ||
|
||
Write-Log "Loaded $( $groups.Count ) groups from Inxmail" -severity INFO | ||
|
||
# Load and filter list into array of mailings objects | ||
$groupsList = [System.Collections.ArrayList]@() | ||
$groups | ForEach-Object { | ||
$group = $_ | ||
[void]$groupsList.add( | ||
[MailingList]@{ | ||
mailingListId=$group.id | ||
mailingListName=( $group.name -replace '[^\w\s]', '' ) | ||
} | ||
) | ||
} | ||
|
||
# Transform the mailings array into the needed output format | ||
$columns = @( | ||
@{ | ||
name="id" | ||
expression={ $_.mailingListId } | ||
} | ||
@{ | ||
name="name" | ||
expression={ $_.toString() } | ||
} | ||
) | ||
|
||
$lists = [System.Collections.ArrayList]@() | ||
[void]$lists.AddRange(@( $groupsList | Select-Object $columns )) | ||
|
||
If ( $lists.count -gt 0 ) { | ||
|
||
Write-Log "Loaded $( $lists.Count ) lists/groups" -severity INFO #-WriteToHostToo $false | ||
|
||
} else { | ||
|
||
$msg = "No lists loaded -> please check!" | ||
Write-Log -Message $msg -Severity ERROR | ||
throw $msg | ||
|
||
} | ||
|
||
# Return | ||
$lists | ||
|
||
} | ||
|
||
end { | ||
|
||
} | ||
|
||
} | ||
|