Skip to content

Commit 57fec34

Browse files
committed
Revert "Deprecate SPDirectSharing"
This reverts commit 1ce871e.
1 parent 1b0b5c6 commit 57fec34

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

Modules/CIPPCore/Public/Standards/Invoke-CIPPStandardSPDirectSharing.ps1

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,49 @@ function Invoke-CIPPStandardSPDirectSharing {
3232

3333
param($Tenant, $Settings)
3434

35-
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message 'This standard has been deprecated in favor of the Set Default Sharing Link Settings standard. Please update your standards to use new standard.' -Sev Alert
35+
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message 'This standard has been deprecated in favor of the "Set Default Sharing Link Settings" standard. Please update your standards to use new standard. However this will continue to function.' -Sev Alert
36+
37+
$CurrentState = Get-CIPPSPOTenant -TenantFilter $Tenant |
38+
Select-Object -Property _ObjectIdentity_, TenantFilter, DefaultSharingLinkType
39+
40+
$StateIsCorrect = ($CurrentState.DefaultSharingLinkType -eq 'Direct' -or $CurrentState.DefaultSharingLinkType -eq 1)
41+
42+
if ($Settings.remediate -eq $true) {
43+
if ($StateIsCorrect -eq $true) {
44+
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message 'SharePoint Default Direct Sharing is already enabled' -Sev Info
45+
} else {
46+
$Properties = @{
47+
DefaultSharingLinkType = 1
48+
}
49+
50+
try {
51+
$CurrentState | Set-CIPPSPOTenant -Properties $Properties
52+
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message 'Successfully set the SharePoint Default Direct Sharing to Direct' -Sev Info
53+
} catch {
54+
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
55+
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message "Failed to set the SharePoint Default Direct Sharing to Direct. Error: $ErrorMessage" -Sev Error
56+
}
57+
}
58+
}
59+
60+
if ($Settings.alert -eq $true) {
61+
if ($StateIsCorrect -eq $true) {
62+
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message 'SharePoint Direct Sharing is enabled' -Sev Info
63+
} else {
64+
$Message = 'SharePoint Default Direct Sharing is not enabled.'
65+
Write-StandardsAlert -message $Message -object $CurrentState -tenant $Tenant -standardName 'SPDirectSharing' -standardId $Settings.standardId
66+
Write-LogMessage -API 'Standards' -Tenant $Tenant -Message $Message -Sev Alert
67+
}
68+
}
69+
70+
if ($Settings.report -eq $true) {
71+
Add-CIPPBPAField -FieldName 'DirectSharing' -FieldValue $StateIsCorrect -StoreAs bool -Tenant $tenant
72+
73+
if ($StateIsCorrect) {
74+
$FieldValue = $true
75+
} else {
76+
$FieldValue = $CurrentState
77+
}
78+
Set-CIPPStandardsCompareField -FieldName 'standards.SPDirectSharing' -FieldValue $FieldValue -Tenant $Tenant
79+
}
3680
}

0 commit comments

Comments
 (0)