PembrokePSqman.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
Write-Verbose 'Importing from [C:\projects\pembrokepsqman\PembrokePSqman\private]'
# .\PembrokePSqman\private\Get-ActiveWmanTaskSet.ps1
function Get-ActiveWmanTaskSet {
    <#
    .DESCRIPTION
        This function will gather the cancelled tasks for the specified TableName.
    .PARAMETER RestServer
        A Rest Server is required.
    .PARAMETER TableName
        A TableName is optional, default is tasks.
    .PARAMETER WmanId
        A WmanId is Required.
    .EXAMPLE
        Get-ActiveWmanTaskSet -RestServer localhost -TableName tasks -WmanId 1
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([hashtable])]
    param(
        [Parameter(Mandatory=$true)][string]$RestServer,
        [Parameter(Mandatory=$true)][int]$WmanId,
        [string]$TableName="tasks"
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            # Checking for tasks that are (Assigned(7),Running(8),Cancelled(10),Staged(14))
            Write-LogLevel -Message "Checking for tasks that are (Assigned(7),Running(8),Cancelled(10),Staged(14)) in table: $TableName" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel DEBUG
            $TableName = $TableName.ToLower()
            $URL = "http://$RestServer/PembrokePS/public/api/api.php/$TableName" + "?&filter[]=STATUS_ID,eq,7&filter[]=STATUS_ID,eq,8&filter[]=STATUS_ID,eq,10&filter[]=STATUS_ID,eq,14&transform=1&satisfy=any"
            Write-LogLevel -Message "The Url is $URL" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel TRACE
            $ActiveWmanTasks = Invoke-RestMethod -Method Get -Uri "$URL" -UseBasicParsing
        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Get-ActiveWmanTaskSet: $ErrorMessage $FailedItem"
        }
        $ActiveWmanTasks
    } else {
        Throw "Get-ActiveWmanTaskSet: Unable to reach Rest server $RestServer."
    }
    
}
# .\PembrokePSqman\private\Get-AvailableWmanSet.ps1
function Get-AvailableWmanSet {
    <#
    .DESCRIPTION
        This function will gather available Workflow Managers that are of a specified type.
    .PARAMETER RestServer
        A Rest Server is required.
    .PARAMETER Wman_Type
        A Wman_Type is required.
    .EXAMPLE
        Get-AvailableWmanSet -RestServer localhost -Wman_Type 1
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([hashtable])]
    param(
        [Parameter(Mandatory=$true)][string]$RestServer,
        [Parameter(Mandatory=$true)][int]$Wman_Type
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            Write-LogLevel -Message "Gathering available Workflow Managers with Type: $Wman_Type" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
            $URL = "http://$RestServer/PembrokePS/public/api/api.php/workflow_manager?filter[]=status_id,eq,2&filter[]=WORKFLOW_MANAGER_TYPE_ID,eq,$Wman_Type&transform=1"
            Write-LogLevel -Message "the URL is: $URL" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel TRACE
            $WmanStatusData = Invoke-RestMethod -Method Get -Uri "$URL" -UseBasicParsing
        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Get-AvailableWmanSet: $ErrorMessage $FailedItem"
        }
        $WmanStatusData
    } else {
        Throw "Get-AvailableWmanSet: Unable to reach Rest server: $RestServer."
    }
    
}
# .\PembrokePSqman\private\Get-AvailableWmanType.ps1
function Get-AvailableWmanType {
    <#
    .DESCRIPTION
        This function will get the Workflow Manager Type based on the specified task type.
    .PARAMETER RestServer
        A Rest Server is required.
    .PARAMETER TaskTypeId
        A TaskTypeId is required.
    .EXAMPLE
        Get-AvailableWmanType -RestServer localhost -TaskTypeId 1
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([hashtable])]
    param(
        [Parameter(Mandatory=$true)][string]$RestServer,
        [Parameter(Mandatory=$true)][int]$TaskTypeId
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            Write-LogLevel -Message "Gathering Available Wman type based on task type: $TaskTypeId" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel DEBUG
            $URL = "http://$RestServer/PembrokePS/public/api/api.php/wman_task_types" + "?filter[]=TASK_TYPE_ID,eq,$TaskTypeId&filter[]=STATUS_ID,eq,11&transform=1"
            Write-LogLevel -Message "the URL is: $URL" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel TRACE
            $WmanTypeData = Invoke-RestMethod -Method Get -Uri "$URL" -UseBasicParsing
        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Get-AvailableWmanType: $ErrorMessage $FailedItem"
        }
        $WmanTypeData
    } else {
        Throw "Get-AvailableWmanType: Unable to reach Rest server: $RestServer."
    }
    
}
# .\PembrokePSqman\private\Get-CancelledTaskSet.ps1
function Get-CancelledTaskSet {
    <#
    .DESCRIPTION
        This function will gather the cancelled tasks for the specified TableName.
    .PARAMETER RestServer
        A Rest Server is required.
    .PARAMETER TableName
        A TableName is optional, default is tasks.
    .EXAMPLE
        Get-CancelledTaskSet -RestServer localhost -TableName tasks
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([hashtable])]
    param(
        [Parameter(Mandatory=$true)][string]$RestServer,
        [string]$TableName="tasks"
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            $TableName = $TableName.ToLower()
            Write-LogLevel -Message "Gathering cancelled tasks from table: $TableName" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
            $URL = "http://$RestServer/PembrokePS/public/api/api.php/$TableName" + "?filter=STATUS_ID,eq,10&transform=1"
            Write-LogLevel -Message "the URL is: $URL" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel TRACE
            $CancelledTasks = Invoke-RestMethod -Method Get -Uri "$URL" -UseBasicParsing
        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Get-CancelledTaskSet: $ErrorMessage $FailedItem"
        }
        $CancelledTasks
    } else {
        Throw "Get-CancelledTaskSet: Unable to reach Rest server: $RestServer."
    }
    
}
# .\PembrokePSqman\private\Get-QmanStatus.ps1
function Get-QmanStatus {
    <#
    .DESCRIPTION
        This function will gather Status information from PembrokePS web/rest for a Queue_Manager
    .PARAMETER ComponentId
        An ID is required.
    .PARAMETER RestServer
        A Rest Server is required.
    .EXAMPLE
        Get-QmanStatus -ComponentId 1 -RestServer localhost
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([hashtable])]
    param(
        [Parameter(Mandatory=$true)][int]$ComponentId,
        [Parameter(Mandatory=$true)][string]$RestServer
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            Write-LogLevel -Message "Getting the Queue_Manager via 'Get-ComponentStatus" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel DEBUG
            $ComponentStatusData = (Get-ComponentStatus -ComponentType Queue_Manager -ComponentId $ComponentId -RestServer $RestServer).queue_manager
        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Get-QmanStatus: $ErrorMessage $FailedItem"
        }
        $ComponentStatusData
    } else {
        Throw "Get-QmanStatus: Unable to reach Rest server: $RestServer."
    }
    
}
# .\PembrokePSqman\private\Get-QmanTableName.ps1
function Get-QmanTableName {
    <#
    .DESCRIPTION
        This function will gather The tableName for the Queue Manager type.
    .PARAMETER RestServer
        A Rest Server is required.
    .PARAMETER Type_ID
        A Queue Manager Type_ID is required.
    .EXAMPLE
        Get-QmanTableName -RestServer localhost -Type_ID 1
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([hashtable])]
    param(
        [Parameter(Mandatory=$true)][string]$RestServer,
        [Parameter(Mandatory=$true)][int]$Type_ID
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            Write-LogLevel -Message "Getting the TableName from: queue_Manager_type table." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel DEBUG
            $URL = "http://$RestServer/PembrokePS/public/api/api.php/queue_manager_type/$Type_ID"
            Write-LogLevel -Message "the URL is: $URL" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel TRACE
            $TableName = Invoke-RestMethod -Method Get -Uri "$URL" -UseBasicParsing
        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Get-QmanTableName: $ErrorMessage $FailedItem"
        }
        $TableName
    } else {
        Throw "Get-QmanTableName: Unable to reach Rest server: $RestServer."
    }
    
}
# .\PembrokePSqman\private\Get-QueuedTaskSet.ps1
function Get-QueuedTaskSet {
    <#
    .DESCRIPTION
        This function will gather the Queued tasks for the specified TableName.
    .PARAMETER RestServer
        A Rest Server is required.
    .PARAMETER TableName
        A TableName is optional, default is tasks.
    .EXAMPLE
        Get-QueuedTaskSet -RestServer localhost -TableName tasks
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([hashtable])]
    param(
        [Parameter(Mandatory=$true)][string]$RestServer,
        [string]$TableName="tasks"
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            $TableName = $TableName.ToLower()
            Write-LogLevel -Message "Gathering Queued tasks from table: $TableName." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
            $URL = "http://$RestServer/PembrokePS/public/api/api.php/$TableName" + "?filter=STATUS_ID,eq,6&transform=1"
            Write-LogLevel -Message "the URL is: $URL" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel TRACE
            $SubmittedTasks = Invoke-RestMethod -Method Get -Uri "$URL" -UseBasicParsing
        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Get-QueuedTaskSet: $ErrorMessage $FailedItem"
        }
        $SubmittedTasks
    } else {
        Throw "Get-QueuedTaskSet: Unable to reach Rest server: $RestServer."
    }
    
}
# .\PembrokePSqman\private\Get-SubmittedTaskSet.ps1
function Get-SubmittedTaskSet {
    <#
    .DESCRIPTION
        This function will gather The submitted tasks for the specified TableName.
    .PARAMETER RestServer
        A Rest Server is required.
    .PARAMETER TableName
        A TableName is optional, default is tasks.
    .EXAMPLE
        Get-SubmittedTaskSet -RestServer localhost -TableName tasks
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([hashtable])]
    param(
        [Parameter(Mandatory=$true)][string]$RestServer,
        [string]$TableName="tasks"
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            $TableName = $TableName.ToLower()
            Write-LogLevel -Message "Gathering Submitted tasks for table: $TableName" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
            $URL = "http://$RestServer/PembrokePS/public/api/api.php/$TableName" + "?filter=STATUS_ID,eq,5&transform=1"
            Write-LogLevel -Message "the URL is: $URL" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel TRACE
            $SubmittedTasks = Invoke-RestMethod -Method Get -Uri "$URL" -UseBasicParsing
        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Get-SubmittedTaskSet: $ErrorMessage $FailedItem"
        }
        $SubmittedTasks
    } else {
        Throw "Get-SubmittedTaskSet: Unable to reach Rest server: $RestServer."
    }
    
}
# .\PembrokePSqman\private\Invoke-AbortCancelledTaskSet.ps1
function Invoke-AbortCancelledTaskSet {
    <#
    .DESCRIPTION
        This function will Set any cancelled task to aborted.
    .PARAMETER RestServer
        A Rest Server is required.
    .PARAMETER TableName
        A TableName is optional, default is tasks.
    .EXAMPLE
        Invoke-AbortCancelledTaskSet -RestServer localhost -TableName tasks
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([Int])]
    [OutputType([Boolean])]
    param(
        [Parameter(Mandatory=$true)][string]$RestServer,
        [string]$TableName="tasks"
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            # Get a list of Submitted tasks
            $TableName = $TableName.ToLower()
            $CancelledTasks = (Get-CancelledTaskSet -RestServer $RestServer -TableName $TableName).$TableName
            $CancelledTasksCount = ($CancelledTasks | Measure-Object).count
            Write-LogLevel -Message "Aborting: $CancelledTasksCount, in table: $TableName" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel info
            if($CancelledTasksCount -gt 0) {
                foreach($Task in $CancelledTasks){
                    # Foreach task, set it to Complete/Aborted.
                    $TaskId = $Task.ID
                    $body = @{STATUS_ID = "9"
                                RESULT_ID = "5"
                                WORKFLOW_MANAGER_ID = "9999"
                            }
                    Write-LogLevel -Message "Aborting task: $TaskId, table: $TableName" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel DEBUG
                    $RestReturn = Invoke-UpdateTaskTable -RestServer $RestServer -TableName $TableName -TaskID $TaskId -Body $body
                }
            } else {
                # No tasks to queue
            }
        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Invoke-AbortCancelledTaskSet: $ErrorMessage $FailedItem"
        }
        $RestReturn
    } else {
        Throw "Invoke-AbortCancelledTaskSet: Unable to reach Rest server: $RestServer."
    }
    
}
# .\PembrokePSqman\private\Invoke-AssignTask.ps1
function Invoke-AssignTask {
    <#
    .DESCRIPTION
        This function will Assign a task to a specific WorkFlow Manager.
    .PARAMETER TaskId
        A TaskId is required.
    .PARAMETER RestServer
        A Rest Server is required.
    .PARAMETER WmanId
        A WmanId is required.
    .PARAMETER TableName
        A TableName is optional, default is tasks.
    .EXAMPLE
        Invoke-AssignTask -RestServer localhost -TaskId 1 -WmanId 1
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([Int])]
    param(
        [Parameter(Mandatory=$true)][int]$TaskId,
        [Parameter(Mandatory=$true)][int]$WmanId,
        [Parameter(Mandatory=$true)][string]$RestServer,
        [string]$TableName="tasks"
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            $TableName = $TableName.ToLower()
            $body = @{STATUS_ID = "7"
                        WORKFLOW_MANAGER_ID = "$WmanId"
                    }
            Write-LogLevel -Message "Assigning task: $TaskId, to Wman: $WmanId, table: $TableName" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
            $URL = "http://$RestServer/PembrokePS/public/api/api.php/$TableName/$TaskId"
            Write-LogLevel -Message "URL is: $URL" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel TRACE
            $RestReturn = Invoke-RestMethod -Method Put -Uri "$URL" -body $body
        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Invoke-AssignTask: $ErrorMessage $FailedItem"
        }
        $RestReturn
    } else {
        Throw "Invoke-AssignTask: Unable to reach Rest server: $RestServer."
    }
    
}
# .\PembrokePSqman\private\Invoke-Qman.ps1
function Invoke-Qman {
    <#
    .DESCRIPTION
        This function will gather Status information from PembrokePS web/rest for a Queue_Manager
    .PARAMETER PropertyFilePath
        A properties path is Required.
    .EXAMPLE
        Invoke-Qman -PropertyFilePath "c:\PembrokePS\qman\pembrokeps.properties"
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([hashtable])]
    [OutputType([Boolean])]
    param(
        [Parameter(Mandatory=$true)][string]$PropertyFilePath
    )
    if (Test-Path -Path $PropertyFilePath) {
        # Gather Local Properties for the Queue Manager
        $PpsProperties = Get-LocalPropertySet -PropertyFilePath $PropertyFilePath
        $RestServer = $PpsProperties.'system.RestServer'
        $SystemRoot = $PpsProperties.'system.root'
        $ID = $PpsProperties.'component.Id'
        $RunLogLevel = $PpsProperties.'component.RunLogLevel'
        $LOG_FILE = $PpsProperties.'component.logfile'
        Write-LogLevel -Message "Gathering Local Properties from: $PropertyFilePath, SystemRoot: $SystemRoot" -Logfile "$LOG_FILE" -RunLogLevel CONSOLEONLY -MsgLevel CONSOLEONLY
     } else {
        Write-LogLevel -Message "Unable to Locate Local properties file: $PropertyFilePath." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel ERROR
        Throw "Invoke-Qman: Unable to Locate Properties file."
    }
    try
    {
        $script:QmanRunning = "Running"
        do {
            # Test connection with the Database Server
            Write-LogLevel -Message "Starting Invoke-Qman loop" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
            if (Test-Connection -Count 1 $RestServer -Quiet) {
                # No Action needed if the RestServer can be reached.
            } else {
                $script:QmanRunning = "Shutdown"
                Write-LogLevel -Message "Unable to reach RestServer: $RestServer." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel ERROR
                Throw "Unable to reach Rest server."
            }
            Write-LogLevel -Message "Validated Connection to RestServer." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO 
            # Get the Status and Queue Manager Specific Information from the Database
            $QmanStatusData = Get-QmanStatus -ComponentId $ID -RestServer $RestServer
            $QueueManagerStatus = $QmanStatusData.STATUS_ID
            $LOG_FILE = $QmanStatusData.LOG_FILE
            $ManagerWait = $QmanStatusData.WAIT
            $QUEUE_MANAGER_TYPE_ID = $QmanStatusData.QUEUE_MANAGER_TYPE_ID
            Write-LogLevel -Message "Get-QmanStatus is complete" -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel INFO 
            $TableName = (Get-QmanTableName -RestServer $RestServer -Type_ID $QUEUE_MANAGER_TYPE_ID).TABLENAME
            Write-LogLevel -Message "Get QmanTablename is complete, TableName: $TableName" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
            # Based on the Status Perform Specific actions
            Write-LogLevel -Message "QueueManager ID: $ID" -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel INFO 
            Write-LogLevel -Message "QueueManager Status: $QueueManagerStatus" -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel INFO 
            Write-LogLevel -Message "QueueManager TableName : $TableName" -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel INFO 
            Write-LogLevel -Message "QueueManager Wait: $ManagerWait" -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel INFO 
            Write-LogLevel -Message "QueueManager LogFile: $LOG_FILE" -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel INFO 
            if ($QueueManagerStatus -eq 1) {
                # Down - Not doing Anything
                Write-LogLevel -Message "Get-QmanStatus is Down, Not taking Action." -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel ERROR 
            } elseif ($QueueManagerStatus -eq 2) {
                # Up - Perform normal Tasks
                Write-LogLevel -Message "Get-QmanStatus is UP, performing Normal Operations" -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel INFO 
                Write-LogLevel -Message "Aborting Cancelled Tasks" -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel DEBUG 
                Invoke-AbortCancelledTaskSet -RestServer $RestServer -TableName $TableName
                Invoke-Wait -Seconds 5
                Write-LogLevel -Message "Queuing Submitted Tasks" -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel DEBUG 
                Invoke-QueueSubmittedTaskSet -RestServer $RestServer -TableName $TableName 
                Invoke-Wait -Seconds 5
                Write-LogLevel -Message "Reviewing Queued Tasks" -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel DEBUG 
                Invoke-ReviewQueuedTaskSet -RestServer $RestServer -TableName $TableName
                Write-LogLevel -Message "Normal Operations Completed." -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel DEBUG 
            } elseif ($QueueManagerStatus -eq 3) {
                # Starting Up - Perform startup Tasks
                Write-LogLevel -Message "Performting Startup Tasks" -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel INFO 
                Invoke-QmanStartupTaskSet -TableName $TableName -RestServer $RestServer -ID $ID
                Write-LogLevel -Message "Startup Tasks Completed." -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel DEBUG
            } elseif ($QueueManagerStatus -eq 4) {
                # Shutting Down - Perform Shutdown Tasks
                Write-LogLevel -Message "Performing Shutdown tasks." -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel INFO 
                Invoke-QmanShutdownTaskSet -TableName $TableName -RestServer $RestServer -ID $ID
                $script:QmanRunning = "Shutdown"
                Write-LogLevel -Message "Shutdown tasks completed." -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel DEBUG 
            }
            Write-LogLevel -Message "Manager running String: $script:QmanRunning" -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel TRACE 
            if($script:QmanRunning -ne "Shutdown"){
                Write-LogLevel -Message "Waiting $ManagerWait Seconds" -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel DEBUG 
                Invoke-Wait -Seconds $ManagerWait
            }
        } while ($script:QmanRunning -ne "Shutdown")
        Write-LogLevel -Message "Exiting QueueManager Function." -Logfile $LOG_FILE -RunLogLevel $RunLogLevel -MsgLevel DEBUG 
    }
    catch
    {
        $ErrorMessage = $_.Exception.Message
        $FailedItem = $_.Exception.ItemName        
        Throw "Invoke-Qman: $ErrorMessage $FailedItem"
    }
    
}
# .\PembrokePSqman\private\Invoke-QmanShutdownTaskSet.ps1
function Invoke-QmanShutdownTaskSet {
    <#
    .DESCRIPTION
        This function will perform shutdown tasks for a Queue_Manager
    .PARAMETER RestServer
        A RestServer is Required.
    .PARAMETER TableName
        A properties path is Required.
    .PARAMETER ID
        An ID is Required.
    .EXAMPLE
        Invoke-QmanShutdownTaskSet -RestServer localhost -TableName tasks -ID 1
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([hashtable])]
    [OutputType([Boolean])]
    param(
        [Parameter(Mandatory=$true)][string]$RestServer,
        [Parameter(Mandatory=$true)][string]$TableName,
        [Parameter(Mandatory=$true)][int]$ID
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            $TableName = $TableName.ToLower()
            Write-LogLevel -Message "Aborting cancelled tasks for table: $TableName" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
            Invoke-AbortCancelledTaskSet -RestServer $RestServer -TableName $TableName
            Invoke-Wait -Seconds 5
            Write-LogLevel -Message "Shutting down QueueManager: $ID." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
            Invoke-UpdateQmanData -ComponentId $ID -RestServer $RestServer -Column STATUS_ID -Value 1
        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Invoke-QmanShutdownTaskSet: $ErrorMessage $FailedItem"
        }
        $ReturnMessage
    } else {
        Throw "Invoke-QmanShutdownTaskSet: Unable to reach Rest server: $RestServer."
    }

}
    
