-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from BNWEIN/Dev
Dev to Main
- Loading branch information
Showing
10 changed files
with
278 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
CIPPAPIModule/public/Email-Exchange/Set-CIPPContact.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<# | ||
.SYNOPSIS | ||
Modifies a contact in the CIPP API. | ||
.DESCRIPTION | ||
The Set-CIPPContact function is used to edit a contact in the CIPP API. It allows you to modify various properties of the contact, such as display name, email address, first name, last name, job title, address, phone numbers, etc. | ||
.PARAMETER CustomerTenantID | ||
The ID of the customer tenant where the contact belongs. | ||
.PARAMETER ContactID | ||
The ID of the contact to be edited. | ||
.PARAMETER DisplayName | ||
The new display name for the contact. If not provided, the existing display name will be used. | ||
.PARAMETER ExternalEmailAddress | ||
The new external email address for the contact. If not provided, the existing email address will be used. | ||
.PARAMETER FirstName | ||
The new first name for the contact. If not provided, the existing first name will be used. | ||
.PARAMETER LastName | ||
The new last name for the contact. If not provided, the existing last name will be used. | ||
.PARAMETER JobTitle | ||
The new job title for the contact. If not provided, the existing job title will be used. | ||
.PARAMETER StreetAddress | ||
The new street address for the contact. If not provided, the existing street address will be used. | ||
.PARAMETER PostalCode | ||
The new postal code for the contact. If not provided, the existing postal code will be used. | ||
.PARAMETER City | ||
The new city for the contact. If not provided, the existing city will be used. | ||
.PARAMETER Country | ||
The new country for the contact. If not provided, the existing country will be used. This must be a valid ISO 3166-1 alpha-2 country code. | ||
.PARAMETER MobilePhone | ||
The new mobile phone number for the contact. If not provided, the existing mobile phone number will be used. | ||
.PARAMETER PhoneNumber | ||
The new business phone number for the contact. If not provided, the existing business phone number will be used. | ||
.EXAMPLE | ||
Set-CIPPContact -CustomerTenantID "contoso.onmicrosoft.com" -ContactID "46200db7-45cd-447e-a7d9-1d2feb91bb10" -DisplayName "John Doe" -JobTitle "Manager" | ||
This example edits the contact with ID "46200db7-45cd-447e-a7d9-1d2feb91bb10" in the customer tenant "contoso.onmicrosoft.com". It sets the display name to "John Doe" and the job title to "Manager". Other properties remain unchanged. | ||
#> | ||
|
||
function Set-CIPPContact { | ||
[CmdletBinding()] | ||
Param( | ||
[Parameter(Mandatory = $true)] | ||
[string]$CustomerTenantID, | ||
[Parameter(Mandatory = $true)] | ||
[string]$ContactID, | ||
[Parameter(Mandatory = $false)] | ||
[string]$DisplayName, | ||
[Parameter(Mandatory = $false)] | ||
[string]$ExternalEmailAddress, | ||
[Parameter(Mandatory = $false)] | ||
[string]$FirstName, | ||
[Parameter(Mandatory = $false)] | ||
[string]$LastName, | ||
[Parameter(Mandatory = $false)] | ||
[string]$JobTitle, | ||
[Parameter(Mandatory = $false)] | ||
[string]$StreetAddress, | ||
[Parameter(Mandatory = $false)] | ||
[string]$PostalCode, | ||
[Parameter(Mandatory = $false)] | ||
[string]$City, | ||
[Parameter(Mandatory = $false)] | ||
[string]$Country, | ||
[Parameter(Mandatory = $false)] | ||
[string]$MobilePhone, | ||
[Parameter(Mandatory = $false)] | ||
[string]$PhoneNumber | ||
) | ||
|
||
Write-Verbose "Editing Contact in tenant: $CustomerTenantID" | ||
|
||
$existingContact = Get-CIPPContacts -CustomerTenantID $CustomerTenantID -ContactID $ContactID | ||
|
||
# Filter to get the mobile and business phone numbers from the phones collection | ||
$existingMobilePhone = ($existingContact.phones | Where-Object { $_.type -eq 'mobile' }).number | ||
$existingBusinessPhone = ($existingContact.phones | Where-Object { $_.type -eq 'business' }).number | ||
|
||
$Endpoint = "/api/Editcontact" | ||
|
||
$body = @{ | ||
tenantID = $CustomerTenantID | ||
ContactID = $ContactID | ||
DisplayName = $DisplayName ? $DisplayName : $existingContact.DisplayName | ||
mail = $ExternalEmailAddress ? $ExternalEmailAddress : $existingContact.mail | ||
firstName = $FirstName ? $FirstName : $existingContact.givenName | ||
LastName = $LastName ? $LastName : $existingContact.surname | ||
jobTitle = $JobTitle ? $JobTitle : $existingContact.jobTitle | ||
Country = $Country ? $Country : $existingContact.addresses.CountryOrRegion | ||
PostalCode = $PostalCode ? $PostalCode : $existingContact.addresses.postalcode | ||
CompanyName = $CompanyName ? $CompanyName : $existingContact.companyName | ||
StreetAddress = $StreetAddress ? $StreetAddress : $existingContact.addresses.street | ||
MobilePhone = $MobilePhone ? $MobilePhone : $existingMobilePhone | ||
BusinessPhone = $PhoneNumber ? $PhoneNumber : $existingBusinessPhone | ||
City = $City ? $City : $existingContact.addresses.city | ||
} | ||
|
||
Invoke-CIPPRestMethod -Endpoint $Endpoint -Body $body -Method POST | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Set-CIPPContact | ||
## SYNOPSIS | ||
Modifies a contact in the CIPP API. | ||
## DESCRIPTION | ||
The Set-CIPPContact function is used to edit a contact in the CIPP API. It allows you to modify various properties of the contact, such as display name, email address, first name, last name, job title, address, phone numbers, etc. | ||
# PARAMETERS | ||
|
||
## **-CustomerTenantID** | ||
>   \ | ||
The ID of the customer tenant where the contact belongs. | ||
|
||
## **-ContactID** | ||
>   \ | ||
The ID of the contact to be edited. | ||
|
||
## **-DisplayName** | ||
>   \ | ||
The new display name for the contact. If not provided, the existing display name will be used. | ||
|
||
## **-ExternalEmailAddress** | ||
>   \ | ||
The new external email address for the contact. If not provided, the existing email address will be used. | ||
|
||
## **-FirstName** | ||
>   \ | ||
The new first name for the contact. If not provided, the existing first name will be used. | ||
|
||
## **-LastName** | ||
>   \ | ||
The new last name for the contact. If not provided, the existing last name will be used. | ||
|
||
## **-JobTitle** | ||
>   \ | ||
The new job title for the contact. If not provided, the existing job title will be used. | ||
|
||
## **-StreetAddress** | ||
>   \ | ||
The new street address for the contact. If not provided, the existing street address will be used. | ||
|
||
## **-PostalCode** | ||
>   \ | ||
The new postal code for the contact. If not provided, the existing postal code will be used. | ||
|
||
## **-City** | ||
>   \ | ||
The new city for the contact. If not provided, the existing city will be used. | ||
|
||
## **-Country** | ||
>   \ | ||
The new country for the contact. If not provided, the existing country will be used. This must be a valid ISO 3166-1 alpha-2 country code. | ||
|
||
## **-MobilePhone** | ||
>   \ | ||
The new mobile phone number for the contact. If not provided, the existing mobile phone number will be used. | ||
|
||
## **-PhoneNumber** | ||
>   \ | ||
The new business phone number for the contact. If not provided, the existing business phone number will be used. | ||
|
||
#### EXAMPLE 1 | ||
```powershell | ||
PS > Set-CIPPContact -CustomerTenantID "contoso.onmicrosoft.com" -ContactID "46200db7-45cd-447e-a7d9-1d2feb91bb10" -DisplayName "John Doe" -JobTitle "Manager" | ||
This example edits the contact with ID "46200db7-45cd-447e-a7d9-1d2feb91bb10" in the customer tenant "contoso.onmicrosoft.com". It sets the display name to "John Doe" and the job title to "Manager". Other properties remain unchanged. | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
function Update-ModuleVersion { | ||
param ( | ||
[string]$FilePath = "..\CIPPAPIModule\CIPPAPIModule\CIPPAPIModule.psd1" | ||
) | ||
|
||
# Read the file contents | ||
$content = Get-Content -Path $FilePath | ||
|
||
# Find the line with ModuleVersion | ||
$moduleVersionLine = $content | Where-Object { $_ -match "ModuleVersion\s*=\s*\'\d+\.\d+\.\d+\'" } | ||
|
||
if ($moduleVersionLine) { | ||
# Extract the version number | ||
$version = $moduleVersionLine -replace "ModuleVersion\s*=\s*\'([0-9]+\.[0-9]+\.[0-9]+)\'.*", '$1' | ||
|
||
# Split the version number into parts | ||
$versionParts = $version -split '\.' | ||
|
||
# Increment the patch version (third part) | ||
$versionParts[2] = [int]$versionParts[2] + 1 | ||
|
||
# Create the new version string | ||
$newVersion = "$($versionParts[0]).$($versionParts[1]).$($versionParts[2])" | ||
|
||
# Replace the old version line with the new version line | ||
$newContent = $content -replace "ModuleVersion\s*=\s*\'$version\'", "ModuleVersion = '$newVersion'" | ||
|
||
# Backup the original file | ||
Copy-Item -Path $FilePath -Destination "$FilePath.bak" -Force | ||
|
||
# Write the new contents back to the file | ||
Set-Content -Path $FilePath -Value $newContent | ||
|
||
Write-Host "Module version updated to $newVersion" | ||
} else { | ||
Write-Host "ModuleVersion line not found in the file." | ||
} | ||
} |