You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Appologies in advance as i am not truly a dev and may not follow usual GitHub etiquette.
The standard currently only changes the "isSiteCreationEnabled" flag, but does not change the "isSiteCreationUIEnabled" flag.
the isSiteCreationUIEnabled flag appears to control if the site creation is allowed through the UI (web).
I am assuming the "isSiteCreationEnabled" flag changes behavior through api/powershell.
I have updated the powershell and tested on my installation and the changes below appear to work
function Invoke-CIPPStandardDisableUserSiteCreate {
<#
.FUNCTIONALITY
Internal
.COMPONENT
(APIName) DisableUserSiteCreate
.SYNOPSIS
(Label) Disable site creation by standard users
.DESCRIPTION
(Helptext) Disables users from creating new SharePoint sites
(DocsDescription) Disables standard users from creating SharePoint sites, also disables the ability to fully create teams
.NOTES
CAT
SharePoint Standards
TAG
"highimpact"
ADDEDCOMPONENT
IMPACT
High Impact
POWERSHELLEQUIVALENT
Update-MgAdminSharepointSetting
RECOMMENDEDBY
UPDATECOMMENTBLOCK
Run the Tools\Update-StandardsComments.ps1 script to update this comment block
.LINK
https://docs.cipp.app/user-documentation/tenant/standards/edit-standards
#>
param($Tenant, $Settings)
##$Rerun -Type Standard -Tenant $Tenant -Settings $Settings 'DisableUserSiteCreate'
$CurrentInfo = New-GraphGetRequest -Uri 'https://graph.microsoft.com/beta/admin/sharepoint/settings' -tenantid $Tenant -AsApp $true
If ($Settings.remediate -eq $true) {
if ($CurrentInfo.isSiteCreationEnabled -or $CurrentInfo.isSiteCreationUIEnabled) {
try {
$body = '{"isSiteCreationEnabled": false, "isSiteCreationUIEnabled": false}'
$null = New-GraphPostRequest -tenantid $tenant -Uri 'https://graph.microsoft.com/beta/admin/sharepoint/settings' -AsApp $true -Type patch -Body $body -ContentType 'application/json'
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Disabled standard users from creating sites and adjusted UI setting' -sev Info
} catch {
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
Write-LogMessage -API 'Standards' -tenant $tenant -message "Failed to disable standard users from creating sites: $ErrorMessage" -sev Error
}
} else {
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Standard users are already disabled from creating sites and UI setting is adjusted' -sev Info
}
}
if ($Settings.alert -eq $true) {
if ($CurrentInfo.isSiteCreationEnabled -eq $false -and $CurrentInfo.isSiteCreationUIEnabled -eq $false) {
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Standard users are not allowed to create sites and UI setting is disabled' -sev Info
} else {
Write-LogMessage -API 'Standards' -tenant $tenant -message 'Standard users are allowed to create sites or UI setting is enabled' -sev Alert
}
}
if ($Settings.report -eq $true) {
Add-CIPPBPAField -FieldName 'DisableUserSiteCreate' -FieldValue $CurrentInfo.isSiteCreationEnabled -StoreAs bool -Tenant $tenant
Add-CIPPBPAField -FieldName 'DisableUserSiteCreateUI' -FieldValue $CurrentInfo.isSiteCreationUIEnabled -StoreAs bool -Tenant $tenant
}
}
Environment data
Non-sponsored
Front End Version Number:
Back End Version Number:
Tried Tenant Cache Clear: true
Tried Token Cache Clear: true
Also tested solution and verified functionality.
The text was updated successfully, but these errors were encountered:
Thank you for creating a bug. Please make sure your bug is indeed a unique case by checking current and past issues, and reading the complete documentation at https://docs.cipp.app/
If your bug is a known documentation issue, it will be closed without notice by a contributor. To confirm that this is not a bug found in the documentation, please copy and paste the following comment: "I confirm that I have checked the documentation thoroughly and believe this to be an actual bug."
Without confirming, your report will be closed in 24 hours. If you'd like this bug to be assigned to you, please comment "I would like to work on this please!".
Description
Appologies in advance as i am not truly a dev and may not follow usual GitHub etiquette.
The standard currently only changes the "isSiteCreationEnabled" flag, but does not change the "isSiteCreationUIEnabled" flag.
the isSiteCreationUIEnabled flag appears to control if the site creation is allowed through the UI (web).
I am assuming the "isSiteCreationEnabled" flag changes behavior through api/powershell.
I have updated the powershell and tested on my installation and the changes below appear to work
"isSiteCreationUIEnabled": true
"isSiteCreationUIEnabled": false
Invoke-CIPPStandardDisableUserSiteCreate.ps1
updated code:
Environment data
The text was updated successfully, but these errors were encountered: