Skip to content

Commit e340917

Browse files
committed
Add Ignite samples.
1 parent fe25a05 commit e340917

File tree

3 files changed

+102
-1
lines changed

3 files changed

+102
-1
lines changed

samples/5-Teams.ps1

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
# Add team owner.
2+
New-MgTeamMember -TeamId $InternsTeam.Id -Roles "owner" `
3+
-AdditionalProperties @{
4+
"@odata.type" = "#microsoft.graph.aadUserConversationMember";
5+
"[email protected]" = "https://graph.microsoft.com/beta/users/" + $teamOwnwerId
6+
}
7+
8+
# Add team members.
9+
foreach ($teamMember in $TeamMembers) {
10+
New-MgTeamMember -TeamId $InternsTeam.Id -Roles "member" `
11+
-AdditionalProperties @{
12+
"@odata.type" = "#microsoft.graph.aadUserConversationMember";
13+
"[email protected]" = "https://graph.microsoft.com/beta/users/" + $teamMember.Id
14+
}
15+
}
16+
17+
# Delete team.
18+
Remove-MgGroup -GroupId $InternsTeam.Id
19+
120
# Teams Chat snippets
221

322
# Get list of 1:1 chats

samples/9-Applications.ps1

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Incremental scope consent.
2+
Connect-Graph -Scopes "Application.ReadWrite.All"
13

24
# Create an application for use with DeviceCodeFlow
35
$app1 = new-mgApplication -displayName "DeviceCodeFlowApp" `
@@ -14,4 +16,26 @@ $app3 = new-mgApplication -displayName "ImplicitWebApp" `
1416
-ImplicitGrantSettingEnableAccessTokenIssuance `
1517
-ImplicitGrantSettingEnableIdTokenIssuance `
1618
-WebRedirectUris "https://localhost:3000/"
17-
19+
20+
# Get certificate from current user store.
21+
$CertificateThumbprint = "THUMBPRINT"
22+
$Certificate = Get-ChildItem -Path "Cert:\CurrentUser\My\$CertificateThumbprint"
23+
24+
# Graph resource Id
25+
$GraphResourceId = "00000003-0000-0000-c000-000000000000"
26+
27+
# Graph permissions constants
28+
$UserReadAll = @{ Id = "df021288-bdef-4463-88db-98f22de89214"; Type = "Role" }
29+
$GroupReadAll = @{ Id = "5b567255-7703-4780-807c-7be8301ae99b"; Type = "Role" }
30+
$MailboxSettingsRead = @{ Id = "40f97065-369a-49f4-947c-6a255697ae91"; Type = "Role" }
31+
$MailSend = @{ Id = "b633e1c5-b582-4048-a93e-9f11b44c7e96"; Type = "Role" }
32+
33+
# Create an application registration.
34+
$AppName = "ScriptedGraphPSApp"
35+
$app4 = New-MgApplication -"ClientCredentialApp" $AppName `
36+
-SignInAudience "AzureADMyOrg" `
37+
-RequiredResourceAccess @{ ResourceAppId = $graphResourceId; ResourceAccess = $UserReadAll, $GroupReadAll, $MailboxSettingsRead, $MailSend } `
38+
-KeyCredentials @(@{ Type = "AsymmetricX509Cert"; Usage = "Verify"; Key= $Certificate.RawData })
39+
40+
# Create corresponding service principal.
41+
New-MgServicePrincipal -AppId $appRegistration.AppId

samples/Scripts/UsersAndGroups.ps1

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
$TenantId = "TENANT_ID"
2+
$ClientId = "CLIENT_ID"
3+
$CertThumbprint = "CERT_THUMBPRINT"
4+
$AdminMail = "ADMIN_MAIL"
5+
6+
# Consent to permissions using app created in the last demo.
7+
$AdminConsentUrl = "https://login.microsoftonline.com/$TenantId/adminconsent?client_id=$ClientId"
8+
Write-Host -ForeGroundColor Yellow "Please go to the following URL in your browser to provide admin consent"
9+
Write-Host $AdminConsentUrl
10+
Write-Host "Press any key to continue when done ....."
11+
$Key = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
12+
13+
# Authenticate as a confidential client for app only calls.
14+
Connect-Graph -ClientId $ClientId -TenantId $TenantId -CertificateThumbprint $CertThumbprint
15+
16+
# Get group named 'Weekday Employees'
17+
$WeekdayEmployeesGroup = Get-MgGroup -Filter "DisplayName eq 'Weekday Employees'"
18+
19+
# Get Members of the group.
20+
$GroupMembers = Get-MgGroupMember -GroupId $WeekdayEmployeesGroup.Id
21+
$ToRecipients = @()
22+
foreach ($member in $GroupMembers) {
23+
$User = Get-MgUser -UserId $member.Id -Select "displayName", "mail", "mailboxSettings" | `
24+
Select DisplayName, Mail, MailboxSettings
25+
26+
# Get users with invalid workdays in their mailbox setting.
27+
if ( $User.MailboxSettings.WorkingHours.DaysOfWeek -contains "saturday" || `
28+
$User.MailboxSettings.WorkingHours.DaysOfWeek -contains "sunday" ) {
29+
Write-Host -ForegroundColor Yellow "User "$User.DisplayName" has an invalid workday."
30+
31+
$ToRecipients += @{
32+
emailAddress = @{
33+
name = $User.DisplayName;
34+
address = $User.Mail
35+
}}
36+
}
37+
}
38+
39+
if ($ToRecipients.Length) {
40+
# Compose message.
41+
$Message = @{
42+
subject = "Update Your Mailbox Settings!";
43+
toRecipients = $ToRecipients;
44+
body = @{
45+
contentType = "Text";
46+
content = "Please update to your mailbox settings to reflect your working hours." + `
47+
" You currently have Saturday and/or Sunday set as workday."
48+
}
49+
}
50+
51+
$Admin = Get-MgUser -UserId $AdminMail
52+
53+
# Send mail to users with invalid workdays.
54+
Send-MgUserMail -UserId $Admin.Id -BodyParameter @{message = $Message}
55+
Write-Host -ForegroundColor Green "Mail sent to affected users."
56+
}
57+
58+
Disconnect-Graph

0 commit comments

Comments
 (0)