File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Endpoint/MEM Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 1
1
using namespace System.Net
2
2
3
- Function Invoke-ExecDeviceAction {
3
+ function Invoke-ExecDeviceAction {
4
4
<#
5
5
. FUNCTIONALITY
6
6
Entrypoint
@@ -22,6 +22,16 @@ Function Invoke-ExecDeviceAction {
22
22
try {
23
23
switch ($Action ) {
24
24
' 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
+
25
35
$ActionBody = @ { deviceName = $Request.Body.input } | ConvertTo-Json - Compress
26
36
break
27
37
}
@@ -30,7 +40,7 @@ Function Invoke-ExecDeviceAction {
30
40
Write-Host " ActionBody: $ActionBody "
31
41
break
32
42
}
33
- Default { $ActionBody = $Request.Body | ConvertTo-Json - Compress }
43
+ default { $ActionBody = $Request.Body | ConvertTo-Json - Compress }
34
44
}
35
45
36
46
$cmdParams = @ {
You can’t perform that action at this time.
0 commit comments