# .\PembrokePSqman\private\Invoke-QmanStartupTaskSet.ps1
function Invoke-QmanStartupTaskSet {
    <#
    .DESCRIPTION
        This function will perform shutdown tasks for a Queue_Manager
    .PARAMETER RestServer
        A RestServer is Required.
    .PARAMETER TableName
        A properties path is Required.
    .PARAMETER ID
        An ID is Required.
    .EXAMPLE
        Invoke-QmanStartupTaskSet -RestServer localhost -TableName tasks -ID 1
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([hashtable])]
    [OutputType([Boolean])]
    param(
        [Parameter(Mandatory=$true)][string]$RestServer,
        [Parameter(Mandatory=$true)][string]$TableName,
        [Parameter(Mandatory=$true)][int]$ID
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            $TableName = $TableName.ToLower()
            Write-LogLevel -Message "Aborting Cancelled tasks for Table: $TableName" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
            Invoke-AbortCancelledTaskSet -RestServer $RestServer -TableName $TableName
            Invoke-Wait -Seconds 5
            Write-LogLevel -Message "Setting the QueueManager status to 2(Running)." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
            Invoke-UpdateQmanData -ComponentId $ID -RestServer $RestServer -Column STATUS_ID -Value 2
        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Invoke-QmanStartupTaskSet: $ErrorMessage $FailedItem"
        }
        $ReturnMessage
    } else {
        Throw "Invoke-QmanStartupTaskSet: Unable to reach Rest server: $RestServer."
    }
}
    
