Bulk removing USB exceptions #366
Replies: 9 comments
-
In the first example, I think you had a problem here: [Array]$IdGroup = $remove[$i..($i + ($Max - 1))].ExceptionID
$Exceptions = @($IdGroup).foreach{ @{ delete_exceptions = @('id', $_.ExceptionID) } } Because [Array]$IdGroup = $remove[$i..($i + ($Max - 1))].ExceptionID
$Exceptions = @($IdGroup).foreach{ @{ delete_exceptions = @('id', $_) } }
|
Beta Was this translation helpful? Give feedback.
-
Thanks for your quick and helpful answer! Regarding $Policy, thats set at the start:
But I reassigned it during edits to reflect the changes:
I think that caused the 2nd Error because the first Code 500 error may mangle up the return to $Policy, and is therefore not accessible for the other commands afterwards. After changing it to
the error is not present anymore. Furthermore you are absolutely right, I made a mistake with $_.ExceptionID. After changing it to
I can see the Keys and Values are set in the $Settings Variable, but sadly this does not seem to be the only issue. Now
still produces the Code 500 Error (now with $VerbosePreference='Continue')
So now at least we see that it does send the IDs, but I suspect the format does not quite work out?
or how does the server wants it to be formatted? |
Beta Was this translation helpful? Give feedback.
-
Try this? for ($i=0; $i -lt ($Remove | Measure-Object).Count; $i+=$Max) {
# Aggregate exceptions in groups of $Max
$Delete = [System.Collections.Generic.List[string]]@()
[string[]]$IdGroup = $Remove[$i..($i+($Max-1))].ExceptionID
@($IdGroup).foreach{ $Delete.Add($_) }
$Setting = [PSCustomObject]@{ delete_exceptions = @($Delete) }
$Policy = Edit-FalconDeviceControlPolicy -Id $Policy.ID -Setting $Setting
$completedCount.Value = ($completedCount.Value + $IdGroup.Count)
} |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
In your example, there were multiple
In mine, it was one
This isn't a PSFalcon question, it's more about what the API expects. As far as my understanding, when adding an exception, you can either provide...
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the clarification.
returns
(Suspected, but worth a try)
returns
even though this should work in my opinion. You have another tip for me here? |
Beta Was this translation helpful? Give feedback.
-
I was incorrect about
I figured out the |
Beta Was this translation helpful? Give feedback.
-
Thanks you very much for your help it works now. PS: not quite sure why there was an
in the inner custom object, I didn't use it and it seems to work fine :) |
Beta Was this translation helpful? Give feedback.
-
There are different classes that you use when setting exceptions. Mobile phones can show up as several device types, so using |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description of your question
I am trying to remove USB Exceptions using PSFalcon module for powershell and am running into some issues.
I am able to remove one exception at a time, but this is very slow for >300 rules, so I want to be able to bulk remove exceptions.
I already managed to bulk add exceptions via this code and wanted to do this for bulk removal too, but i fail miserably.
To Reproduce
This works, removing one exception at a time:
This works, adding multiple exceptions at a time:
This does not work, removing multiple exceptions at a time:
I tried adding the IDs together as an object of strings which returns the error in the screenshot:
The error seems strange, since the argument that cannot be validated seems to be the $Policy.ID, not $Settings, which surely is correct, since the command in the non-bulk version directly below works just fine, and the commands are identical (besides $Settings). So there also could be a bug in here, not just my bad scripting skills.
I also tried to join the object as comma separated string like that:
This does not return an error, but also it does not remove any exceptions so yeah ... am a bit lost here.
Expected behavior
Bulk removal should work like bulk adding.
Environment (please complete the following information):
Additional context
Nothing I would be aware of.
Beta Was this translation helpful? Give feedback.
All reactions