Skip to content

Create a function to set the tenant alias in CIPP - #96

Open
jonwbstr wants to merge 1 commit into
BNWEIN:Devfrom
jonwbstr:Create_Set-CIPPTenantProperties
Open

Create a function to set the tenant alias in CIPP#96
jonwbstr wants to merge 1 commit into
BNWEIN:Devfrom
jonwbstr:Create_Set-CIPPTenantProperties

Conversation

@jonwbstr

@jonwbstr jonwbstr commented May 26, 2026

Copy link
Copy Markdown
Contributor

You need to get the current groups to run this command and keep the existing groups I don't use tenant groups and did not look into how that could be done.

# Get tenant names from the https://api.partnercenter.microsoft.com/v1/customers MSPC endpoint. 
# This function is a workaround while until the following feature request is implemented https://github.com/KelvinTegelaar/CIPP/issues/6057
# The live company name is also available from Get-CIPPTenantDetails
$t = Get-M365Tenants
$tht = $t|group tenantid -AsHashTable

# Get CIPP Tenants
$ct = Get-CIPPTenants

# compare the live name with the name in CIPP
$ct2 = $ct|?{$tht.($_.customerid).companyname -ne $_.displayname}|select *,@{n="MSPCDisplayName";e={$tht.($_.customerid).companyname}}
$ct2 = $ct2|?{$_.mspcdisplayname}
$ct2|select customerId,displayname,mspcdisplayname

This is what I used prior to making this function:

$endpoint = "/api/EditTenant"
$method = "POST"

$ct2|%{
        $body = @{tenantAlias = $_.MSPCDisplayName; tenantGroups = @(); customerId = $_.customerId}
        Invoke-CIPPRestMethod -Endpoint $endpoint -Method $method -Body $Body
}

This is what I will use when syncing names manually in the future:

$ct2|%{
        Set-CIPPTenantProperty -CustomerTenantID $_.customerId -TenantAlias $_.MSPCDisplayName
}

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new tenant administration cmdlet intended to update CIPP tenant properties, especially tenant aliases, through the /api/EditTenant endpoint.

Changes:

  • Adds a new public PowerShell script for setting tenant properties.
  • Builds a request body with customer ID, tenant alias, and tenant groups.
  • Calls Invoke-CIPPRestMethod with POST against /api/EditTenant.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

[string]$TenantAlias,

[Parameter(Mandatory = $true)]
[hashtable][]$TenantGroups = @(),
Comment on lines +34 to +35
[Parameter(Mandatory = $true)]
[hashtable][]$TenantGroups = @(),
$body = @{
customerId = $CustomerTenantID
tenantAlias = $tenantAlias
tenantGroups = $tenantGroups
Set-CIPPTenantProperty -CustomerTenantID "12345678-1234-1234-1234-1234567890ab" -TenantAlias "Contoso, LLC" -TenantGroups
Adds or updates the TenantAlias and TenantGroups for the specified tenant.
#>
function Set-CIPPCustomVariable {

@kris6673 kris6673 May 27, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function name should be the same as the file name. You reference 3 names in total:

  • Set-CIPPTenantProperty
  • Set-CIPPTenantProperties
  • Set-CIPPCustomVariable

I'm guessing you want it to be named Set-CIPPTenantProperty? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants