Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: backup the Windows 365 Cloud PC settings #125

Closed
TheKrabbe opened this issue Mar 20, 2023 · 11 comments
Closed

Feature Request: backup the Windows 365 Cloud PC settings #125

TheKrabbe opened this issue Mar 20, 2023 · 11 comments

Comments

@TheKrabbe
Copy link

Hi
would it possible to get the cloudPC settings added/backup as well
from following 2 endpoints
/deviceManagement/virtualEndpoint/provisioningPolicies
deviceManagement/virtualEndpoint/userSettings

fantastisk work by the way

@Micke-K
Copy link
Owner

Micke-K commented Apr 11, 2023

Hello!

I'm so sorry for late reply. I've been so busy the last couple of months so I've had almost no time for the project.

I gad a quick look at the apis. Should be possible but I don't have this in my dev tenant so I might have some problems testing it.

Cheers!

@TheKrabbe
Copy link
Author

TheKrabbe commented Apr 12, 2023 via email

@Micke-K
Copy link
Owner

Micke-K commented Apr 12, 2023

Hello!

Thank you for the kind words.

I'll try to add this so you can test. Add support for export is normally the easy part. It's the import that can be tricky.

I'll see if I can do this soon. I have a bunch of things to fix once I get dome time to work on this.

Cheers!

@TheKrabbe
Copy link
Author

TheKrabbe commented Apr 12, 2023 via email

@TheKrabbe
Copy link
Author

so did some test yesterday and was able to succesfully import the policy and user assigment for following endpoint (deviceManagement/virtualEndpoint/userSettings), the json file i used to restore contained the assignments as well, so it first restore the policy and then the asssigment, i will try and do the same for the (deviceManagement/virtualEndpoint/provisioningPolicies) endpoint and get back to you

`$W365UserSettings = Get-Content -LiteralPath "C:\temp\W365_USER_SETTINGS_BACKUP_TEST.json" -Raw | ConvertFrom-Json
$UserAssigments = $W365UserSettings | Select-Object -ExpandProperty assignments | Select-Object -Property id
$requestBody = $W365UserSettings | Select-Object -Property * -ExcludeProperty assignments@odata.context,assignments,id, createdDateTime, lastModifiedDateTime, settingCount, creationSource | ConvertTo-Json -Depth 100
$ImportReturn = Invoke-MgGraphRequest -Method POST -Body $requestBody.toString() -URI "beta/deviceManagement/virtualEndpoint/userSettings" -ErrorAction Stop

$UserAssigmentBody = @{
assignments = @()
}
foreach($UserAssigment in $UserAssigments){
$UserAssigmentBody.assignments += @{
"target" = @{groupid = "$($UserAssigment.id)"}
}
}
$UserAssigmentBody = $UserAssigmentBody | ConvertTo-Json -Depth 100

Invoke-MgGraphRequest -Method POST -Body $UserAssigmentBody.toString() -Uri "beta/deviceManagement/virtualEndpoint/userSettings/$($ImportReturn.id)/assign" -ErrorAction Stop`

@TheKrabbe
Copy link
Author

Seem like same code can be used for the (deviceManagement/virtualEndpoint/provisioningPolicies) endpoint, was able to succesfully import both policy and assignmets

`$W365ProvisioningProfile = Get-Content -LiteralPath "C:\temp\W365_PROVISIONG_PROFILE_BACKUP_TEST.json" -Raw | ConvertFrom-Json
$UserAssigments = $W365ProvisioningProfile | Select-Object -ExpandProperty assignments | Select-Object -Property id
$requestBody = $W365ProvisioningProfile | Select-Object -Property * -ExcludeProperty assignments@odata.context,assignments,id, createdDateTime, lastModifiedDateTime, settingCount, creationSource | ConvertTo-Json -Depth 100
$ImportReturn = Invoke-MgGraphRequest -Method POST -Body $requestBody.toString() -URI "beta/deviceManagement/virtualEndpoint/provisioningPolicies" -ErrorAction Stop

$UserAssigmentBody = @{
assignments = @()
}
foreach($UserAssigment in $UserAssigments){
$UserAssigmentBody.assignments += @{
"target" = @{groupid = "$($UserAssigment.id)"}
}
}
$UserAssigmentBody = $UserAssigmentBody | ConvertTo-Json -Depth 100

Invoke-MgGraphRequest -Method POST -Body $UserAssigmentBody.toString() -Uri "beta/deviceManagement/virtualEndpoint/provisioningPolicies/$($ImportReturn.id)/assign" -ErrorAction Stop`

@Micke-K
Copy link
Owner

Micke-K commented Apr 19, 2023

Can you try this version. Export should work but not sure about import. Some policies has extra properties to remove before import.

Cheers!

EndpointManager.zip

@TheKrabbe
Copy link
Author

TheKrabbe commented Apr 24, 2023 via email

@Micke-K
Copy link
Owner

Micke-K commented Jun 7, 2023

Hello!
Can I close this issue?
Cheers!

@TheKrabbe
Copy link
Author

TheKrabbe commented Jun 7, 2023 via email

@Micke-K
Copy link
Owner

Micke-K commented Jun 8, 2023

Thank you!

@Micke-K Micke-K closed this as completed Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants