A basic powershell module to interact with REST methods of the Graph API.
There's nothing fancy about this super basic Powershell module; it's intended to be a starting point for working directly with Graph API REST methods outside of the official module.
- Copy the
BasicRestModule
directory to your PS modules path or add this directory to yourPSModulePath
- Edit the
RestSecrets.ps1
file to use your own tenant ID, client ID, and client secret values- VERY IMPORTANT NOTE: If you clone this repo and edit the secrets file, you run the risk of accidentally committing your secrets. Adjust/Plan accordingly.
- Edit lines 6-15 of
example.ps1
to use valid ID strings (e.g. bogus value372fc89a-42f0-4f6c-b165-273055550fd9
) for:- Group ID
- User ID
- Device (object) ID
- Device (object) to Update ID
- Device with Bitlocker Enabled (device ID)
- Run the
example.ps1
script (comment out actions if/as desired before executing)
The client ID under which this is run must have at least the following API permissions granted:
Device.Read.All
Device.ReadWrite.All
Directory.Read.All
BitlockerKey.Read.All
BitlockerKey.ReadBasic.All
It is entirely possible I missed listing a permission, specifically within the DeviceManagement___
scope. This module and example do not cover how to create a Graph application project, create secrets, or manage permissions, so your mileage may vary (provided AS IS).
I interchange the use of "Object ID" and "Device ID." These are different strings and will throw an error if you provided the incorrect one.
There is no error handling on this module and example script. This is done by design to illustrate the core bits to get started with Graph API REST methods.
Only one action in the example script is write-enabled: Update-DeviceDetails
In the example it will attempt to set the extensionAttribute1
value; you'll need to understand if this has an impact in your environment or not (or just comment it out for safety).
All other functions are read-only and generally safe to run without fear of catastrophe.