Code Monkey home page Code Monkey logo

cippapimodule's Introduction

What is this?

This is the code for a PowerShell module for CIPP. It is a work in progress, and only has about 134 out of the almost 300 API Endpoints built in. However, more will follow and it does have a generic 'Invoke-CIPPRestMethod' available so you can make any API call you want. See advanced usage examples below.

The module is written for PowerShell 7.

What does it do?

CIPPAPIModule provides a PowerShell wrapper around the CIPP API. The module handles all the authentication for you. All you need to do is supply your CIPP API Details using the 'Set-CIPPAPIDetails' command.

Installing

This module is published to the PowerShell Gallery and can be installed from within PowerShell with Install-Module

Install-Module -Name CIPPAPIModule

Updating

This module is updated regularly. Remember to always check for the latest version from within PowerShell with Update-Module

Update-Module -Name CIPPAPIModule

Getting Started

The first and probably most important requirement for this module is getting it connected to your CIPP API.

Connecting the PowerShell module to the API

  1. Set API Connection details
Set-CIPPAPIDetails -CIPPClientID "YourClientIDGoesHere" -CIPPClientSecret "YourClientSecretGoesHere" -CIPPAPIUrl "https://your.cipp.apiurl" -TenantID "YourTenantID"
  1. Test your first call to the API
Get-CIPPLogs

Cmdlet Help

CIPP

Email-Exchange

Endpoint

Identity

Intune

Security

Teams-Sharepoint

Tenant

Invoke-CIPPRestMethod

Set-CIPPAPIDetails

Advanced Usage Examples

Below are some examples for some generic requests

Invoke-CIPPRestMethod -Endpoint '/api/Listusers' -Method 'GET' -Params @{ 'tenantfilter' = '11c11ab1-527a-1d29-l92e-76413h012s76' }

This example sends a GET request to the '/api/Listusers' endpoint with a query parameter 'tenantfilter' set to '11c11ab1-527a-1d29-l92e-76413h012s76'.

Invoke-CIPPRestMethod -Endpoint '/api/ListMailboxPermissions' -Params @{ 'tenantfilter' = 'M365x72601982.onmicrosoft.com', 'userid' = '11c11ab1-527a-1d29-l92e-76413h012s76'}

This example sends a GET request to the '/api/ListMailboxPermissions' endpoint with a query parameter 'tenantfilter' set to 'M365x72601982.onmicrosoft.com' and 'userid' set to '11c11ab1-527a-1d29-l92e-76413h012s76'

Invoke-CIPPRestMethod -Endpoint '/api/adduser' -method 'POST' -Body @{ 'tenantID' = '11c11ab1-527a-1d29-l92e-76413h012s76';'DisplayName' = 'Test User';'UserName' = 'testuser';'AutoPassword' = $true;'FirstName' = 'Test';'LastName' = 'User';'Domain' = 'M365x72601982.onmicrosoft.com';'CopyFrom' = "" }

This example sends a POST request to the '/api/adduser' endpoint with a Body 'tenantID' set to '11c11ab1-527a-1d29-l92e-76413h012s76' and 'DisplayName' set to 'Test User', 'UserName' set to 'testuser', 'AutoPassword' set to $true, 'FirstName' set to 'Test', 'LastName' set to 'User', 'Domain' set to 'M365x72601982.onmicrosoft.com'

Example Scripts

Some example scripts can be found Below:

Special Thanks

Special thanks to @KelvinTegelaar, @JohnDuprey, @rvdwegen and @Jr7468. I Could not have got this far without you!

cippapimodule's People

Contributors

bnwein avatar

Stargazers

 avatar  avatar sam avatar Reed Scheper avatar  avatar  avatar David Szpunar avatar  avatar  avatar  avatar AME avatar

Watchers

 avatar

cippapimodule's Issues

Get-CIPPTeamsVoice not working?

Hello, first off - this module is SUPER cool. Thanks so much for investing the time to make this.

I noticed when using it today that the command Get-CIPPTeamsVoice does not work on any of our managed tenants.

At first, we were getting: "Invoke-RestMethod: [ "The property \u0027AcquisitionDate\u0027 cannot be found on this object. Verify that the property exists and can be set." ]"

After a few attempts, now we get: "Invoke-RestMethod: [ "Failed to make Teams API Get Request Response status code does not indicate success: 404 (Not Found)." ]"

I have also tried: invoke-CIPPRestMethod -Endpoint '/api/listteamsvoice' -Method GET -Params @{ 'tenantfilter' = "xxxxxxxx" }
same result.

Perhaps this error is thrown from the CIPP API itself?

Our intended goal is to get a list of available Teams Voice phone numbers. Would love any thoughts or ideas you may have!

Invoke-RestMethod: Bad Request

Description

First of all thanks for the massive effort in producing this awesome piece of work!

After installing the CIPPAPIModule 1.1.4 on Powershell 7.4.3 without issues, I can authohorize with Set-CIPPAPIDetails without issues but every command thereafter results in "Invoke-RestMethod: Bad Request" as if the api-url isn't correct. I'm 100% sure that's correct, it's copied from the response from the CIPP registration. Even the Get-CIPPLogs gives this error.

Any suggestion on how to resolve this?

Furthermore (and separate from this issue), the Get-AllTenants-SharedMailboxesEnabledAccount.ps1 has an error in line 46. The Get-CIPPEnabled[...] is missing an 's' at the end.

Environment data

Module Version Number: 1.1.4 
CIPP Back end version number: 6.0.0

Group members incomplete

Description

Hello,

I am unsure if this is an issue with the Powershell module or the CIPP API itself, but it does not appear that all groups members are returned. Specifically, we are using this to report on Distribution List members and have found that only 20 members in the "group" are shown, even though there are 80+.

For example, run a command like this:
$groups = Get-CIPPGroups -CustomerTenantID $company.tenantId

Observe that the member count will not exceed 20
$group = $groups | Where-object {$_.mail -eq "[email protected]"}
$group.members.count

This is also true for the membersCsv result

Environment data

Module Version: 1.1.0
Back End Version: 6.0.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.