Skip to content

Commit 7064a70

Browse files
committed
feat: new Guest Invite standard
1 parent b713768 commit 7064a70

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
function Invoke-CIPPStandardGuestInvite {
2+
<#
3+
.FUNCTIONALITY
4+
Internal
5+
.COMPONENT
6+
(APIName) GuestInvite
7+
.SYNOPSIS
8+
(Label) Guest Invite settings
9+
.DESCRIPTION
10+
(Helptext) This setting controls who can invite guests to your directory to collaborate on resources secured by your company, such as SharePoint sites or Azure resources.
11+
(DocsDescription) This setting controls who can invite guests to your directory to collaborate on resources secured by your company, such as SharePoint sites or Azure resources.
12+
.NOTES
13+
CAT
14+
InTune Standards
15+
TAG
16+
"highimpact"
17+
ADDEDCOMPONENT
18+
IMPACT
19+
High Impact
20+
RECOMMENDEDBY
21+
UPDATECOMMENTBLOCK
22+
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
23+
.LINK
24+
https://docs.cipp.app/user-documentation/tenant/standards/edit-standards
25+
#>
26+
27+
param($Tenant, $Settings)
28+
29+
$CurrentState = New-GraphGetRequest -Uri 'https://graph.microsoft.com/beta/policies/authorizationPolicy/authorizationPolicy' -tenantid $Tenant
30+
31+
if ($null -eq $Settings.allowInvitesFrom) { $Settings.allowInvitesFrom = 'Everyone' } # none, adminsAndGuestInviters, adminsGuestInvitersAndAllMembers, everyone
32+
$StateIsCorrect = ($CurrentState.allowInvitesFrom -eq $Settings.allowInvitesFrom)
33+
34+
if ($Settings.remediate -eq $true) {
35+
if ($StateIsCorrect -eq $true) {
36+
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message 'Guest Invite settings is already applied correctly.' -Sev Info
37+
} else {
38+
try {
39+
$GraphRequest = @{
40+
tenantID = $Tenant
41+
uri = "https://graph.microsoft.com/beta/policies/authorizationPolicy/authorizationPolicy"
42+
AsApp = $false
43+
Type = 'PATCH'
44+
ContentType = 'application/json; charset=utf-8'
45+
Body = [pscustomobject]@{
46+
allowInvitesFrom = $Settings.allowInvitesFrom
47+
} | ConvertTo-Json -Compress
48+
}
49+
New-GraphPostRequest @GraphRequest
50+
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message "Successfully updated Guest Invite setting to $($Settings.allowInvitesFrom)" -Sev Info
51+
} catch {
52+
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message "Failed to update Guest Invite setting to $($Settings.allowInvitesFrom)" -Sev Error -LogData $_
53+
}
54+
}
55+
}
56+
57+
if ($Settings.alert -eq $true) {
58+
if ($StateIsCorrect -eq $true) {
59+
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Guest Invite settings is enabled.' -sev Info
60+
} else {
61+
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Guest Invite settings is not enabled.' -sev Alert
62+
}
63+
}
64+
65+
if ($Settings.report -eq $true) {
66+
Add-CIPPBPAField -FieldName 'GuestInvite' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $tenant
67+
}
68+
}

0 commit comments

Comments
 (0)