# .\PembrokePSqman\private\Invoke-QueueSubmittedTaskSet.ps1
function Invoke-QueueSubmittedTaskSet {
    <#
    .DESCRIPTION
        This function will queue Submitted tasks
    .PARAMETER RestServer
        A Rest Server is required.
    .PARAMETER TableName
        A TableName is optional, default is tasks.
    .EXAMPLE
        Invoke-QueueSubmittedTaskSet -RestServer localhost -TableName tasks
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([Int])]
    [OutputType([Boolean])]
    param(
        [Parameter(Mandatory=$true)][string]$RestServer,
        [string]$TableName="tasks"
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            # Get a list of Submitted tasks
            $TableName = $TableName.ToLower()
            $SubmittedTasks = (Get-SubmittedTaskSet -RestServer $RestServer -TableName $TableName).$TableName
            $SubmittedTasksCount = ($SubmittedTasks | Measure-Object).count
            Write-LogLevel -Message "Reviewing: $SubmittedTasksCount for queueing from table: $TableName." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
            if($SubmittedTasksCount -gt 0) {
                foreach($Task in $SubmittedTasks){
                    # Foreach task, set it to Queued.
                    $TaskId = $Task.ID
                    $body = @{STATUS_ID = "6"} 
                    Write-LogLevel -Message "Queueing task: $TaskId." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
                    $ReturnMessage = Invoke-UpdateTaskTable -RestServer $RestServer -TableName $TableName -TaskID $TaskId -Body $body
                }
            } else {
                # No tasks to queue
                Write-LogLevel -Message "No Tasks to Queue from table: $TableName." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel DEBUG
            }
        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Invoke-QueueSubmittedTaskSet: $ErrorMessage $FailedItem"
        }
        $ReturnMessage
    } else {
        Throw "Invoke-QueueSubmittedTaskSet: Unable to reach Rest server: $RestServer."
    }
    
}
# .\PembrokePSqman\private\Invoke-ReviewQueuedTaskSet.ps1
function Invoke-ReviewQueuedTaskSet {
    <#
    .DESCRIPTION
        This function will Review Queued tasks for assignment to Workflow Managers.
    .PARAMETER RestServer
        A Rest Server is required.
    .PARAMETER TableName
        A TableName is optional, default is tasks.
    .EXAMPLE
        Invoke-ReviewQueuedTaskSet -RestServer localhost -TableName tasks
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([Int])]
    [OutputType([Boolean])]
    param(
        [Parameter(Mandatory=$true)][string]$RestServer,
        [string]$TableName="tasks"
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            # Get a list of Submitted tasks
            $TableName = $TableName.ToLower()
            $QueuedTasks = (Get-QueuedTaskSet -RestServer $RestServer -TableName $TableName).$TableName
            $QueuedTasksCount = ($QueuedTasks | Measure-Object).Count
            Write-LogLevel -Message "Reviewing: $QueuedTasksCount tasks that are queued from table: $TableName." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
            if($QueuedTasksCount -gt 0) {
                foreach($Task in $QueuedTasks){
                    # Foreach task, see if it can be assigned.
                    $TaskId = $Task.ID
                    $TASK_TYPE_ID = $Task.TASK_TYPE_ID
                    Write-LogLevel -Message "Reviewing TaskId: $TaskId TaskTypeID: $Task_Type_Id for Assignment." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
                    # Based on the task type ID, we need to get the Workflow Manager Type that is enabled to perform that task.
                    Write-LogLevel -Message "Determining the Workflow Manager Type that can perform the task." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel DEBUG
                    $Wman_Type_ID = ((Get-AvailableWmanType -RestServer localhost -TaskTypeId $TASK_TYPE_ID).wman_task_types).WORKFLOW_MANAGER_TYPE_ID
                    # then get the WMAN that is available
                    Write-LogLevel -Message "Getting list of Available Workflow Managers" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel DEBUG
                    $AvailableWmanSet = (Get-AvailableWmanSet -RestServer localhost -Wman_Type $Wman_Type_ID).workflow_manager
                    # Loop through each to see if the Wman is at it's max
                    :SingleTaskLoop
                    foreach($Workflow_Manager in $AvailableWmanSet) {
                        $WmanId = $Workflow_Manager.ID
                        $Wman_Max = $Workflow_Manager.MAX_CONCURRENT_TASKS
                        $Wman_Hostname = $Workflow_Manager.Hostname
                        # Get the current Number of 'active' tasks assigned to the Workflow Manager
                        $WmanActiveTaskCount = ((Get-ActiveWmanTaskSet -RestServer localhost -TableName tasks -WmanId $WmanId).$TableName | Where-Object {$_.WORKFLOW_MANAGER_ID -eq "$WmanId"} | Measure-Object).count
                        # if its not, then we can assign it!
                        if ($WmanActiveTaskCount -lt $Wman_Max){
                            #Don't forget to break out if we can assign it!
                            Write-LogLevel -Message "Assigning task: $TaskId to Mgr: $Wman_Hostname." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel INFO
                            $ReturnMessage = Invoke-AssignTask -RestServer localhost -TaskId $TaskId -WmanId $WmanId
                            break SingleTaskLoop
                        } else {
                            # Current Workflow MGR was at its Max.
                            Write-LogLevel -Message "Current Workflow Manager: $Wman_Hostname is running at it's max: $WmanActiveTaskCount." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel DEBUG
                        }
                    }
                }
            } else {
                # No tasks to queue
                Write-LogLevel -Message "No Tasks to Queue" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel DEBUG
            }
        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Invoke-ReviewQueuedTaskSet: $ErrorMessage $FailedItem"
        }
        $ReturnMessage
    } else {
        Throw "Invoke-ReviewQueuedTaskSet: Unable to reach Rest server: $RestServer."
    }
    
}
# .\PembrokePSqman\private\Invoke-UpdateQmanData.ps1
function Invoke-UpdateQmanData {
    <#
    .DESCRIPTION
        This function will update a column and field for a Queue_Manager
    .PARAMETER ComponentId
        An ID is required.
    .PARAMETER RestServer
        A Rest Server is required.
    .PARAMETER Column
        A Column/Field is required.
    .PARAMETER Value
        A Value is required.
    .EXAMPLE
        Invoke-UpdateQmanData -ComponentId 1 -RestServer localhost -Column STATUS_ID -Value 2
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([hashtable])]
    param(
        [Parameter(Mandatory=$true)][int]$ComponentId,
        [Parameter(Mandatory=$true)][string]$RestServer,
        [Parameter(Mandatory=$true)][string]$Column,
        [Parameter(Mandatory=$true)][string]$Value
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            Write-LogLevel -Message "Updating the Queue_Manager -Column $Column -Value $Value" -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel TRACE
            if ((Invoke-UpdateComponent -ComponentId $ComponentId -RestServer $RestServer -Column $Column -Value $Value -ComponentType queue_manager) -eq 1) {
                # Good To go
            } else {
                Write-LogLevel -Message "Unable to update Queue Manager via restcall." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel TRACE
                Throw "Unable to update Qman data."
            }
        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Invoke-UpdateQmanData: $ErrorMessage $FailedItem"
        }
    } else {
        Throw "Invoke-UpdateQmanData: Unable to reach Rest server: $RestServer."
    }
    
}
Write-Verbose 'Importing from [C:\projects\pembrokepsqman\PembrokePSqman\public]'
# .\PembrokePSqman\public\Invoke-DeployQman.ps1
function Invoke-DeployQman
{
    <#
    .DESCRIPTION
        Deploys artifacts to prepare a machine to run a PembrokePS Queue Manager.
    .PARAMETER Destination
        A Destitnation path is optional.
    .PARAMETER Source
        A Source location for PembrokePS artifacts is optional.
    .EXAMPLE
        Invoke-DeployQman -Destination c:\PembrokePS -Source c:\OpenProjects\ProjectPembroke\PembrokePSqman
    .NOTES
        It will create the directory if it does not exist. Also install required Modules.
    #>

    [CmdletBinding()]
    [OutputType([boolean])]
    param(
        [String]$Destination="C:\PembrokePS\",
        [String]$Source=(Split-Path -Path (Get-Module -ListAvailable PembrokePSqman).path)
    )
    try
    {
        if(Test-Path -Path "$Destination\qman") {
            Write-LogLevel -Message "The Qman Directory exists." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel CONSOLEONLY
        } else {
            Write-LogLevel -Message "Creating '\qman\data' and '\qman\logs' Directories." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel CONSOLEONLY
            New-Item -Path "$Destination\qman\data" -ItemType Directory
            New-Item -Path "$Destination\qman\logs" -ItemType Directory
        }
        Write-LogLevel -Message "Installing Required Modules." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel CONSOLEONLY
        Install-Module -Name PembrokePSrest,PembrokePSutilities,PowerLumber,RestPS -Force
        Import-Module -Name PembrokePSrest,PembrokePSutilities,PowerLumber,RestPS -Force
        Write-LogLevel -Message "Creating Rest Directory Set." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel CONSOLEONLY
        Invoke-CreateRouteDirectorySet -InstallDirectory "$Destination\Qman\rest"
        Write-LogLevel -Message "Copying Default Properties file to Qman\data Directory." -Logfile "$LOG_FILE" -RunLogLevel $RunLogLevel -MsgLevel CONSOLEONLY
        Copy-Item -Path "$Source\data\pembrokeps.properties" -Destination "$Destination\qman\data" -Confirm:$false       
    }
    catch
    {
        $ErrorMessage = $_.Exception.Message
        $FailedItem = $_.Exception.ItemName        
        Throw "Invoke-DeployQman: $ErrorMessage $FailedItem"
    }

}
# .\PembrokePSqman\public\Invoke-RegisterQman.ps1
function Invoke-RegisterQman {
    <#
    .DESCRIPTION
        This function will gather Status information from PembrokePS web/rest for a Queue_Manager
    .PARAMETER RestServer
        A Rest Server is required.
    .EXAMPLE
        Invoke-RegisterQman -RestServer -localhost
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding()]
    [OutputType([hashtable])]
    param(
        [Parameter(Mandatory=$true)][string]$RestServer
            # Update the Parameters
                # RestServer Required
                # ComponentType By Name (Required)
                # Description (Required)
                # Desired Port (Optional)
                # Hostname (Optional)
                # IP (Optional)
                # Wait
                # LogFile (Optional)
                # Kicker Port (Optional)
    )
    if (Test-Connection -Count 1 $RestServer -Quiet) {
        try
        {
            #Going to be creating a new record here, need to figure out the 'joins' to ensure the data is good.
            Write-Output "This function is not complete!"
            # if ports were specified
                # Check to see if the requested ports are available
                # if not, see if any are available
                    #if not, create the next ones

            # Build up the rest call to add the row

            # Write the local Properties file with all of the information used to create the row.

        }
        catch
        {
            $ErrorMessage = $_.Exception.Message
            $FailedItem = $_.Exception.ItemName        
            Throw "Invoke-RegisterQman: $ErrorMessage $FailedItem"
        }
        #$QmanStatusData
    } else {
        Throw "Unable to reach Rest server: $RestServer."
    }
    
}
# .\PembrokePSqman\public\Start-Qman.ps1
function Start-Qman {
    <#
    .DESCRIPTION
        This function will gather Status information from PembrokePS web/rest for a Queue_Manager
    .PARAMETER RestServer
        A Rest Server is required.
    .EXAMPLE
        Start-Qman -RestServer localhost
    .NOTES
        This will return a hashtable of data from the PPS database.
    #>

    [CmdletBinding(
        SupportsShouldProcess = $true,
        ConfirmImpact = "Low"
    )]
    [OutputType([hashtable])]
    [OutputType([Boolean])]
    param(
        [Parameter(Mandatory=$true)][string]$RestServer
    )
    begin {
        if (Test-Connection -Count 1 $RestServer -Quiet) {
            # Gather the local properties
        } else {
            Throw "Unable to reach web server."
        }
    }
    process
    {
        if ($pscmdlet.ShouldProcess("PembrokePSQman"))
        {
            try
            {
                #Going to be creating a new record here, need to figure out the 'joins' to ensure the data is good.
                Write-Output "This function is not complete!"
                # Validate properties file exists
                # Import all the data.
                # Validate system.RestServer
                # Start Kicker process
                # Start Rest Service (and kicker rest)
            }
            catch
            {
                $ErrorMessage = $_.Exception.Message
                $FailedItem = $_.Exception.ItemName        
                Throw "Start-Qman: $ErrorMessage $FailedItem"
            }
        }
        else
        {
            # -WhatIf was used.
            return $false
        }
    }
    
}
Write-Verbose 'Importing from [C:\projects\pembrokepsqman\PembrokePSqman\classes]'