forked from KelvinTegelaar/CIPP-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'KelvinTegelaar:dev' into dev
- Loading branch information
Showing
5 changed files
with
120 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"name": "tenant", | ||
"type": "activityTrigger", | ||
"direction": "in" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
param($tenant) | ||
|
||
function GetTenantRequestXml { | ||
return @" | ||
<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" | ||
ApplicationName="SharePoint Online PowerShell (16.0.23814.0)" | ||
xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"> | ||
<Actions> | ||
<ObjectPath Id="4" ObjectPathId="3" /> | ||
<Query Id="5" ObjectPathId="3"> | ||
<Query SelectAllProperties="true"> | ||
<Properties /> | ||
</Query> | ||
</Query> | ||
</Actions> | ||
<ObjectPaths> | ||
<Constructor Id="3" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" /> | ||
</ObjectPaths> | ||
</Request> | ||
"@ | ||
} | ||
|
||
function GetDisableAddShortcutsToOneDriveXml { | ||
param( | ||
[string]$identity | ||
) | ||
|
||
# the json object gives us a space and a newline :( | ||
$identity = $identity.Replace(" ", "") | ||
$identity = $identity.Replace("`n", "
") | ||
return @" | ||
<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" | ||
LibraryVersion="16.0.0.0" ApplicationName="SharePoint Online PowerShell (16.0.23814.0)" | ||
xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009"> | ||
<Actions> | ||
<SetProperty Id="7" ObjectPathId="3" Name="DisableAddToOneDrive"> | ||
<Parameter Type="Boolean">true</Parameter> | ||
</SetProperty> | ||
</Actions> | ||
<ObjectPaths> | ||
<Identity Id="3" Name="$identity" /> | ||
</ObjectPaths> | ||
</Request> | ||
"@ | ||
} | ||
|
||
$log = @{ | ||
API = "Standards" | ||
tenant = $tenant | ||
message = "" | ||
sev = "Info" | ||
} | ||
|
||
try { | ||
$OnMicrosoft = (New-GraphGetRequest -uri 'https://graph.microsoft.com/beta/domains?$top=999' -tenantid $tenant | | ||
Where-Object -Property isInitial -EQ $true).id.split('.') | Select-Object -First 1 | ||
$AdminUrl = "https://$($OnMicrosoft)-admin.sharepoint.com" | ||
$graphRequest = @{ | ||
"scope" = "$AdminURL/.default" | ||
"tenantid" = $tenant | ||
"uri" = "$AdminURL/_vti_bin/client.svc/ProcessQuery" | ||
"type" = "POST" | ||
"body" = GetTenantRequestXml | ||
"ContentType" = "text/xml" | ||
} | ||
|
||
$response = New-GraphPostRequest @graphRequest | ||
if (!$response.ErrorInfo.ErrorMessage) { | ||
$log.message = "Received Tenant from Sharepoint" | ||
Write-LogMessage @log | ||
} | ||
|
||
$graphRequest.Body = GetDisableAddShortcutsToOneDriveXml -identity $response._ObjectIdentity_ | ||
$response = New-GraphPostRequest @graphRequest | ||
|
||
if (!$response.ErrorInfo.ErrorMessage) { | ||
$log.message = "Set DisableAddShortcutsToOneDrive to True on $tenant" | ||
} | ||
else { | ||
$log.message = "Unable to set DisableAddShortcutsToOneDrive to True ` | ||
on $($tenant): $($response.ErrorInfo.ErrorMessage)" | ||
} | ||
} | ||
catch { | ||
$log.message = "Failed to set OneDrive shortcut: $($_.Exception.Message)" | ||
$log.sev = "Error" | ||
} | ||
|
||
Write-LogMessage @log |