Skip to content

Commit 645b57a

Browse files
authored
Merge branch 'KelvinTegelaar:dev' into dev
2 parents a9e5f14 + 9d8efca commit 645b57a

5 files changed

Lines changed: 188 additions & 1 deletion

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using namespace System.Net
2+
3+
Function Invoke-ExecRemoveTeamsVoicePhoneNumberAssignment {
4+
<#
5+
.FUNCTIONALITY
6+
Entrypoint
7+
.ROLE
8+
Teams.Voice.ReadWrite
9+
#>
10+
[CmdletBinding()]
11+
param($Request, $TriggerMetadata)
12+
13+
$APIName = $TriggerMetadata.FunctionName
14+
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
15+
16+
$tenantFilter = $Request.Body.TenantFilter
17+
try {
18+
$null = New-TeamsRequest -TenantFilter $TenantFilter -Cmdlet 'Remove-CsPhoneNumberAssignment' -CmdParams @{Identity = $Request.Body.AssignedTo; PhoneNumber = $Request.Body.PhoneNumber; PhoneNumberType = $Request.Body.PhoneNumberType; ErrorAction = 'stop'}
19+
$Results = [pscustomobject]@{'Results' = "Successfully unassigned $($Request.Body.PhoneNumber) from $($Request.Body.AssignedTo)"}
20+
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($TenantFilter) -message $($Results.Results) -Sev 'Info'
21+
} catch {
22+
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
23+
$Results = [pscustomobject]@{'Results' = $ErrorMessage}
24+
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($TenantFilter) -message $($Results.Results) -Sev 'Error'
25+
}
26+
# Associate values to output bindings by calling 'Push-OutputBinding'.
27+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
28+
StatusCode = [HttpStatusCode]::OK
29+
Body = $Results
30+
})
31+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using namespace System.Net
2+
3+
Function Invoke-ExecTeamsVoicePhoneNumberAssignment {
4+
<#
5+
.FUNCTIONALITY
6+
Entrypoint
7+
.ROLE
8+
Teams.Voice.ReadWrite
9+
#>
10+
[CmdletBinding()]
11+
param($Request, $TriggerMetadata)
12+
13+
$APIName = $TriggerMetadata.FunctionName
14+
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
15+
16+
$tenantFilter = $Request.Body.TenantFilter
17+
try {
18+
if ($Request.Body.locationOnly) {
19+
$null = New-TeamsRequest -TenantFilter $TenantFilter -Cmdlet 'Set-CsPhoneNumberAssignment' -CmdParams @{LocationId = $Request.Body.input; PhoneNumber = $Request.Body.PhoneNumber; ErrorAction = 'stop'}
20+
$Results = [pscustomobject]@{'Results' = "Successfully assigned emergency location to $($Request.Body.PhoneNumber)"}
21+
} else {
22+
$null = New-TeamsRequest -TenantFilter $TenantFilter -Cmdlet 'Set-CsPhoneNumberAssignment' -CmdParams @{Identity = $Request.Body.input; PhoneNumber = $Request.Body.PhoneNumber; PhoneNumberType = $Request.Body.PhoneNumberType; ErrorAction = 'stop'}
23+
$Results = [pscustomobject]@{'Results' = "Successfully assigned $($Request.Body.PhoneNumber) to $($Request.Body.input)"}
24+
}
25+
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($TenantFilter) -message $($Results.Results) -Sev 'Info'
26+
} catch {
27+
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
28+
$Results = [pscustomobject]@{'Results' = $ErrorMessage}
29+
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -tenant $($TenantFilter) -message $($Results.Results) -Sev 'Error'
30+
}
31+
# Associate values to output bindings by calling 'Push-OutputBinding'.
32+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
33+
StatusCode = [HttpStatusCode]::OK
34+
Body = $Results
35+
})
36+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using namespace System.Net
2+
3+
Function Invoke-ListTeamsLisLocation {
4+
<#
5+
.FUNCTIONALITY
6+
Entrypoint
7+
.ROLE
8+
Teams.Voice.Read
9+
#>
10+
[CmdletBinding()]
11+
param($Request, $TriggerMetadata)
12+
13+
$APIName = $TriggerMetadata.FunctionName
14+
Write-LogMessage -user $request.headers.'x-ms-client-principal' -API $APINAME -message 'Accessed this API' -Sev 'Debug'
15+
16+
$TenantFilter = $Request.Query.TenantFilter
17+
try {
18+
$EmergencyLocations = New-TeamsRequest -TenantFilter $TenantFilter -Cmdlet 'Get-CsOnlineLisLocation'
19+
$StatusCode = [HttpStatusCode]::OK
20+
} catch {
21+
$ErrorMessage = Get-NormalizedError -Message $_.Exception.Message
22+
$StatusCode = [HttpStatusCode]::Forbidden
23+
$EmergencyLocations = $ErrorMessage
24+
}
25+
# Associate values to output bindings by calling 'Push-OutputBinding'.
26+
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
27+
StatusCode = $StatusCode
28+
Body = @($EmergencyLocations)
29+
})
30+
31+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
2+
Function Set-CIPPAlwaysShowFrom {
3+
<#
4+
.SYNOPSIS
5+
Sets the "Always Show From" property for a user or all users in a tenant.
6+
7+
.DESCRIPTION
8+
The Set-CIPPAlwaysShowFrom function is used to set the "Always Show From" property for a specified user or all users in a specified tenant. The "Always Show From" property determines whether the from field is always shown in Outlook.
9+
10+
.PARAMETER UserID
11+
Specifies the user ID for which to set the "Always Show From" property. This can be UserPrincipalName, SamAccountName, GUID or Email address.
12+
This parameter is mandatory unless the RunOnAllUsersInTenant switch is used.
13+
14+
.PARAMETER TenantFilter
15+
Specifies the tenant for which to set the "Always Show From" property. This parameter is mandatory.
16+
17+
.PARAMETER APIName
18+
Specifies the name of the API. The default value is "Always Show From".
19+
20+
.PARAMETER ExecutingUser
21+
Specifies the user who is executing the function.
22+
23+
.PARAMETER AlwaysShowFrom
24+
Specifies whether to set the "Always Show From" property to true or false. This parameter is mandatory.
25+
26+
.PARAMETER RunOnAllUsersInTenant
27+
If this switch is present, the function will set the "Always Show From" property for all users in the specified tenant.
28+
29+
.EXAMPLE
30+
Set-CIPPAlwaysShowFrom -UserID "john.doe@example.com" -TenantFilter "example.com" -AlwaysShowFrom $true
31+
Sets the "Always Show From" property to true for the user "john.doe@example.com" in the "example.com" tenant.
32+
33+
.EXAMPLE
34+
Set-CIPPAlwaysShowFrom -TenantFilter "example.com" -AlwaysShowFrom $true -RunOnAllUsersInTenant
35+
Sets the "Always Show From" property to true for all users in the "example.com" tenant.
36+
#>
37+
[CmdletBinding(DefaultParameterSetName = 'User')]
38+
param (
39+
[Parameter(Mandatory = $true, ParameterSetName = 'User')]
40+
[Parameter(Mandatory = $false, ParameterSetName = 'AllUsers')]
41+
[Alias('Username')][string]$UserID,
42+
43+
[Parameter(Mandatory = $true, ParameterSetName = 'User')]
44+
[Parameter(Mandatory = $true, ParameterSetName = 'AllUsers')]
45+
$TenantFilter,
46+
47+
[Parameter(ParameterSetName = 'User')]
48+
[Parameter(ParameterSetName = 'AllUsers')]
49+
$APIName = 'Always Show From',
50+
51+
[Parameter(ParameterSetName = 'User')]
52+
[Parameter(ParameterSetName = 'AllUsers')]
53+
$ExecutingUser,
54+
55+
[Parameter(Mandatory = $true, ParameterSetName = 'User')]
56+
[Parameter(Mandatory = $true, ParameterSetName = 'AllUsers')]
57+
[bool]$AlwaysShowFrom,
58+
59+
[Parameter(ParameterSetName = 'AllUsers')]
60+
[switch]$RunOnAllUsersInTenant
61+
)
62+
63+
64+
if ($RunOnAllUsersInTenant.IsPresent -eq $true) {
65+
$AllUsers = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Get-Mailbox' -cmdParams @{ ResultSize = 'Unlimited' }
66+
Write-LogMessage -user $ExecutingUser -API $APIName -message "Setting Always Show From to $AlwaysShowFrom for all $($AllUsers.Count) users in $TenantFilter" -Sev 'Info' -tenant $TenantFilter
67+
$ErrorCount = 0
68+
foreach ($User in $AllUsers) {
69+
try {
70+
$null = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Set-MailboxMessageConfiguration' -anchor $User.UserPrincipalName -cmdParams @{AlwaysShowFrom = $AlwaysShowFrom; Identity = $User.UserPrincipalName }
71+
# Write-Information "Set Always Show From to $AlwaysShowFrom for $($User.UserPrincipalName)"
72+
} catch {
73+
$ErrorCount++
74+
}
75+
}
76+
Write-LogMessage -user $ExecutingUser -API $APIName -message "Set Always Show From to $AlwaysShowFrom for $($AllUsers.Count - $ErrorCount) users in $TenantFilter" -Sev 'Info' -tenant $TenantFilter
77+
return "Set Always Show From to $AlwaysShowFrom for $($AllUsers.Count - $ErrorCount) users in $TenantFilter"
78+
} else {
79+
try {
80+
$null = New-ExoRequest -tenantid $TenantFilter -cmdlet 'Set-MailboxMessageConfiguration' -anchor $UserID -cmdParams @{AlwaysShowFrom = $AlwaysShowFrom; Identity = $UserID }
81+
Write-LogMessage -user $ExecutingUser -API $APIName -message "Set Always Show From to $AlwaysShowFrom for $UserID" -Sev 'Info' -tenant $TenantFilter
82+
} catch {
83+
$ErrorMessage = Get-CippException -Exception $_
84+
Write-LogMessage -user $ExecutingUser -API $APIName -message "Could not set Always Show From to $AlwaysShowFrom for $UserID. Error: $($ErrorMessage.NormalizedError)" -Sev 'Error' -tenant $TenantFilter -LogData $ErrorMessage
85+
return "Could not set Always Show From to $AlwaysShowFrom for $UserID. Error: $($ErrorMessage.NormalizedError)"
86+
}
87+
return "Set Always Show From to $AlwaysShowFrom for $UserID"
88+
}
89+
}

version_latest.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.2.3
1+
6.3.0

0 commit comments

Comments
 (0)