Public/Get-PegasusDemoData.ps1
function Get-PegasusDemoData { [CmdletBinding()] Param ( ) Process { #region Example data - persons $ExpectedPersons = @( @{ anchor = "8a2462e1-068b-4be0-840b-c961ab66aded" firstname = "James" lastname = "Hoffmann" positions = @( @{ id = "1" employeeid = "1001" name = "Chief Executive Officer" orgunit = "1" startdate = "2021-01-01" enddate = "2099-12-31" } ) } @{ anchor = "f6609805-86ad-4c78-a79e-beed5034ca94" firstname = "John" lastname = "Doe" positions = @( @{ id = "1" employeeid = "1002" name = "HR Manager" orgunit = "1" startdate = "2021-01-01" enddate = "2099-12-31" } ) } @{ anchor = "18ff6bd8-98ca-4bd7-b3f6-6e803c6ed8ed" firstname = "Jane" lastname = "Doe" positions = @( @{ id = "1" employeeid = "1003" name = "IT Manager" orgunit = "1" startdate = "2021-01-01" enddate = "2099-12-31" } ) } @{ anchor = "b8672b8b-cd86-41d3-904b-315004c5a0b6" firstname = "Alice" lastname = "Smith" positions = @( @{ id = "1" employeeid = "1004" name = "Marketing Manager" orgunit = "1" startdate = "2021-01-01" enddate = "2099-12-31" } ) } @{ anchor = "0910c415-e851-40af-9759-291e48c5bb28" firstname = "Bob" lastname = "Smith" positions = @( @{ id = "1" employeeid = "1005" name = "Chief Executive Officer" orgunit = "2" startdate = "2021-01-01" enddate = "2099-12-31" } ) } @{ anchor = "6088fc01-a146-43cb-831d-75f6b7ad3207" firstname = "Charlie" lastname = "Brown" positions = @( @{ id = "1" employeeid = "5748" name = "HR Manager" orgunit = "2" startdate = "2021-01-01" enddate = "2099-12-31" } ) } @{ anchor = "00dd0c86-9217-484b-b448-d01a1ef8929f" firstname = "Daisy" lastname = "Duck" positions = @( @{ id = "1" employeeid = "1006" name = "IT Manager" orgunit = "2" startdate = "2021-01-01" enddate = "2099-12-31" } ) } @{ anchor = "ab30b317-c056-4240-b9aa-5c168d1edab2" firstname = "Eve" lastname = "Doe" positions = @( @{ id = "1" employeeid = "1007" name = "Marketing Manager" orgunit = "2" startdate = "2021-01-01" enddate = "2099-12-31" } ) } @{ anchor = "d4cd5695-2a31-40e0-a77b-95329a9ed3ae" firstname = "Fred" lastname = "Flintstone" positions = @( @{ id = "1" employeeid = "1008" name = "Designer" orgunit = "22" startdate = "2021-01-01" enddate = "2099-12-31" } ) } @{ anchor = "41399484-77bf-4c80-86fc-b5c545e7cc8d" firstname = "George" lastname = "Jetson" positions = @( @{ id = "1" employeeid = "1009" name = "Designer" orgunit = "22" startdate = "2021-01-01" enddate = "2099-12-31" } ) } @{ anchor = "23b1b03b-666e-4deb-bbeb-7d2cf767d8a5" firstname = "Homer" lastname = "Simpson" positions = @( @{ id = "1" employeeid = "1010" name = "Senior consultant" orgunit = "21" startdate = "2015-11-01" enddate = "2099-12-31" } ) } @{ anchor = "90e3a9ff-c16d-4997-bb79-9de74d5c22b3" firstname = "Isaac" lastname = "Newton" positions = @( @{ id = "1" employeeid = "1011" name = "Senior consultant" orgunit = "21" startdate = "2019-11-01" enddate = "2099-12-31" } ) } @{ anchor = "253dad74-9b05-48fe-ad3f-3d6bdfe5f766" firstname = "Johannes" lastname = "Kepler" positions = @( @{ id = "1" employeeid = "1012" name = "Senior consultant" orgunit = "11" startdate = "2019-12-01" enddate = "2099-12-31" } ) } @{ anchor = "238e0c48-bfd9-4d65-a5d4-28d7ca44c3bc" firstname = "Karl" lastname = "Marx" positions = @( @{ id = "1" employeeid = "1013" name = "Senior consultant" orgunit = "10" startdate = "2023-03-01" enddate = "2099-12-31" } ) } @{ anchor = "ff95aa75-6dcf-480a-babd-b82401cc326b" firstname = "Leonardo" lastname = "Da Vinci" positions = @( @{ id = "1" employeeid = "1014" name = "Senior consultant" orgunit = "21" startdate = "2023-10-01" enddate = "2099-12-31" } ) } @{ anchor = "0c5bd0b0-b812-4416-9101-f5bcc6abcfeb" firstname = "Mickey" lastname = "Mouse" positions = @( @{ id = "1" employeeid = "1015" name = "Senior consultant" orgunit = "21" startdate = "2023-09-01" enddate = "2099-12-31" } ) } @{ anchor = "57d77107-2c4f-4a10-94e3-bda3d993ba7f" firstname = "Nikola" lastname = "Tesla" positions = @( @{ id = "1" employeeid = "1016" name = "Senior consultant" orgunit = "10" startdate = "2024-09-01" enddate = "2099-12-31" } ) } @{ anchor = "6c6e2350-08af-4cdd-81b7-4d8f8e9cf367" firstname = "Oscar" lastname = "Wilde" positions = @( @{ id = "1" employeeid = "1017" name = "Senior consultant" orgunit = "10" startdate = "2024-01-01" enddate = "2099-12-31" } ) } @{ anchor = "5b652e6c-c1a8-4f17-8fa1-12f598dbe084" firstname = "Pablo" lastname = "Picasso" positions = @( @{ id = "1" employeeid = "1018" name = "Senior consultant" orgunit = "10" startdate = "1994-09-01" enddate = "2099-12-31" } ) } @{ anchor = "d9a7c0ae-a809-4955-857c-807c717f7b34" firstname = "Quentin" lastname = "Tarantino" positions = @( @{ id = "1" employeeid = "1019" name = "Senior consultant" orgunit = "10" startdate = "2017-05-01" enddate = "2099-12-31" } ) } @{ anchor = "e519ebcb-3fe3-4197-8426-646d3c375529" firstname = "Rene" lastname = "Descartes" positions = @( @{ id = "1" employeeid = "1020" name = "Senior consultant" orgunit = "10" startdate = "2022-05-01" enddate = "2099-12-31" } ) } @{ anchor = "fbf1ed36-d646-4966-b6fb-23ad7705387f" firstname = "Sigmund" lastname = "Freud" positions = @( @{ id = "1" employeeid = "1021" name = "Principal consultant" orgunit = "10" startdate = "2023-01-01" enddate = "2099-12-31" } ) } @{ anchor = "2dc08016-e0c9-49a4-b21e-8dfdabc51536" firstname = "Thomas" lastname = "Edison" positions = @( @{ id = "1" employeeid = "1022" name = "Phone operator" orgunit = "22" startdate = "2022-10-01" enddate = "2099-12-31" } ) } @{ anchor = "a089d9b0-d880-425d-a9ef-885f66ca0b9a" firstname = "Ulysses" lastname = "Grant" positions = @( @{ id = "1" employeeid = "1023" name = "Phone operator" orgunit = "22" startdate = "2022-10-01" enddate = "2099-12-31" } ) } ) #endregion #region Example data - org units $ExpectedOrgUnits = @( @{ id = "1" name = "Identity Travels AS" manager = "8a2462e1-068b-4be0-840b-c961ab66aded" } @{ id = "10" name = "HR" parent = "1" manager = "f6609805-86ad-4c78-a79e-beed5034ca94" } @{ id = "11" name = "IT" parent = "1" manager = "18ff6bd8-98ca-4bd7-b3f6-6e803c6ed8ed" } @{ id = "12" name = "Marketing" parent = "1" manager = "b8672b8b-cd86-41d3-904b-315004c5a0b6" } @{ id = "2" name = "Identity Travels AB" manager = "0910c415-e851-40af-9759-291e48c5bb28" } @{ id = "20" name = "HR" parent = "2" manager = "6088fc01-a146-43cb-831d-75f6b7ad3207" } @{ id = "21" name = "IT" parent = "2" manager = "00dd0c86-9217-484b-b448-d01a1ef8929f" } @{ id = "22" name = "Operations" parent = "2" manager = "ab30b317-c056-4240-b9aa-5c168d1edab2" } ) #endregion @{ Persons = $ExpectedPersons | Select-Object ssn, anchor, firstname, lastname, @{L = "displayname"; E = { "$($_.firstname) $($_.lastname)" } } OrgUnits = $ExpectedOrgUnits | ForEach-Object { $OrgUnit = @{ sourceid = $_.id displayname = $_.name.Trim() shortname = $_.id longname = $_.name.Trim() managers = New-Object System.Collections.ArrayList # deputies = $ExistingPosition.deputies ?? (New-Object System.Collections.ArrayList) parent = $_.parent } if ($_.manager) { $_.manager | ForEach-Object { $OrgUnit.managers.Add($_) | Out-Null } } $OrgUnit } Positions = $ExpectedPersons | ForEach-Object { $Person = $_ # $Person = $ExpectedPersons | ? positions | get-random -count 1 if (!$Person.positions) { return } $Person.positions | ForEach-Object { $Position = $_ @{ sourceid = "$($Person.anchor)-$($Position.id)" person = $Person.anchor startdate = $Position.startdate enddate = $Position.enddate primary = $Position.primary ?? $false orgunit = $Position.orgunit jobtitle = $Position.name employeeid = $Position.employeeid customfields = @{} } } } } } } |