Skip to content

zaskem/basic-graph-rest-powershell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

basic-graph-rest-powershell

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.

Installation/Configuration/Use

  1. Copy the BasicRestModule directory to your PS modules path or add this directory to your PSModulePath
  2. 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.
  3. Edit lines 6-15 of example.ps1 to use valid ID strings (e.g. bogus value 372fc89a-42f0-4f6c-b165-273055550fd9) for:
    1. Group ID
    2. User ID
    3. Device (object) ID
    4. Device (object) to Update ID
    5. Device with Bitlocker Enabled (device ID)
  4. Run the example.ps1 script (comment out actions if/as desired before executing)

Permissions

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).

Notes and Miscellaneous Bits

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.

About

A basic REST powershell module to interact with the Graph API.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published