I'm trying to run a PowerShell script to create a managed Wi-Fi profile (WPA3), and while it works fine on clients, I'm hitting errors when I try to execute it through Intune. I've looked at the logs and noticed that there are spaces in the registry key, which might be causing issues. The script runs in system context and I've attempted it in both 32-bit and 64-bit modes. Any advice on how to troubleshoot or fix this?
5 Answers
It’s not a direct fix, but you might want to clean up your script a bit. You are fetching the interface profiles multiple times with Get-ChildItem, which is inefficient. Consider storing the results in a variable to simplify your loops. Also, check how you're constructing the registry path; it looks like it might be built incorrectly.
Good point! Adding logging within your script while running it in Intune might also help you catch where things are going wrong during execution.
Have you considered using Intune's built-in configuration profile for adding Wi-Fi instead of running a custom script? It might simplify things and avoid these errors you’re encountering.
Instead of Get-Item, have you tried using Get-ItemProperty or Get-ItemPropertyValue? It could change how you access the registry keys and help with the errors you're seeing.
Remember that Intune requires you to run PowerShell in 64-bit mode, even if you start from the 32-bit path. Make sure you’re not missing that step, as it can lead to these kinds of issues.
It might help to properly format your code before posting. Use your favorite PowerShell editor to highlight the code and hit tab for indentation, then copy and paste it here. This could make it easier for others to read and help you troubleshoot.

Definitely! Keep an eye on spaces and special characters in your registry paths. A slight mismatch can lead to those 'path not found' errors you're experiencing. Simplifying the code can really help in tracking down the root cause!