AQTools.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
<#
    .NOTES
    --------------------------------------------------------------------------------
     Code generated by: SAPIEN Technologies, Inc., PowerShell Studio 2019 v5.6.167
     Generated on: 9/28/2019 4:34 PM
     Generated by: Craig Moore (McMurdo Sr Systems Administrator)
     Organization: United States Antarctic Program
    --------------------------------------------------------------------------------
    .DESCRIPTION
        Script generated by PowerShell Studio 2019
#>



    <#
        ===========================================================================
         Created on: 9/28/2019 1:27 PM
         Created by: Craig Moore (McMurdo Sr Systems Administrator)
         Organization: United States Antarctic Program
         Filename: AQTools.psm1
        -------------------------------------------------------------------------
         Module Name: AQTools
        ===========================================================================
    #>

    
    <#
        .EXTERNALHELP AQTools.psm1-Help.xml
    #>

    function Get-MCMListDocumentation
    {
        [CmdletBinding(DefaultParameterSetName = 'None')]
        [OutputType([System.IO.File], ParameterSetName = 'None')]
        [OutputType([System.IO.File], ParameterSetName = 'Logding')]
        [OutputType([System.IO.File], ParameterSetName = 'Operations')]
        [OutputType([System.IO.File], ParameterSetName = 'WorkPhone')]
        [OutputType([System.IO.File], ParameterSetName = 'Pager')]
        param
        (
            [Parameter(Mandatory = $true)]
            [ValidateScript({
                    if ($_ -notmatch "(\.xlsx)")
                    {
                        throw "The file extension must be .xlsx"
                    }
                    return $true
                })]
            [Alias('SaveTo')]
            [System.IO.FileInfo]
            $Path,
            [switch]
            $Show,
            [Parameter(ParameterSetName = 'Logding')]
            [switch]
            $Logding,
            [Parameter(ParameterSetName = 'Operations')]
            [switch]
            $Operations,
            [Parameter(ParameterSetName = 'WorkPhone')]
            [switch]
            $WorkPhone,
            [Parameter(ParameterSetName = 'Pager')]
            [switch]
            $Pager
        )
    
        BEGIN
        {
            # Time
            $Date = Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
            # Cleanup old documentents with the same name.
            $TestPath = Get-Item -Path $Path -ErrorAction SilentlyContinue
            if ($null -ne $TestPath)
            {
                Write-Verbose -Message "Removing $Path"
                Export-Excel -Path $Path -KillExcel
                Remove-Item $Path
            }
            Write-Verbose -Message "Documenting all residents in McMurdo from Active Directory"
        }
        PROCESS
        {
            switch ($PSCmdlet.ParameterSetName)
            {
                "Logding" {
                    $Residents = Get-ADUser -Filter "(extensionAttribute10 -like '*')" -Properties *
                    $Export = $Residents | ForEach-Object {
                        New-Object System.Management.Automation.PSObject -Property @{
                            Name = $_.Name.ToUpper()
                            Dorm = $_.extensionAttribute10
                            Room = $_.extensionAttribute11
                            Phone = $_.extensionAttribute12
                            DaySleeper = $_.employeeType
                            Title = $_.title
                        }
                    }
                    # Master List
                    $Dorm = "Lodging"
                    $Document = $Export | Select-Object Name, Dorm, Room, Phone, DaySleeper, Title | Sort-Object Name | Export-Excel -Path $Path -TableName "MCM_$Dorm" -AutoSize -ClearSheet -FreezePane 3 -TableStyle Medium16 -Title "All McMurdo Lodging- Last Updated $Date" -TitleBold -TitleSize 20 -WorksheetName $Dorm -ErrorAction SilentlyContinue -PassThru
                    # Format the sheet
                    # Title Row 1
                    $Document.Workbook.Worksheets[$Dorm].Row(1).Merged = $true
                    $Document.Workbook.Worksheets[$Dorm].Row(1).Height = 25.0
                    # Colunm 1 (Name)
                    $Document.Workbook.Worksheets[$Dorm].Column(1).style.font.bold = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(1).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(1).width = 40.0
                    # Colunm 2 (Dorm)
                    $Document.Workbook.Worksheets[$Dorm].Column(2).width = 14.0
                    $Document.Workbook.Worksheets[$Dorm].Column(2).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(2).Style.HorizontalAlignment = "Center"
                    # Colunm 3 (Room)
                    $Document.Workbook.Worksheets[$Dorm].Column(3).width = 14.0
                    $Document.Workbook.Worksheets[$Dorm].Column(3).Style.wraptext = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(3).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(3).Style.HorizontalAlignment = "Center"
                    # Colunm 4 (Phone)
                    $Document.Workbook.Worksheets[$Dorm].Column(4).width = 14.0
                    $Document.Workbook.Worksheets[$Dorm].Column(4).Style.wraptext = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(4).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(4).Style.HorizontalAlignment = "Center"
                    # Colunm 5 (DaySleeper)
                    $Document.Workbook.Worksheets[$Dorm].Column(5).width = 14.0
                    $Document.Workbook.Worksheets[$Dorm].Column(5).Style.wraptext = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(5).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(5).Style.HorizontalAlignment = "Center"
                    # Colunm 6 (Title)
                    $Document.Workbook.Worksheets[$Dorm].Column(6).Style.VerticalAlignment = "Top"
                    # Save formatting
                    $Document.Save()
                    $Document.Dispose()
    
                    # Each Dorm
                    $Dorms = "155", "166", "188", "201", "202", "203A", "203B", "203C", "206", "207", "208", "209", "210", "211"
                    # For empty dorms
                    $Empty = "THERE ARE NO RESIDENTS ASSIGNED TO THIS DORM"
                    foreach ($Dorm in $Dorms)
                    {
                        # Gather basic information
                        Write-Verbose -Message "Dorm $Dorm"
                        $Residents = Get-ADUser -Filter "(extensionAttribute10 -like '$Dorm')" -Properties *
    
                        if ($null -eq $Residents)
                        {
                            Write-Verbose -Message " Dorm is empty"
                            $Empty | Export-Excel -Path $Path -TableName "MCM_$Dorm" -AutoSize -ClearSheet -FreezePane 3 -TableStyle Dark3 -Title "Dorm $Dorm - Last Updated $Date" -TitleBold -TitleSize 20 -WorksheetName $Dorm -ErrorAction SilentlyContinue
                        }
                        else
                        {
                            # Gather basic information
                            $Date = Get-Date
                            Write-Verbose -Message " Documenting Dorm"
                            $Export = $Residents | ForEach-Object {
                                New-Object System.Management.Automation.PSObject -Property @{
                                    Name = $_.Name.ToUpper()
                                    Dorm = $_.extensionAttribute10
                                    Room = $_.extensionAttribute11
                                    Phone = $_.extensionAttribute12
                                    DaySleeper = $_.employeeType
                                    Title = $_.title
                                }
                            }
                            $Document = $Export | Select-Object Name, Dorm, Room, Phone, DaySleeper, Title | Sort-Object Room | Export-Excel -Path $Path -TableName "MCM_$Dorm" -AutoSize -ClearSheet -FreezePane 3 -TableStyle Medium16 -Title "Dorm $Dorm - Last Updated $Date" -TitleBold -TitleSize 20 -WorksheetName $Dorm -ErrorAction SilentlyContinue -PassThru
                            # Format the sheet
                            # Title Row 1
                            $Document.Workbook.Worksheets[$Dorm].Row(1).Merged = $true
                            $Document.Workbook.Worksheets[$Dorm].Row(1).Height = 25.0
                            # Colunm 1 (Name)
                            $Document.Workbook.Worksheets[$Dorm].Column(1).style.font.bold = $true
                            $Document.Workbook.Worksheets[$Dorm].Column(1).Style.VerticalAlignment = "Top"
                            $Document.Workbook.Worksheets[$Dorm].Column(1).width = 40.0
                            # Colunm 2 (Dorm)
                            $Document.Workbook.Worksheets[$Dorm].Column(2).width = 14.0
                            $Document.Workbook.Worksheets[$Dorm].Column(2).Style.VerticalAlignment = "Top"
                            $Document.Workbook.Worksheets[$Dorm].Column(2).Style.HorizontalAlignment = "Center"
                            # Colunm 3 (Room)
                            $Document.Workbook.Worksheets[$Dorm].Column(3).width = 14.0
                            $Document.Workbook.Worksheets[$Dorm].Column(3).Style.wraptext = $true
                            $Document.Workbook.Worksheets[$Dorm].Column(3).Style.VerticalAlignment = "Top"
                            $Document.Workbook.Worksheets[$Dorm].Column(3).Style.HorizontalAlignment = "Center"
                            # Colunm 4 (Phone)
                            $Document.Workbook.Worksheets[$Dorm].Column(4).width = 14.0
                            $Document.Workbook.Worksheets[$Dorm].Column(4).Style.wraptext = $true
                            $Document.Workbook.Worksheets[$Dorm].Column(4).Style.VerticalAlignment = "Top"
                            $Document.Workbook.Worksheets[$Dorm].Column(4).Style.HorizontalAlignment = "Center"
                            # Colunm 5 (DaySleeper)
                            $Document.Workbook.Worksheets[$Dorm].Column(5).width = 14.0
                            $Document.Workbook.Worksheets[$Dorm].Column(5).Style.wraptext = $true
                            $Document.Workbook.Worksheets[$Dorm].Column(5).Style.VerticalAlignment = "Top"
                            $Document.Workbook.Worksheets[$Dorm].Column(5).Style.HorizontalAlignment = "Center"
                            # Colunm 6 (Title)
                            $Document.Workbook.Worksheets[$Dorm].Column(6).Style.VerticalAlignment = "Top"
                            # Save formatting
                            $Document.Save()
                            $Document.Dispose()
                        }
                    }
                }
                "Operations" {
                    $Residents = Get-ADUser -Filter { extensionAttribute10 -like '*' -and (pager -like '*' -or facsimileTelephoneNumber -like '4*') } -Properties *
                    Write-Verbose -Message "Documenting all residents in McMurdo from Active Directory"
                    $Export = $Residents | ForEach-Object {
                        New-Object System.Management.Automation.PSObject -Property @{
                            Name = $_.Name.ToUpper()
                            Title = $_.title
                            Pager = $_.pager
                            WorkPhone = $_.facsimileTelephoneNumber
                        }
                    }
                    # Master List
                    $Dorm = "Operations"
                    $Document = $Export | Select-Object Name, Pager, WorkPhone, Title | Sort-Object Name | Export-Excel -Path $Path -TableName "MCM_$Dorm" -AutoSize -ClearSheet -FreezePane 3 -TableStyle Medium16 -Title "All McMurdo Operations - Last Updated $Date" -TitleBold -TitleSize 20 -WorksheetName $Dorm -ErrorAction SilentlyContinue -PassThru
                    # Format the sheet
                    # Title Row 1
                    $Document.Workbook.Worksheets[$Dorm].Row(1).Merged = $true
                    $Document.Workbook.Worksheets[$Dorm].Row(1).Height = 25.0
                    # Colunm 1 (Name)
                    $Document.Workbook.Worksheets[$Dorm].Column(1).style.font.bold = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(1).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(1).width = 40.0
                    # Colunm 2 (Pager)
                    $Document.Workbook.Worksheets[$Dorm].Column(2).width = 14.0
                    $Document.Workbook.Worksheets[$Dorm].Column(2).Style.wraptext = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(2).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(2).Style.HorizontalAlignment = "Center"
                    # Colunm 3 (WorkPhone)
                    $Document.Workbook.Worksheets[$Dorm].Column(3).width = 14.0
                    $Document.Workbook.Worksheets[$Dorm].Column(3).Style.wraptext = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(3).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(3).Style.HorizontalAlignment = "Center"
                    # Colunm 4 (Title)
                    $Document.Workbook.Worksheets[$Dorm].Column(4).Style.VerticalAlignment = "Top"
                    # Save formatting
                    $Document.Save()
                    $Document.Dispose()
                }
                "WorkPhone" {
                    $Residents = Get-ADUser -Filter { extensionAttribute10 -like '*' -and (pager -like '*' -or facsimileTelephoneNumber -like '4*') } -Properties *
                    Write-Verbose -Message "Documenting all residents in McMurdo from Active Directory"
                    $Export = $Residents | ForEach-Object {
                        New-Object System.Management.Automation.PSObject -Property @{
                            Name = $_.Name.ToUpper()
                            Title = $_.title
                            WorkPhone = $_.facsimileTelephoneNumber
                        }
                    }
                    # Master List
                    $Dorm = "WorkPhone"
                    $Document = $Export | Select-Object Name, WorkPhone, Title | Sort-Object Name | Export-Excel -Path $Path -TableName "MCM_$Dorm" -AutoSize -ClearSheet -FreezePane 3 -TableStyle Medium16 -Title "All McMurdo Work Phones - Last Updated $Date" -TitleBold -TitleSize 20 -WorksheetName $Dorm -ErrorAction SilentlyContinue -PassThru
                    # Format the sheet
                    # Title Row 1
                    $Document.Workbook.Worksheets[$Dorm].Row(1).Merged = $true
                    $Document.Workbook.Worksheets[$Dorm].Row(1).Height = 25.0
                    # Colunm 1 (Name)
                    $Document.Workbook.Worksheets[$Dorm].Column(1).style.font.bold = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(1).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(1).width = 40.0
                    # Colunm 2 (WorkPhone)
                    $Document.Workbook.Worksheets[$Dorm].Column(2).width = 14.0
                    $Document.Workbook.Worksheets[$Dorm].Column(2).Style.wraptext = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(2).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(2).Style.HorizontalAlignment = "Center"
                    # Colunm 3 (Title)
                    $Document.Workbook.Worksheets[$Dorm].Column(3).Style.VerticalAlignment = "Top"
                    # Save formatting
                    $Document.Save()
                    $Document.Dispose()
                }
                "Pager" {
                    $Residents = Get-ADUser -Filter { extensionAttribute10 -like '*' -and (pager -like '*' -or facsimileTelephoneNumber -like '4*') } -Properties *
                    Write-Verbose -Message "Documenting all residents in McMurdo from Active Directory"
                    $Export = $Residents | ForEach-Object {
                        New-Object System.Management.Automation.PSObject -Property @{
                            Name = $_.Name.ToUpper()
                            Title = $_.title
                            Pager = $_.pager
                        }
                    }
                    # Master List
                    $Dorm = "Pager"
                    $Document = $Export | Select-Object Name, Pager, Title | Sort-Object Name | Export-Excel -Path $Path -TableName "MCM_$Dorm" -AutoSize -ClearSheet -FreezePane 3 -TableStyle Medium16 -Title "All McMurdo Pagers - Last Updated $Date" -TitleBold -TitleSize 20 -WorksheetName $Dorm -ErrorAction SilentlyContinue -PassThru
                    # Format the sheet
                    # Title Row 1
                    $Document.Workbook.Worksheets[$Dorm].Row(1).Merged = $true
                    $Document.Workbook.Worksheets[$Dorm].Row(1).Height = 25.0
                    # Colunm 1 (Name)
                    $Document.Workbook.Worksheets[$Dorm].Column(1).style.font.bold = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(1).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(1).width = 40.0
                    # Colunm 2 (Pager)
                    $Document.Workbook.Worksheets[$Dorm].Column(2).width = 14.0
                    $Document.Workbook.Worksheets[$Dorm].Column(2).Style.wraptext = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(2).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(2).Style.HorizontalAlignment = "Center"
                    # Colunm 4 (Title)
                    $Document.Workbook.Worksheets[$Dorm].Column(3).Style.VerticalAlignment = "Top"
                    # Save formatting
                    $Document.Save()
                    $Document.Dispose()
                }
                default {
                    # Master List
                    $Residents = Get-ADUser -Filter "(extensionAttribute10 -like '*')" -Properties *
                    $Export = $Residents | ForEach-Object {
                        New-Object System.Management.Automation.PSObject -Property @{
                            Name = $_.Name.ToUpper()
                            Dorm = $_.extensionAttribute10
                            Room = $_.extensionAttribute11
                            Phone = $_.extensionAttribute12
                            DaySleeper = $_.employeeType
                            Pager = $_.pager
                            WorkPhone = $_.facsimileTelephoneNumber
                            Title = $_.title
                        }
                    }
                    $Dorm = "All"
                    $Document = $Export | Select-Object Name, Dorm, Room, Phone, DaySleeper, Pager, WorkPhone, Title | Sort-Object Name | Export-Excel -Path $Path -TableName "MCM_$Dorm" -AutoSize -ClearSheet -FreezePane 3 -TableStyle Medium16 -Title "All McMurdo - Last Updated $Date" -TitleBold -TitleSize 20 -WorksheetName $Dorm -ErrorAction SilentlyContinue -PassThru
                    # Format the sheet
                    # Title Row 1
                    $Document.Workbook.Worksheets[$Dorm].Row(1).Merged = $true
                    $Document.Workbook.Worksheets[$Dorm].Row(1).Height = 25.0
                    # Colunm 1 (Name)
                    $Document.Workbook.Worksheets[$Dorm].Column(1).style.font.bold = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(1).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(1).width = 40.0
                    # Colunm 2 (Dorm)
                    $Document.Workbook.Worksheets[$Dorm].Column(2).width = 14.0
                    $Document.Workbook.Worksheets[$Dorm].Column(2).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(2).Style.HorizontalAlignment = "Center"
                    # Colunm 3 (Room)
                    $Document.Workbook.Worksheets[$Dorm].Column(3).width = 14.0
                    $Document.Workbook.Worksheets[$Dorm].Column(3).Style.wraptext = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(3).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(3).Style.HorizontalAlignment = "Center"
                    # Colunm 4 (Phone)
                    $Document.Workbook.Worksheets[$Dorm].Column(4).width = 14.0
                    $Document.Workbook.Worksheets[$Dorm].Column(4).Style.wraptext = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(4).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(4).Style.HorizontalAlignment = "Center"
                    # Colunm 5 (DaySleeper)
                    $Document.Workbook.Worksheets[$Dorm].Column(5).width = 14.0
                    $Document.Workbook.Worksheets[$Dorm].Column(5).Style.wraptext = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(5).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(5).Style.HorizontalAlignment = "Center"
                    # Colunm 6 (Pager)
                    $Document.Workbook.Worksheets[$Dorm].Column(6).width = 14.0
                    $Document.Workbook.Worksheets[$Dorm].Column(6).Style.wraptext = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(6).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(6).Style.HorizontalAlignment = "Center"
                    # Colunm 7 (WorkPhone)
                    $Document.Workbook.Worksheets[$Dorm].Column(7).width = 14.0
                    $Document.Workbook.Worksheets[$Dorm].Column(7).Style.wraptext = $true
                    $Document.Workbook.Worksheets[$Dorm].Column(7).Style.VerticalAlignment = "Top"
                    $Document.Workbook.Worksheets[$Dorm].Column(7).Style.HorizontalAlignment = "Center"
                    # Colunm 8 (Title)
                    $Document.Workbook.Worksheets[$Dorm].Column(8).Style.VerticalAlignment = "Top"
                    # Save formatting
                    $Document.Save()
                    $Document.Dispose()
                }
            }
        }
        END
        {
            # Open spredsheet when done
            if ($Show)
            {
                Write-Verbose "Opening document at $Path"
                Invoke-Item $Path
            }
        }
    }
    
    <#
        .EXTERNALHELP AQTools.psm1-Help.xml
             
         
        .PARAMETER Path
            The save location to the .xlsx document. Later to be used by Set-FutureRoom function
    #>

    function Get-FutureList
    {
        [CmdletBinding(DefaultParameterSetName = 'None')]
        [OutputType([System.IO.File], ParameterSetName = 'None')]
        [OutputType([System.IO.File], ParameterSetName = 'Logding')]
        [OutputType([System.IO.File], ParameterSetName = 'Operations')]
        [OutputType([System.IO.File], ParameterSetName = 'WorkPhone')]
        [OutputType([System.IO.File], ParameterSetName = 'Pager')]
        param
        (
            [Parameter(Mandatory = $true,
                       HelpMessage = 'The save location to the .xlsx document. Later to be used by Set-FutureRoom function')]
            [ValidateScript({
                    if ($_ -notmatch "(\.xlsx)")
                    {
                        throw "The file extension must be .xlsx"
                    }
                    return $true
                })]
            [System.IO.FileInfo]
            $Path,
            [switch]
            $Show,
            [Parameter(Mandatory = $true)]
            [array]
            $OU,
            [Parameter(ParameterSetName = 'Logding')]
            [switch]
            $Logding,
            [Parameter(ParameterSetName = 'Operations')]
            [switch]
            $Operations,
            [Parameter(ParameterSetName = 'WorkPhone')]
            [switch]
            $WorkPhone,
            [Parameter(ParameterSetName = 'Pager')]
            [switch]
            $Pager
        )
        
        BEGIN
        {
            # Remove old file
            $TestPath = Get-Item -Path $Path -ErrorAction SilentlyContinue
            if ($null -ne $TestPath)
            {
                Write-Verbose -Message "Removing $Path"
                Export-Excel -Path $Path -KillExcel
                Remove-Item $Path
            }
            $Date = Get-Date -Format "yyyy-mm-dd HH:mm:ss"
            $Residents = Foreach ($OUs in $OU)
            {
                Write-Verbose -Message "Processing $OUs"
                Get-ADUser -Filter { extensionAttribute4 -like "*" } -Properties * -SearchBase $OUs
            }
        }
        PROCESS
        {
            switch ($PSCmdlet.ParameterSetName)
            {
                "Logding" {
                    $Export = $Residents | ForEach-Object {
                        New-Object System.Management.Automation.PSObject -Property @{
                            SamAccountName = $_.SamAccountName
                            Name           = $_.Name.ToUpper()
                            Flight           = $_.extensionAttribute4.ToUpper()
                            Dorm           = $_.extensionAttribute10
                            Room           = $_.extensionAttribute11
                            Phone           = $_.extensionAttribute12
                            DaySleeper       = $_.employeeType
                            Title           = $_.title
                        }
                    }
                    Write-Verbose -Message "Creating $Path"
                    # Create Excel document
                    $Excel = $Export | Select-Object SamAccountName, Name, Flight, Dorm, Room, Phone, DaySleeper, Title | Sort-Object Name | Export-Excel -Path $Path -TableName "FromAD" -AutoSize -ClearSheet -FreezePane 3 -TableStyle Medium20 -Title "Created $Date" -TitleBold -TitleSize 20 -WorksheetName "From_AD" -KillExcel -PassThru
                    # Format the sheet
                    # Row 1 (Title)
                    $Excel.Workbook.Worksheets["From_AD"].Row(1).Merged = $true
                    $Excel.Workbook.Worksheets["From_AD"].Row(1).Height = 25.0
                    # Column 1 (SamAccountName)
                    $Excel.Workbook.Worksheets["From_AD"].Column(1).Hidden = $true
                    # Column 2 (Name)
                    $Excel.Workbook.Worksheets["From_AD"].Column(2).style.font.bold = $true
                    # Column 3 (Flight)
                    $Excel.Workbook.Worksheets["From_AD"].Column(3).Style.HorizontalAlignment = "Center"
                    # Column 4 (Dorm)
                    $Excel.Workbook.Worksheets["From_AD"].Column(4).Style.HorizontalAlignment = "Center"
                    # Column 5 (Room)
                    $Excel.Workbook.Worksheets["From_AD"].Column(5).Style.HorizontalAlignment = "Center"
                    # Column 6 (Phone)
                    $Excel.Workbook.Worksheets["From_AD"].Column(6).Style.HorizontalAlignment = "Center"
                    # Column 7 (DaySleeper)
                    $Excel.Workbook.Worksheets["From_AD"].Column(7).Style.HorizontalAlignment = "Center"
                    # Column 8 (Title)
                    $Excel.Workbook.Worksheets["From_AD"].Column(8).Style.HorizontalAlignment = "Left"
                    # Row 2
                    $Excel.Workbook.Worksheets["From_AD"].Row(2).Style.HorizontalAlignment = "Left"
                    # Save formatting
                    $Excel.Save()
                    $Excel.Dispose()
                }
                "Operations" {
                    $Export = $Residents | ForEach-Object {
                        New-Object System.Management.Automation.PSObject -Property @{
                            SamAccountName = $_.SamAccountName
                            Name           = $_.Name.ToUpper()
                            Flight           = $_.extensionAttribute4.ToUpper()
                            Pager           = $_.pager
                            WorkPhone       = $_.facsimileTelephoneNumber
                            Title           = $_.title
                        }
                    }
                    Write-Verbose -Message "Creating $Path"
                    # Create Excel document
                    $Excel = $Export | Select-Object SamAccountName, Name, Flight, Pager, WorkPhone, Title | Sort-Object Name | Export-Excel -Path $Path -TableName "FromAD" -AutoSize -ClearSheet -FreezePane 3 -TableStyle Medium20 -Title "Created $Date" -TitleBold -TitleSize 20 -WorksheetName "From_AD" -KillExcel -PassThru
                    # Format the sheet
                    # Row 1 (Title)
                    $Excel.Workbook.Worksheets["From_AD"].Row(1).Merged = $true
                    $Excel.Workbook.Worksheets["From_AD"].Row(1).Height = 25.0
                    # Column 1 (SamAccountName)
                    $Excel.Workbook.Worksheets["From_AD"].Column(1).Hidden = $true
                    # Column 2 (Name)
                    $Excel.Workbook.Worksheets["From_AD"].Column(2).style.font.bold = $true
                    # Column 3 (Flight)
                    $Excel.Workbook.Worksheets["From_AD"].Column(3).Style.HorizontalAlignment = "Center"
                    # Column 4 (Pager)
                    $Excel.Workbook.Worksheets["From_AD"].Column(4).Style.HorizontalAlignment = "Center"
                    # Column 5 (WorkPhone)
                    $Excel.Workbook.Worksheets["From_AD"].Column(5).Style.HorizontalAlignment = "Center"
                    # Column 6 (Title)
                    $Excel.Workbook.Worksheets["From_AD"].Column(6).Style.HorizontalAlignment = "Left"
                    # Row 2
                    $Excel.Workbook.Worksheets["From_AD"].Row(2).Style.HorizontalAlignment = "Left"
                    # Save formatting
                    $Excel.Save()
                    $Excel.Dispose()
                }
                "WorkPhone" {
                    $Export = $Residents | ForEach-Object {
                        New-Object System.Management.Automation.PSObject -Property @{
                            SamAccountName = $_.SamAccountName
                            Name           = $_.Name.ToUpper()
                            Flight           = $_.extensionAttribute4.ToUpper()
                            WorkPhone       = $_.facsimileTelephoneNumber
                            Title           = $_.title
                        }
                    }
                    Write-Verbose -Message "Creating $Path"
                    # Create Excel document
                    $Excel = $Export | Select-Object SamAccountName, Name, Flight, WorkPhone, Title | Sort-Object Name | Export-Excel -Path $Path -TableName "FromAD" -AutoSize -ClearSheet -FreezePane 3 -TableStyle Medium20 -Title "Created $Date" -TitleBold -TitleSize 20 -WorksheetName "From_AD" -KillExcel -PassThru
                    # Format the sheet
                    # Row 1 (Title)
                    $Excel.Workbook.Worksheets["From_AD"].Row(1).Merged = $true
                    $Excel.Workbook.Worksheets["From_AD"].Row(1).Height = 25.0
                    # Column 1 (SamAccountName)
                    $Excel.Workbook.Worksheets["From_AD"].Column(1).Hidden = $true
                    # Column 2 (Name)
                    $Excel.Workbook.Worksheets["From_AD"].Column(2).style.font.bold = $true
                    # Column 3 (Flight)
                    $Excel.Workbook.Worksheets["From_AD"].Column(3).Style.HorizontalAlignment = "Center"
                    # Column 4 (WorkPhone)
                    $Excel.Workbook.Worksheets["From_AD"].Column(4).Style.HorizontalAlignment = "Center"
                    # Column 5 (Title)
                    $Excel.Workbook.Worksheets["From_AD"].Column(5).Style.HorizontalAlignment = "Left"
                    # Row 2
                    $Excel.Workbook.Worksheets["From_AD"].Row(2).Style.HorizontalAlignment = "Left"
                    # Save formatting
                    $Excel.Save()
                    $Excel.Dispose()
                }
                "Pager" {
                    $Export = $Residents | ForEach-Object {
                        New-Object System.Management.Automation.PSObject -Property @{
                            SamAccountName = $_.SamAccountName
                            Name           = $_.Name.ToUpper()
                            Flight           = $_.extensionAttribute4.ToUpper()
                            Pager           = $_.pager
                            Title           = $_.title
                        }
                    }
                    Write-Verbose -Message "Creating $Path"
                    # Create Excel document
                    $Excel = $Export | Select-Object SamAccountName, Name, Flight, Pager, Title | Sort-Object Name | Export-Excel -Path $Path -TableName "FromAD" -AutoSize -ClearSheet -FreezePane 3 -TableStyle Medium20 -Title "Created $Date" -TitleBold -TitleSize 20 -WorksheetName "From_AD" -KillExcel -PassThru
                    # Format the sheet
                    # Row 1 (Title)
                    $Excel.Workbook.Worksheets["From_AD"].Row(1).Merged = $true
                    $Excel.Workbook.Worksheets["From_AD"].Row(1).Height = 25.0
                    # Column 1 (SamAccountName)
                    $Excel.Workbook.Worksheets["From_AD"].Column(1).Hidden = $true
                    # Column 2 (Name)
                    $Excel.Workbook.Worksheets["From_AD"].Column(2).style.font.bold = $true
                    # Column 3 (Flight)
                    $Excel.Workbook.Worksheets["From_AD"].Column(3).Style.HorizontalAlignment = "Center"
                    # Column 4 (Pager)
                    $Excel.Workbook.Worksheets["From_AD"].Column(4).Style.HorizontalAlignment = "Center"
                    # Column 5 (Title)
                    $Excel.Workbook.Worksheets["From_AD"].Column(5).Style.HorizontalAlignment = "Left"
                    # Row 2
                    $Excel.Workbook.Worksheets["From_AD"].Row(2).Style.HorizontalAlignment = "Left"
                    # Save formatting
                    $Excel.Save()
                    $Excel.Dispose()
                }
                default {
                    $Export = $Residents | ForEach-Object {
                        New-Object System.Management.Automation.PSObject -Property @{
                            SamAccountName = $_.SamAccountName
                            Name           = $_.Name.ToUpper()
                            Flight           = $_.extensionAttribute4.ToUpper()
                            Dorm           = $_.extensionAttribute10
                            Room           = $_.extensionAttribute11
                            Phone           = $_.extensionAttribute12
                            DaySleeper       = $_.employeeType
                            Title           = $_.title
                            Pager           = $_.pager
                            WorkPhone       = $_.facsimileTelephoneNumber
                        }
                    }
                    Write-Verbose -Message "Creating $Path"
                    # Create Excel document
                    $Excel = $Export | Select-Object SamAccountName, Name, Flight, Dorm, Room, Phone, DaySleeper, Pager, WorkPhone, Title | Sort-Object Name | Export-Excel -Path $Path -TableName "FromAD" -AutoSize -ClearSheet -FreezePane 3 -TableStyle Medium20 -Title "Created $Date" -TitleBold -TitleSize 20 -WorksheetName "From_AD" -KillExcel -PassThru
                    # Format the sheet
                    # Row 1 (Title)
                    $Excel.Workbook.Worksheets["From_AD"].Row(1).Merged = $true
                    $Excel.Workbook.Worksheets["From_AD"].Row(1).Height = 25.0
                    # Column 1 (SamAccountName)
                    $Excel.Workbook.Worksheets["From_AD"].Column(1).Hidden = $true
                    # Column 2 (Name)
                    $Excel.Workbook.Worksheets["From_AD"].Column(2).style.font.bold = $true
                    # Column 3 (Flight)
                    $Excel.Workbook.Worksheets["From_AD"].Column(3).Style.HorizontalAlignment = "Center"
                    # Column 4 (Dorm)
                    $Excel.Workbook.Worksheets["From_AD"].Column(4).Style.HorizontalAlignment = "Center"
                    # Column 5 (Room)
                    $Excel.Workbook.Worksheets["From_AD"].Column(5).Style.HorizontalAlignment = "Center"
                    # Column 6 (Phone)
                    $Excel.Workbook.Worksheets["From_AD"].Column(6).Style.HorizontalAlignment = "Center"
                    # Column 7 (DaySleeper)
                    $Excel.Workbook.Worksheets["From_AD"].Column(7).Style.HorizontalAlignment = "Center"
                    # Column 8 (Pager)
                    $Excel.Workbook.Worksheets["From_AD"].Column(8).Style.HorizontalAlignment = "Center"
                    # Column 9 (WorkPhone)
                    $Excel.Workbook.Worksheets["From_AD"].Column(9).Style.HorizontalAlignment = "Center"
                    # Column 10 (Title)
                    $Excel.Workbook.Worksheets["From_AD"].Column(10).Style.HorizontalAlignment = "Left"
                    # Row 2
                    $Excel.Workbook.Worksheets["From_AD"].Row(2).Style.HorizontalAlignment = "Left"
                    # Save formatting
                    $Excel.Save()
                    $Excel.Dispose()
                }
            }
        }
        END
        {
            # Open spredsheet when done
            if ($Show)
            {
                Write-Verbose -Message "Open $Path"
                Invoke-Item $Path
            }
        }
    }
    
    <#
        .EXTERNALHELP AQTools.psm1-Help.xml
    #>

    function Set-FutureList
    {
        [CmdletBinding(DefaultParameterSetName = 'None')]
        param
        (
            [Parameter(Mandatory = $true,
                       HelpMessage = 'Path to the Excel document created by Get-FutureRoom.')]
            [ValidateScript({
                    if ($_ -notmatch "(\.xlsx)")
                    {
                        throw "The file extension must be .xlsx"
                    }
                    return $true
                })]
            [System.IO.FileInfo]
            $Path,
            [Parameter(ParameterSetName = 'Logding')]
            [switch]
            $Logding,
            [Parameter(ParameterSetName = 'Operations')]
            [switch]
            $Operations,
            [Parameter(ParameterSetName = 'WorkPhone')]
            [switch]
            $WorkPhone,
            [Parameter(ParameterSetName = 'Pager')]
            [switch]
            $Pager,
            [switch]
            $Force
        )
    
        switch ($PSCmdlet.ParameterSetName)
        {
            "Operations" {
                Import-Excel -Path $Path -StartRow 2 | ForEach-Object {
                    $User = $_.SamAccountName
                    $Display = $_.Name
                    Write-Verbose -Message "$($Display)"
                    # Remove Operations attributes cleared on Excel Document
                    if ([string]::IsNullOrEmpty($_.Pager))
                    {
                        Set-ADUser -Identity $User -Clear "Pager"
                        Write-Verbose -Message " Clear Pager"
                    }
                    if ([string]::IsNullOrEmpty($_.WorkPhone))
                    {
                        Set-ADUser -Identity $User -Clear "facsimileTelephoneNumber"
                        Write-Verbose -Message " Clear WorkPhone"
                    }
                    # Adding Operations attributes created in the Excel document
                    if (-not ([string]::IsNullOrEmpty($_.Pager)))
                    {
                        Set-ADUser -Identity $User -Replace @{ pager = "$($_.Pager)" }
                        Write-Verbose -Message " Add Pager"
                    }
                    if (-not ([string]::IsNullOrEmpty($_.WorkPhone)))
                    {
                        Set-ADUser -Identity $User -Replace @{ facsimileTelephoneNumber = "$($_.WorkPhone)" }
                        Write-Verbose -Message " Add WorkPhone"
                    }
                }
            }
            "WorkPhone" {
                Import-Excel -Path $Path -StartRow 2 | ForEach-Object {
                    $User = $_.SamAccountName
                    $Display = $_.Name
                    Write-Verbose -Message "$($Display)"
                    # Remove Operations attributes cleared on Excel Document
                    if ([string]::IsNullOrEmpty($_.WorkPhone))
                    {
                        Set-ADUser -Identity $User -Clear "facsimileTelephoneNumber"
                        Write-Verbose -Message " Clear WorkPhone"
                    }
                    # Adding Operations attributes created in the Excel document
                    if (-not ([string]::IsNullOrEmpty($_.WorkPhone)))
                    {
                        Set-ADUser -Identity $User -Replace @{ facsimileTelephoneNumber = "$($_.WorkPhone)" }
                        Write-Verbose -Message " Add WorkPhone"
                    }
                }
            }
            "Pager" {
                Import-Excel -Path $Path -StartRow 2 | ForEach-Object {
                    $User = $_.SamAccountName
                    $Display = $_.Name
                    Write-Verbose -Message "$($Display)"
                    # Remove Operations attributes cleared on Excel Document
                    if ([string]::IsNullOrEmpty($_.Pager))
                    {
                        Set-ADUser -Identity $User -Clear "Pager"
                        Write-Verbose -Message " Clear Pager"
                    }
                    # Adding Operations attributes created in the Excel document
                    if (-not ([string]::IsNullOrEmpty($_.Pager)))
                    {
                        Set-ADUser -Identity $User -Replace @{ pager = "$($_.Pager)" }
                        Write-Verbose -Message " Add Pager"
                    }
                }
            }
            "Logding" {
                Import-Excel -Path $Path -StartRow 2 | ForEach-Object {
                    $User = $_.SamAccountName
                    $Display = $_.Name
                    Write-Verbose -Message "$($Display)"
                    # Remove Lodging attributes cleared on Excel Document
                    if ([string]::IsNullOrEmpty($_.Dorm))
                    {
                        Set-ADUser -Identity $User -Clear "extensionAttribute10"
                        Write-Verbose -Message " Clear Dorm"
                    }
                    if ([string]::IsNullOrEmpty($_.Room))
                    {
                        Set-ADUser -Identity $User -Clear "extensionAttribute11"
                        Write-Verbose -Message " Clear Room"
                    }
                    if ([string]::IsNullOrEmpty($_.Phone))
                    {
                        Set-ADUser -Identity $User -Clear "extensionAttribute12"
                        Write-Verbose -Message " Clear Phone"
                    }
                    if ([string]::IsNullOrEmpty($_.DaySleeper))
                    {
                        Set-ADUser -Identity $User -Clear "employeeType"
                        Write-Verbose -Message " Clear DaySleeper"
                    }
                    # Adding Lodging attributes created in the Excel document
                    if (-not ([string]::IsNullOrEmpty($_.Dorm)))
                    {
                        Set-ADUser -Identity $User -Replace @{ extensionAttribute10 = "$($_.Dorm)" }
                        Write-Verbose -Message " Add Dorm"
                    }
                    if (-not ([string]::IsNullOrEmpty($_.Room)))
                    {
                        Set-ADUser -Identity $User -Replace @{ extensionAttribute11 = "$($_.Room)" }
                        Write-Verbose -Message " Add Room"
                    }
                    if (-not ([string]::IsNullOrEmpty($_.Phone)))
                    {
                        Set-ADUser -Identity $User -Replace @{ extensionAttribute12 = "$($_.Phone)" }
                        Write-Verbose -Message " Add Phone"
                    }
                    if (-not ([string]::IsNullOrEmpty($_.DaySleeper)))
                    {
                        Set-ADUser -Identity $User -Replace @{ employeeType = "$($_.DaySleeper)" }
                        Write-Verbose -Message " Add DaySleeper"
                    }
                }
            }
            default {
                Import-Excel -Path $Path -StartRow 2 | ForEach-Object {
                    $User = $_.SamAccountName
                    $Display = $_.Name
                    Write-Verbose -Message "$($Display)"
                    # Remove attributes cleared on Excel Document
                    if ([string]::IsNullOrEmpty($_.Dorm))
                    {
                        Set-ADUser -Identity $User -Clear "extensionAttribute10"
                        Write-Verbose -Message " Clear Dorm"
                    }
                    if ([string]::IsNullOrEmpty($_.Room))
                    {
                        Set-ADUser -Identity $User -Clear "extensionAttribute11"
                        Write-Verbose -Message " Clear Room"
                    }
                    if ([string]::IsNullOrEmpty($_.Phone))
                    {
                        Set-ADUser -Identity $User -Clear "extensionAttribute12"
                        Write-Verbose -Message " Clear Phone"
                    }
                    if ([string]::IsNullOrEmpty($_.DaySleeper))
                    {
                        Set-ADUser -Identity $User -Clear "employeeType"
                        Write-Verbose -Message " Clear DaySleeper"
                    }
                    if ([string]::IsNullOrEmpty($_.Pager))
                    {
                        Set-ADUser -Identity $User -Clear "Pager"
                        Write-Verbose -Message " Clear Pager"
                    }
                    if ([string]::IsNullOrEmpty($_.WorkPhone))
                    {
                        Set-ADUser -Identity $User -Clear "facsimileTelephoneNumber"
                        Write-Verbose -Message " Clear WorkPhone"
                    }
                    # Adding attributes created in the Excel document
                    if (-not ([string]::IsNullOrEmpty($_.Dorm)))
                    {
                        Set-ADUser -Identity $User -Replace @{ extensionAttribute10 = "$($_.Dorm)" }
                        Write-Verbose -Message " Add Dorm"
                    }
                    if (-not ([string]::IsNullOrEmpty($_.Room)))
                    {
                        Set-ADUser -Identity $User -Replace @{ extensionAttribute11 = "$($_.Room)" }
                        Write-Verbose -Message " Add Room"
                    }
                    if (-not ([string]::IsNullOrEmpty($_.Phone)))
                    {
                        Set-ADUser -Identity $User -Replace @{ extensionAttribute12 = "$($_.Phone)" }
                        Write-Verbose -Message " Add Phone"
                    }
                    if (-not ([string]::IsNullOrEmpty($_.DaySleeper)))
                    {
                        Set-ADUser -Identity $User -Replace @{ employeeType = "$($_.DaySleeper)" }
                        Write-Verbose -Message " Add DaySleeper"
                    }
                    if (-not ([string]::IsNullOrEmpty($_.Pager)))
                    {
                        Set-ADUser -Identity $User -Replace @{ pager = "$($_.Pager)" }
                        Write-Verbose -Message " Add Pager"
                    }
                    if (-not ([string]::IsNullOrEmpty($_.WorkPhone)))
                    {
                        Set-ADUser -Identity $User -Replace @{ facsimileTelephoneNumber = "$($_.WorkPhone)" }
                        Write-Verbose -Message " Add WorkPhone"
                    }
                }
            }
        }
    }