Skip to content

Commit 1b6cedd

Browse files
Merge branch 'dev' of https://github.com/KelvinTegelaar/CIPP-API into dev
2 parents 208ab11 + bd6a52b commit 1b6cedd

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/MEM/Invoke-ExecDeviceAction.ps1

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using namespace System.Net
22

3-
Function Invoke-ExecDeviceAction {
3+
function Invoke-ExecDeviceAction {
44
<#
55
.FUNCTIONALITY
66
Entrypoint
@@ -22,6 +22,16 @@ Function Invoke-ExecDeviceAction {
2222
try {
2323
switch ($Action) {
2424
'setDeviceName' {
25+
if ($Request.Body.input -match '%') {
26+
$Device = New-GraphGetRequest -uri "https://graph.microsoft.com/beta/deviceManagement/managedDevices/$DeviceFilter" -tenantid $TenantFilter
27+
$Request.Body.input = Get-CIPPTextReplacement -TenantFilter $TenantFilter -Text $Request.Body.input
28+
$Request.Body.input = $Request.Body.input -replace '%SERIAL%', $Device.serialNumber
29+
# limit to 15 characters
30+
if ($Request.Body.input.Length -gt 15) {
31+
$Request.Body.input = $Request.Body.input.Substring(0, 15)
32+
}
33+
}
34+
2535
$ActionBody = @{ deviceName = $Request.Body.input } | ConvertTo-Json -Compress
2636
break
2737
}
@@ -30,7 +40,7 @@ Function Invoke-ExecDeviceAction {
3040
Write-Host "ActionBody: $ActionBody"
3141
break
3242
}
33-
Default { $ActionBody = $Request.Body | ConvertTo-Json -Compress }
43+
default { $ActionBody = $Request.Body | ConvertTo-Json -Compress }
3444
}
3545

3646
$cmdParams = @{

0 commit comments

Comments
 (0)