-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1114 lines (1096 loc) · 55.1 KB
/
index.html
File metadata and controls
1114 lines (1096 loc) · 55.1 KB
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
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<!--
<auto-generated>
<synopsis>
This code was generated by a psDoc. on: 10/06/2025 09:44:12
Get it here: https://github.com/ChaseFlorell/psDoc
</synopsis>
<description>
If you'd like to regenerate the documentation, please open up powershell and run
> Import-Module GraphAppToolkit
> .\psDoc.ps1 -moduleName GraphAppToolkit
If the documentation is incomplete, or erroneous, please edit the comments
at the top of the module method within it's respective .ps1 file.
</description>
</auto-generated>
-->
<html lang="en">
<head>
<title>GraphAppToolkit Documentation</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/styles/shCore.min.css" rel="stylesheet" charset="utf-8">
<link href="https://cdnjs.cloudflare.com/ajax/libs/SyntaxHighlighter/3.0.83/styles/shCoreDefault.min.css" rel="stylesheet" charset="utf-8">
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" charset="utf-8">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<style>
.syntaxhighlighter {
overflow-y: hidden !important;
overflow-x: auto !important;
}
pre {
min-height: 30px;
}
.navbar-nav {
height: 100%;
overflow-y: auto;
}
.form-group {
padding-top: 12px;
padding-left: 12px;
padding-right: 12px;
}
.sidebar-nav .navbar-header {
float: none;
}
.sidebar-nav .navbar li a {
padding-top: 4px;
padding-bottom: 4px;
}
@media (min-width: 768px) {
.sidebar-nav .navbar .navbar-collapse {
padding: 0;
max-height: none;
}
.sidebar-nav .navbar ul {
float: none;
}
.sidebar-nav .navbar ul:not {
display: block;
}
.sidebar-nav .navbar li {
float: none;
display: block;
}
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row-fluid">
<div><h1>GraphAppToolkit</h1></div>
</div>
<div class="row-fluid">
<div class="col-lg-3 col-md-4 col-sm-5 col-xs-12">
<div class="sidebar-nav">
<div class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-navbar-collapse">
<span class="sr-only">Toggle</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="visible-xs navbar-brand">click menu to open</span>
</div>
<div class="navbar-collapse collapse sidebar-navbar-collapse">
<div class="form-group">
<input class="form-control" id="searchinput" type="search" placeholder="Filter..." />
</div>
<ul class="nav navbar-nav list-group" id="searchList">
<li class="nav-menu list-group-item"><a href="#New-MailEnabledSendingGroup">New-MailEnabledSendingGroup</a></li>
<li class="nav-menu list-group-item"><a href="#Publish-TkEmailApp">Publish-TkEmailApp</a></li>
<li class="nav-menu list-group-item"><a href="#Publish-TkM365AuditApp">Publish-TkM365AuditApp</a></li>
<li class="nav-menu list-group-item"><a href="#Publish-TkMemPolicyManagerApp">Publish-TkMemPolicyManagerApp</a></li>
<li class="nav-menu list-group-item"><a href="#Send-TkEmailAppMessage">Send-TkEmailAppMessage</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="col-lg-9 col-md-8 col-sm-7 col-xs-12">
<div id="New-MailEnabledSendingGroup" class="toggle_container">
<div class="page-header">
<h2> New-MailEnabledSendingGroup </h2>
<p><p>Creates or retrieves a mail-enabled security group with a custom or default domain.</p>
</p>
<p><p>The New-MailEnabledSendingGroup function ensures that a mail-enabled security group is
available for restricting email sending in Exchange Online. If a group of the specified
name already exists and is security-enabled, the function returns that group. Otherwise,
it creates a new security-enabled distribution group. You can specify either a custom
primary SMTP address (via the 'CustomDomain' parameter set) or construct one using an
alias and default domain (via the 'DefaultDomain' parameter set).
By default, the 'CustomDomain' parameter set is used. If you wish to construct the SMTP
address from the alias, switch to the 'DefaultDomain' parameter set.</p>
</p>
</div>
<div>
<h3> Syntax </h3>
</div>
<div class="panel panel-default">
<div class='panel-body'>
<pre class="brush: ps">New-MailEnabledSendingGroup -Name <String> [-Alias <String>] -PrimarySmtpAddress <String> [-LogOutputPath <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-MailEnabledSendingGroup -Name <String> [-Alias <String>] -DefaultDomain <String> [-LogOutputPath <String>] [-WhatIf] [-Confirm] [<CommonParameters>]</pre>
</div>
</div>
<div>
<h3> Parameters </h3>
<table class="table table-striped table-bordered table-condensed visible-on">
<thead>
<tr>
<th>Name</th>
<th class="visible-lg visible-md">Alias</th>
<th>Description</th>
<th class="visible-lg visible-md">Required?</th>
<th class="visible-lg">Pipeline Input</th>
<th class="visible-lg">Default Value</th>
</tr>
</thead>
<tbody>
<tr>
<td><nobr>-Name</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>The name of the mail-enabled security group to create or retrieve. This is also used as
the alias if no separate Alias parameter is provided.</p>
</td>
<td class="visible-lg visible-md">true</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-Alias</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>An optional alias for the group. If omitted, the group name is used as the alias.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-PrimarySmtpAddress</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>(CustomDomain parameter set) The full SMTP address for the group (e.g. "MyGroup@contoso.com").
This parameter is mandatory when using the 'CustomDomain' parameter set.</p>
</td>
<td class="visible-lg visible-md">true</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-DefaultDomain</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>(DefaultDomain parameter set) The domain portion to be appended to the group alias (e.g.
"Alias@DefaultDomain"). This parameter is mandatory when using the 'DefaultDomain' parameter set.</p>
</td>
<td class="visible-lg visible-md">true</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-LogOutputPath</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>An optional path to output the log file. If not provided, logs will not be written to a file.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-WhatIf</nobr></td>
<td class="visible-lg visible-md">wi</td>
<td></td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-Confirm</nobr></td>
<td class="visible-lg visible-md">cf</td>
<td></td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
</tbody>
</table>
</div>
<div>
<h3> Inputs </h3>
<p>The input type is the type of the objects that you can pipe to the cmdlet.</p>
<ul><li>None. This function does not accept pipeline input.</li></ul>
</div>
<div>
<h3> Outputs </h3>
<p>The output type is the type of the objects that the cmdlet emits.</p>
<ul><li>Microsoft.Exchange.Data.Directory.Management.DistributionGroup
Returns the newly created or existing mail-enabled security group object.</li></ul>
</div>
<div class='panel panel-default'>
<div class='panel-heading'>
<h3 class='panel-title'> Note </h3>
</div>
<div class='panel-body'>- Requires connectivity to Exchange Online (Connect-TkMsService -ExchangeOnline).
- The caller must have sufficient privileges to create or modify distribution groups.
- DefaultParameterSetName = 'CustomDomain'.</div>
</div>
<div>
<h3> Examples </h3>
</div>
<div class='panel panel-default'>
<div class='panel-body'>
<strong>EXAMPLE 1</strong>
<pre class="brush: ps">New-MailEnabledSendingGroup -Name "SecureSenders" -DefaultDomain "contoso.com"
Creates a new mail-enabled security group named "SecureSenders" with a primary SMTP address
of SecureSenders@contoso.com.</pre>
<div></div>
<strong>EXAMPLE 2</strong>
<pre class="brush: ps">New-MailEnabledSendingGroup -Name "SecureSenders" -Alias "Senders" -PrimarySmtpAddress "Senders@customdomain.org"
Creates a new mail-enabled security group named "SecureSenders" with an alias "Senders"
and a primary SMTP address of Senders@customdomain.org.</pre>
<div></div>
</div>
</div>
<p class='pull-right'><a onclick='document.body.scrollTop = document.documentElement.scrollTop = 0;' style='cursor: pointer;'>Top of page</a>
</div>
<div id="Publish-TkEmailApp" class="toggle_container">
<div class="page-header">
<h2> Publish-TkEmailApp </h2>
<p><p>Publishes a new or existing Graph Email App with specified configurations.</p>
</p>
<p><p>The Publish-TkEmailApp function creates or configures a Graph Email App in Azure AD. It supports two scenarios:</p>
<ol>
<li>Creating a new app with specified parameters.</li>
<li>Using an existing app and attaching a certificate to it.</li>
</ol>
</p>
</div>
<div>
<h3> Syntax </h3>
</div>
<div class="panel panel-default">
<div class='panel-body'>
<pre class="brush: ps">Publish-TkEmailApp [-WhatIf] [-Confirm] [<CommonParameters>]
Publish-TkEmailApp [-AppPrefix <String>] -AuthorizedSenderUserName <String> -MailEnabledSendingGroup <String> [-CertPrefix <String>] [-CertThumbprint <String>] [-KeyExportPolicy <String>] [-VaultName <String>] [-OverwriteVaultSecret] [-ReturnParamSplat] [-DoNotUseDomainSuffix] [-LogOutput <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
Publish-TkEmailApp -ExistingAppObjectId <String> -CertPrefix <String> [-CertThumbprint <String>] [-KeyExportPolicy <String>] [-VaultName <String>] [-OverwriteVaultSecret] [-ReturnParamSplat] [-DoNotUseDomainSuffix] [-LogOutput <String>] [-WhatIf] [-Confirm] [<CommonParameters>]</pre>
</div>
</div>
<div>
<h3> Parameters </h3>
<table class="table table-striped table-bordered table-condensed visible-on">
<thead>
<tr>
<th>Name</th>
<th class="visible-lg visible-md">Alias</th>
<th>Description</th>
<th class="visible-lg visible-md">Required?</th>
<th class="visible-lg">Pipeline Input</th>
<th class="visible-lg">Default Value</th>
</tr>
</thead>
<tbody>
<tr>
<td><nobr>-AppPrefix</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>The prefix used to initialize the Graph Email App. Must be 2-4 characters, letters, and numbers only. The default value is 'Gtk'.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">Gtk</td>
</tr>
<tr>
<td><nobr>-AuthorizedSenderUserName</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>The username of the authorized sender. Must be a valid email address.</p>
</td>
<td class="visible-lg visible-md">true</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-MailEnabledSendingGroup</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>The mail-enabled security group. Must be a valid email address.</p>
</td>
<td class="visible-lg visible-md">true</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-ExistingAppObjectId</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>The AppId of the existing App Registration to which you want to attach a certificate. Must be a valid GUID.</p>
</td>
<td class="visible-lg visible-md">true</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-CertPrefix</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>Prefix to add to the certificate subject for the existing app.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-CertThumbprint</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>The thumbprint of the certificate to be retrieved. Must be a valid 40-character hexadecimal string.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-KeyExportPolicy</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>Key export policy for the certificate. Valid values are 'Exportable' and 'NonExportable'. The default value is 'NonExportable'.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">NonExportable</td>
</tr>
<tr>
<td><nobr>-VaultName</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>If specified, use a custom vault name. Otherwise, use the default 'GraphEmailAppLocalStore'.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">GraphEmailAppLocalStore</td>
</tr>
<tr>
<td><nobr>-OverwriteVaultSecret</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>If specified, overwrite the vault secret if it already exists.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">False</td>
</tr>
<tr>
<td><nobr>-ReturnParamSplat</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>If specified, return the parameter splat for use in other functions.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">False</td>
</tr>
<tr>
<td><nobr>-DoNotUseDomainSuffix</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>Switch to add session domain suffix to the app name.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">False</td>
</tr>
<tr>
<td><nobr>-LogOutput</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>If specified, log the output to the console.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-WhatIf</nobr></td>
<td class="visible-lg visible-md">wi</td>
<td></td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-Confirm</nobr></td>
<td class="visible-lg visible-md">cf</td>
<td></td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
</tbody>
</table>
</div>
<div class='panel panel-default'>
<div class='panel-heading'>
<h3 class='panel-title'> Note </h3>
</div>
<div class='panel-body'>This cmdlet requires that the user running the cmdlet have the necessary permissions to create the app and connect to Exchange Online.</div>
</div>
<div>
<h3> Examples </h3>
</div>
<div class='panel panel-default'>
<div class='panel-body'>
<strong>EXAMPLE 1</strong>
<pre class="brush: ps"># Permissions required for app registration:
- 'Application.ReadWrite.All'
- 'DelegatedPermissionGrant.ReadWrite.All'
- 'Directory.ReadWrite.All'
- 'RoleManagement.ReadWrite.Directory'
# Permissions granted to the app:
- 'Mail.Send' (Application) - Send mail as any user
# Exchange application policy restricts send to a mail enabled security group
# Ensure a mail enabled sending group is created first:
$DefaultDomain = 'contoso.com'
$MailEnabledSendingGroupToCreate = "CTSO-GraphAPIMail"
# Creates a mail-enabled security group named "MySenders" using a default domain
$group = New-MailEnabledSendingGroup -Name $MailEnabledSendingGroupToCreate -DefaultDomain $DefaultDomain
# Create a new Graph Email App for a single tenant
$LicensedUserToSendAs = 'helpdesk@contoso.com'
Publish-TkEmailApp `
-AuthorizedSenderUserName $LicensedUserToSendAs `
-MailEnabledSendingGroup $group.PrimarySmtpAddress `
-ReturnParamSplat
# Returns an app named like 'GraphToolKit-Gtk-<Session AD Domain>-As-helpdesk'
# Returns a param splat that can be used as input for the send mail function:
# Example:
$params = @{
AppId = 'your-app-id'
Id = 'your-app-object-id'
AppName = 'GraphToolKit-Gtk-<Session AD Domain>-As-helpdesk'
CertificateSubject = 'GraphToolKit-GTK-<Session AD Domain>-As-helpdesk'
AppRestrictedSendGroup = 'CTSO-GraphAPIMail@contoso.com'
CertExpires = 'yyyy-MM-dd HH:mm:ss'
CertThumbprint = 'your-cert-thumbprint'
ConsentUrl = 'https://login.microsoftonline.com/<your-tenant-id>/adminconsent?client_id=<your-app-id>'
DefaultDomain = 'contoso.com'
SendAsUser = 'helpdesk'
SendAsUserEmail = 'helpdesk@contoso.com'
TenantID = 'your-tenant-id'
}</pre>
<div></div>
<strong>EXAMPLE 2</strong>
<pre class="brush: ps"># Create a multi client app registration where one app exists and multiple certificates are associated to the app:
# Initial setup:
# Create the group as before (or reuse the existing group) and run the following commands:
$LicensedUserToSendAs = 'helpdesk@contoso.com'
$CertPrefix = "CTSO" # First Company prefix. This will be used to prefix the certificate subject.
Publish-TkEmailApp `
-CertPrefix $CertPrefix `
-AuthorizedSenderUserName $LicensedUserToSendAs `
-MailEnabledSendingGroup $group.PrimarySmtpAddress `
-ReturnParamSplat
# Returns an app named like 'GraphToolKit-Gtk-<Session AD Domain>-As-helpdesk'
$params = @{
AppId = 'your-app-id'
Id = 'your-app-object-id'
AppName = 'GraphToolKit-Gtk-<Session AD Domain>-As-helpdesk'
CertificateSubject = 'GraphToolKit-CTSO-<Session AD Domain>-As-helpdesk'
AppRestrictedSendGroup = 'CTSO-GraphAPIMail@contoso.com'
CertExpires = 'yyyy-MM-dd HH:mm:ss'
CertThumbprint = 'your-cert-thumbprint'
ConsentUrl = 'https://login.microsoftonline.com/<your-tenant-id>/adminconsent?client_id=<your-app-id>'
DefaultDomain = 'contoso.com'
SendAsUser = 'helpdesk'
SendAsUserEmail = 'helpdesk@contoso.com'
TenantID = 'your-tenant-id'
}
$useExistingParams = @{
ExistingAppObjectId = $params.Id
CertPrefix = 'NewCompany'
OverwriteVaultSecret = $true # optional, if you want to overwrite the existing vault secret
ReturnParamSplat = $true # optional, returns the param splat
}
Publish-TkEmailApp @useExistingParams
# The new Cert will be prefixed with the new company prefix and will allow the current client to authenticate.
# Back in the app registrations console, if you look at the internal notes in the properties of the app:
# The app's "Internal Notes" will be populated with the following json:
# Assists in tracking the app's usage and configuration.
{
"GraphEmailAppFor": "helpdesk@contoso.com",
"RestrictedToGroup": "CTSO-GraphAPIMail@contoso.com",
"AppPermissions": "Mail.Send",
"New-Company_ClientIP": "<Public IP Address of the client where the app was called>",
"New-Company_Host": "<Host of the client where the app was called>",
"NewCoolCompany_ClientIP": "<Public IP Address of the client where the app was called>",
"NewCoolCompany_Host": "Host of the client where the app was called>"
}
# New cert additions added through the toolkit will append new client info to these notes.</pre>
<div></div>
</div>
</div>
<p class='pull-right'><a onclick='document.body.scrollTop = document.documentElement.scrollTop = 0;' style='cursor: pointer;'>Top of page</a>
</div>
<div id="Publish-TkM365AuditApp" class="toggle_container">
<div class="page-header">
<h2> Publish-TkM365AuditApp </h2>
<p><p>Publishes (creates) a new M365 Audit App registration in Entra ID (Azure AD) with a specified certificate.</p>
</p>
<p><p>The Publish-TkM365AuditApp function creates a new Azure AD application used for M365 auditing.
It connects to Microsoft Graph, gathers the required permissions for SharePoint and Exchange,
and optionally creates a self-signed certificate if no thumbprint is provided. It also assigns
the application to the Exchange Administrator and Global Reader roles. By default, the newly
created application details are stored as a secret in the specified SecretManagement vault.</p>
</p>
</div>
<div>
<h3> Syntax </h3>
</div>
<div class="panel panel-default">
<div class='panel-body'>
<pre class="brush: ps">Publish-TkM365AuditApp [[-AppPrefix] <String>] [[-CertThumbprint] <String>] [[-KeyExportPolicy] <String>] [[-VaultName] <String>] [-OverwriteVaultSecret] [-ReturnParamSplat] [-DoNotUseDomainSuffix] [<CommonParameters>]</pre>
</div>
</div>
<div>
<h3> Parameters </h3>
<table class="table table-striped table-bordered table-condensed visible-on">
<thead>
<tr>
<th>Name</th>
<th class="visible-lg visible-md">Alias</th>
<th>Description</th>
<th class="visible-lg visible-md">Required?</th>
<th class="visible-lg">Pipeline Input</th>
<th class="visible-lg">Default Value</th>
</tr>
</thead>
<tbody>
<tr>
<td><nobr>-AppPrefix</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>A short prefix (2-4 alphanumeric characters) used to build the app name. Defaults to "Gtk"
if not specified. Example app name: GraphToolKit-MSN-GraphApp-MyDomain-As-helpDesk</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">Gtk</td>
</tr>
<tr>
<td><nobr>-CertThumbprint</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>The thumbprint of an existing certificate in the current user's certificate store. If not
provided, a new self-signed certificate is created.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-KeyExportPolicy</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>Specifies whether the newly created certificate (if no thumbprint is provided) is
'Exportable' or 'NonExportable'. Defaults to 'NonExportable'.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">NonExportable</td>
</tr>
<tr>
<td><nobr>-VaultName</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>The SecretManagement vault name in which to store the app credentials. Defaults to
"M365AuditAppLocalStore" if not specified.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">M365AuditAppLocalStore</td>
</tr>
<tr>
<td><nobr>-OverwriteVaultSecret</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>If specified, overwrites an existing secret in the specified vault if it already exists.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">False</td>
</tr>
<tr>
<td><nobr>-ReturnParamSplat</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>If specified, returns a parameter splat string for use in other functions, instead of the
default PSCustomObject containing the app details.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">False</td>
</tr>
<tr>
<td><nobr>-DoNotUseDomainSuffix</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>If specified, does not append the domain suffix to the app name.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">False</td>
</tr>
</tbody>
</table>
</div>
<div>
<h3> Inputs </h3>
<p>The input type is the type of the objects that you can pipe to the cmdlet.</p>
<ul><li>None. This function does not accept pipeline input.</li></ul>
</div>
<div>
<h3> Outputs </h3>
<p>The output type is the type of the objects that the cmdlet emits.</p>
<ul><li>By default, returns a PSCustomObject with details of the new app (AppId, ObjectId, TenantId,
certificate thumbprint, expiration, etc.). If -ReturnParamSplat is used, returns a parameter
splat string.</li></ul>
</div>
<div class='panel panel-default'>
<div class='panel-heading'>
<h3 class='panel-title'> Note </h3>
</div>
<div class='panel-body'>Requires the Microsoft.Graph and ExchangeOnlineManagement modules for app creation and
role assignment. The user must have sufficient privileges to create and manage applications
in Azure AD, and to assign roles. After creation, admin consent may be required for the
assigned permissions.
Permissions required for app registration:
'Application.ReadWrite.All',
'DelegatedPermissionGrant.ReadWrite.All',
'Directory.ReadWrite.All',
'RoleManagement.ReadWrite.Directory'
Permissions granted to the app:
(Exchange Administrator and Global Reader Roles are also added to the service principal.)
'AppCatalog.ReadWrite.All',
'Channel.Delete.All',
'ChannelMember.ReadWrite.All',
'ChannelSettings.ReadWrite.All',
'Directory.Read.All',
'Group.ReadWrite.All',
'Organization.Read.All',
'Policy.Read.All',
'Domain.Read.All',
'TeamSettings.ReadWrite.All',
'User.Read.All',
'Sites.Read.All',
'Sites.FullControl.All',
'Exchange.ManageAsApp'</div>
</div>
<div>
<h3> Examples </h3>
</div>
<div class='panel panel-default'>
<div class='panel-body'>
<strong>EXAMPLE 1</strong>
<pre class="brush: ps">Publish-TkM365AuditApp -AppPrefix "CS12" -ReturnParamSplat
Creates a new M365 Audit App with the prefix "CS12", returns a parameter splat, and stores
the credentials in the default vault.</pre>
<div></div>
</div>
</div>
<p class='pull-right'><a onclick='document.body.scrollTop = document.documentElement.scrollTop = 0;' style='cursor: pointer;'>Top of page</a>
</div>
<div id="Publish-TkMemPolicyManagerApp" class="toggle_container">
<div class="page-header">
<h2> Publish-TkMemPolicyManagerApp </h2>
<p><p>Publishes a new MEM (Intune) Policy Manager App in Azure AD with read-only or read-write permissions.</p>
</p>
<p><p>The Publish-TkMemPolicyManagerApp function creates an Azure AD application intended for managing
Microsoft Endpoint Manager (MEM/Intune) policies. It optionally creates or retrieves a certificate,
configures the necessary Microsoft Graph permissions for read-only or read-write access, and stores
the resulting app credentials in a SecretManagement vault.</p>
</p>
</div>
<div>
<h3> Syntax </h3>
</div>
<div class="panel panel-default">
<div class='panel-body'>
<pre class="brush: ps">Publish-TkMemPolicyManagerApp [-AppPrefix] <String> [[-CertThumbprint] <String>] [[-KeyExportPolicy] <String>] [[-VaultName] <String>] [-OverwriteVaultSecret] [-ReadWrite] [-ReturnParamSplat] [-DoNotUseDomainSuffix] [<CommonParameters>]</pre>
</div>
</div>
<div>
<h3> Parameters </h3>
<table class="table table-striped table-bordered table-condensed visible-on">
<thead>
<tr>
<th>Name</th>
<th class="visible-lg visible-md">Alias</th>
<th>Description</th>
<th class="visible-lg visible-md">Required?</th>
<th class="visible-lg">Pipeline Input</th>
<th class="visible-lg">Default Value</th>
</tr>
</thead>
<tbody>
<tr>
<td><nobr>-AppPrefix</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>A 2-4 character prefix used to build the application name (e.g., CORP, MSN). This helps uniquely
identify the app in Azure AD.</p>
</td>
<td class="visible-lg visible-md">true</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-CertThumbprint</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>The thumbprint of an existing certificate in the current user's certificate store. If omitted,
a new self-signed certificate is created.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-KeyExportPolicy</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>Specifies whether the newly created certificate is 'Exportable' or 'NonExportable'.
Defaults to 'NonExportable' if not specified.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">NonExportable</td>
</tr>
<tr>
<td><nobr>-VaultName</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>The name of the SecretManagement vault in which to store the app credentials.
Defaults to 'MemPolicyManagerLocalStore'.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">MemPolicyManagerLocalStore</td>
</tr>
<tr>
<td><nobr>-OverwriteVaultSecret</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>If specified, overwrites any existing secret of the same name in the vault.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">False</td>
</tr>
<tr>
<td><nobr>-ReadWrite</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>If specified, grants read-write MEM/Intune permissions. Otherwise, read-only permissions are granted.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">False</td>
</tr>
<tr>
<td><nobr>-ReturnParamSplat</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>If specified, returns a parameter splat string for use in other functions. Otherwise, returns
a PSCustomObject containing the app details.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">False</td>
</tr>
<tr>
<td><nobr>-DoNotUseDomainSuffix</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>If specified, the function does not append the domain suffix to the app name.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">False</td>
</tr>
</tbody>
</table>
</div>
<div>
<h3> Inputs </h3>
<p>The input type is the type of the objects that you can pipe to the cmdlet.</p>
<ul><li>None. This function does not accept pipeline input.</li></ul>
</div>
<div>
<h3> Outputs </h3>
<p>The output type is the type of the objects that the cmdlet emits.</p>
<ul><li>By default, returns a PSCustomObject (TkMemPolicyManagerAppParams) with details of the newly created
app (AppId, certificate thumbprint, tenant ID, etc.). If -ReturnParamSplat is used, returns a parameter
splat string.</li></ul>
</div>
<div class='panel panel-default'>
<div class='panel-heading'>
<h3 class='panel-title'> Note </h3>
</div>
<div class='panel-body'>This function requires the Microsoft.Graph module for application creation and the user must have
permissions in Azure AD to register and grant permissions to the application. After creation, admin
consent may be needed to finalize the permission grants.
Permissions required for app registration::
'Application.ReadWrite.All',
'DelegatedPermissionGrant.ReadWrite.All',
'Directory.ReadWrite.All'
Permissions required for read-only access:
'DeviceManagementConfiguration.Read.All',
'DeviceManagementApps.Read.All',
'DeviceManagementManagedDevices.Read.All',
'Policy.Read.ConditionalAccess',
'Policy.Read.All'
Permissions required for read-write access:
'DeviceManagementConfiguration.ReadWrite.All',
'DeviceManagementApps.ReadWrite.All',
'DeviceManagementManagedDevices.ReadWrite.All',
'Policy.ReadWrite.ConditionalAccess',
'Policy.Read.All'</div>
</div>
<div>
<h3> Examples </h3>
</div>
<div class='panel panel-default'>
<div class='panel-body'>
<strong>EXAMPLE 1</strong>
<pre class="brush: ps">Publish-TkMemPolicyManagerApp -AppPrefix "CORP" -ReadWrite
Creates a new MEM Policy Manager App with read-write permissions, retrieves or
creates a certificate, and stores the credentials in the default vault.</pre>
<div></div>
</div>
</div>
<p class='pull-right'><a onclick='document.body.scrollTop = document.documentElement.scrollTop = 0;' style='cursor: pointer;'>Top of page</a>
</div>
<div id="Send-TkEmailAppMessage" class="toggle_container">
<div class="page-header">
<h2> Send-TkEmailAppMessage </h2>
<p><p>Sends an email using the Microsoft Graph API, either by retrieving app credentials from a local vault
or by specifying them manually.</p>
</p>
<p><p>The Send-TkEmailAppMessage function uses the Microsoft Graph API to send an email to a specified
recipient. It supports two parameter sets:</p>
<ol>
<li>'Vault' (default): Provide an existing app name (AppName) whose credentials are stored in the
local secret vault (e.g., GraphEmailAppLocalStore). The function retrieves the AppId, TenantId,
and certificate thumbprint automatically.</li>
<li>'Manual': Provide the AppId, TenantId, and certificate thumbprint yourself, bypassing the vault.
In both cases, the function obtains an OAuth2 token (via MSAL.PS) using the specified certificate
and uses the Microsoft Graph 'sendMail' endpoint to deliver the message.</li>
</ol>
</p>
</div>
<div>
<h3> Syntax </h3>
</div>
<div class="panel panel-default">
<div class='panel-body'>
<pre class="brush: ps">Send-TkEmailAppMessage -AppName <String> -To <String> -FromAddress <String> -Subject <String> -EmailBody <String> [-AttachmentPath <String[]>] [-VaultName <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
Send-TkEmailAppMessage -AppId <String> -TenantId <String> -CertThumbprint <String> -To <String> -FromAddress <String> -Subject <String> -EmailBody <String> [-AttachmentPath <String[]>] [-WhatIf] [-Confirm] [<CommonParameters>]</pre>
</div>
</div>
<div>
<h3> Parameters </h3>
<table class="table table-striped table-bordered table-condensed visible-on">
<thead>
<tr>
<th>Name</th>
<th class="visible-lg visible-md">Alias</th>
<th>Description</th>
<th class="visible-lg visible-md">Required?</th>
<th class="visible-lg">Pipeline Input</th>
<th class="visible-lg">Default Value</th>
</tr>
</thead>
<tbody>
<tr>
<td><nobr>-AppName</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>[Vault Parameter Set Only]
The name of the pre-created Microsoft Graph Email App (stored in GraphEmailAppLocalStore). Used only
if the 'Vault' parameter set is chosen. The function retrieves the AppId, TenantId, and certificate
thumbprint from the vault entry.</p>
</td>
<td class="visible-lg visible-md">true</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-AppId</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>[Manual Parameter Set Only]
The Azure AD application (client) ID to use for sending the email. Must be used together with TenantId
and CertThumbprint in the 'Manual' parameter set.</p>
</td>
<td class="visible-lg visible-md">true</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-TenantId</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>[Manual Parameter Set Only]
The Azure AD tenant ID (GUID or domain name). Must be used together with AppId and CertThumbprint
in the 'Manual' parameter set.</p>
</td>
<td class="visible-lg visible-md">true</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-CertThumbprint</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>[Manual Parameter Set Only]
The certificate thumbprint (in Cert:\CurrentUser\My) used for authenticating as the Azure AD app.
Must be used together with AppId and TenantId in the 'Manual' parameter set.</p>
</td>
<td class="visible-lg visible-md">true</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-To</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>The email address of the recipient.</p>
</td>
<td class="visible-lg visible-md">true</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-FromAddress</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>The email address of the sender who is authorized to send email as configured in the Graph Email App.</p>
</td>
<td class="visible-lg visible-md">true</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-Subject</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>The subject line of the email.</p>
</td>
<td class="visible-lg visible-md">true</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-EmailBody</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>The body text of the email.</p>
</td>
<td class="visible-lg visible-md">true</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-AttachmentPath</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>An array of file paths for any attachments to include in the email. Each path must exist as a leaf file.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>
<tr>
<td><nobr>-VaultName</nobr></td>
<td class="visible-lg visible-md"></td>
<td><p>[Vault Parameter Set Only]
The name of the vault to retrieve the GraphEmailApp object. Default is 'GraphEmailAppLocalStore'.</p>
</td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg">GraphEmailAppLocalStore</td>
</tr>
<tr>
<td><nobr>-WhatIf</nobr></td>
<td class="visible-lg visible-md">wi</td>
<td></td>
<td class="visible-lg visible-md">false</td>
<td class="visible-lg">false</td>
<td class="visible-lg"></td>
</tr>