Skip to content

Commit

Permalink
Merge pull request #6 from BNWEIN/Dev
Browse files Browse the repository at this point in the history
Added Functions
  • Loading branch information
BNWEIN authored Jun 21, 2024
2 parents 1042a0c + 06ed049 commit 4ae2f18
Show file tree
Hide file tree
Showing 14 changed files with 426 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CIPPAPIModule/CIPPAPIModule.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'CIPPAPIModule.psm1'

# Version number of this module.
ModuleVersion = '1.1.0'
ModuleVersion = '1.1.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
91 changes: 91 additions & 0 deletions CIPPAPIModule/public/Email-Exchange/Set-CIPPOOO.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<#
.SYNOPSIS
Sets the out of office settings for a user.
.DESCRIPTION
The Set-CIPPOOO function is used to set the out of office settings for a user in a customer's Exchange environment. It allows you to specify the customer tenant ID, user, auto reply state, external message, internal message, start time, and end time for the out of office settings.
.PARAMETER CustomerTenantID
The ID of the customer's tenant.
.PARAMETER User
The user for whom the out of office settings should be set.
.PARAMETER autoreplystate
The auto reply state. Valid values are 'Scheduled', 'Disabled', or 'Enabled'.
.PARAMETER externalmessage
The external message to be sent as an auto reply.
.PARAMETER internalmessage
The internal message to be sent as an auto reply.
.PARAMETER endtime
The end time for the out of office settings. This parameter is mandatory when autoreplystate is 'Scheduled'.
.PARAMETER starttime
The start time for the out of office settings. This parameter is mandatory when autoreplystate is 'Scheduled'.
.EXAMPLE
Set-CIPPOOO -CustomerTenantID "contoso.onmicrosoft.com" -User "john.doe@contoso.onmicrosoft.com" -autoreplystate "Disabled"
Sets the out of office settings for the user "john.doe@contoso.onmicrosoft.com" in the customer's tenant with ID "contoso.onmicrosoft.com". The auto reply state is set to "Disable"
.EXAMPLE
Set-CIPPOOO -CustomerTenantID "contoso.onmicrosoft.com" -User "john.doe@contoso.onmicrosoft.com" -autoreplystate "Enabled"
Sets the out of office settings for the user "john.doe@contoso.onmicrosoft.com" in the customer's tenant with ID "contoso.onmicrosoft.com". The auto reply state is set to "Enabled"
.EXAMPLE
Set-CIPPOOO -CustomerTenantID "contoso.onmicrosoft.com" -User "john.doe@contoso.onmicrosoft.com" -autoreplystate "Enabled" -externalmessage "I'm currently out of office." -internalmessage "I'm currently out of office." -starttime 2024-06-21 14:00" -endtime "2024-06-21 14:30""
Sets the out of office settings for the user "john.doe@contoso.onmicrosoft.com" in the customer's tenant with ID "@contoso.onmicrosoft.com". The auto reply state is set to "Enabled" and the external and internal messages are set to "I'm currently out of office.". The out of office settings are scheduled to start on "2024-06-21 14:00" and end on "2024-06-21 14:30".
#>

function Set-CIPPOOO {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$CustomerTenantID,
[Parameter(Mandatory = $true)]
[string]$User,
[Parameter(Mandatory = $true)]
[ValidateSet(
'Scheduled',
'Disabled',
'Enabled'
)]
[string]$autoreplystate,
[Parameter(Mandatory = $false)]
[string]$externalmessage,
[Parameter(Mandatory = $false)]
[string]$internalmessage,
[Parameter(Mandatory = $false)]
[datetime]$endtime,
[Parameter(Mandatory = $false)]
[datetime]$starttime
)

Write-Verbose "Setting out of office for $User to $autoreplystate"

if ($autoreplystate -eq 'Scheduled') {
if (-not $PSBoundParameters.ContainsKey('starttime')) {
throw "Start time is mandatory when autoreplystate is 'Scheduled'."
}
if (-not $PSBoundParameters.ContainsKey('endtime')) {
throw "End time is mandatory when autoreplystate is 'Scheduled'."
}
}

$endpoint = "/api/execsetooo"
$body = @{
TenantFilter = $CustomerTenantID
User = $User
AutoReplyState = $autoreplystate
externalmessage = $externalmessage
internalmessage = $internalmessage
endtime = $endtime
starttime = $starttime
input = $Input
}

Invoke-CIPPRestMethod -Endpoint $endpoint -body $body -Method 'POST'
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ function Set-CIPPRevokeSessions {
[Parameter(Mandatory = $true)]
[string]$CustomerTenantID,
[Parameter(Mandatory = $true)]
[string]$UserID
[string]$UserID,
[Parameter(Mandatory = $true)]
[string]$UserName
)

Write-Verbose "Revoking Sessions for user: $UserID"
Expand All @@ -32,6 +34,7 @@ function Set-CIPPRevokeSessions {
$params = @{
TenantFilter = $CustomerTenantID
ID = $UserID
UserName = $UserName

}
Invoke-CIPPRestMethod -Endpoint $endpoint -Params $params
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<#
.SYNOPSIS
Sets permissions for a user on a OneDrive.
.DESCRIPTION
The Set-CIPPOneDrivePerms function is used to give or remove access permissions for a specified user on a OneDrive.
.PARAMETER CustomerTenantID
The ID of the customer's tenant.
.PARAMETER OneDriveUserUPN
The User Principal Name (UPN) of the OneDrive user.
.PARAMETER RemovePermission
Specifies whether to remove the access permission for the specified user. If set to $true, the permission will be removed. If set to $false, the permission will be granted.
.PARAMETER GiveAccessToUPN
The User Principal Name (UPN) of the user to whom access is being granted or removed.
.EXAMPLE
Set-CIPPOneDrivePerms -CustomerTenantID "contoso.onmicrosoft.com" -OneDriveUserUPN "john@contoso.com" -RemovePermission $false -GiveAccessToUPN "jane@contoso.com"
Grants access to "jane@contoso.com" on the OneDrive of user "john@contoso.com" in the "contoso.onmicrosoft.com" tenant.
.EXAMPLE
Set-CIPPOneDrivePerms -CustomerTenantID "contoso.onmicrosoft.com" -OneDriveUserUPN "john@contoso.com" -RemovePermission $true -GiveAccessToUPN "jane@contoso.com"
Removes access for "jane@contoso.com" from the OneDrive of user "john@contoso.com" in the "contoso.onmicrosoft.com" tenant.
#>
function Set-CIPPOneDrivePerms {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$CustomerTenantID,
[Parameter(Mandatory = $true)]
[string]$OneDriveUserUPN,
[Parameter(Mandatory = $true)]
[bool]$RemovePermission,
[Parameter(Mandatory = $true)]
[string]$GiveAccessToUPN
)

Write-Verbose "Giving access to $GiveAccessToUPN on $OneDriveUserUPN's OneDrive."
$endpoint = "/api/ExecSharePointPerms"
$body = @{
TenantFilter = $CustomerTenantID
UPN = $OneDriveUserUPN
URL = $SiteUrl
RemovePermission = $RemovePermission
input = $GiveAccessToUPN
}

Invoke-CIPPRestMethod -Endpoint $endpoint -Body $body -Method POST
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<#
.SYNOPSIS
Sets the SharePoint site admin for a given site.
.DESCRIPTION
The Set-CIPPSharePointSiteAdmin function sets the SharePoint site admin for a specified site by making a REST API call to the CIPP API.
.PARAMETER CustomerTenantID
The ID of the customer's tenant.
.PARAMETER CurrentAdminUPN
The UPN (User Principal Name) of the current site admin.
.PARAMETER SiteUrl
The URL of the SharePoint site.
.PARAMETER RemovePermission
Specifies whether to remove the admin permission for the current admin UPN.
.PARAMETER AdditionalAdminUPN
The UPN of the additional admin to be added.
.EXAMPLE
Set-CIPPSharePointSiteAdmin -CustomerTenantID "contoso.onmicrosoft.com" -CurrentAdminUPN "admin@contoso.com" -SiteUrl "https://contoso.sharepoint.com/sites/site1" -RemovePermission $true -AdditionalAdminUPN "admin2@contoso.com"
Sets the SharePoint site admin for the site "https://contoso.sharepoint.com/sites/site1" by removing the admin permission for "admin@contoso.com" and adding "admin2@contoso.com" as an additional admin.
#>
function Set-CIPPSharePointSiteAdmin {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$CustomerTenantID,
[Parameter(Mandatory = $true)]
[string]$CurrentAdminUPN,
[Parameter(Mandatory = $true)]
[string]$SiteUrl,
[Parameter(Mandatory = $true)]
[bool]$RemovePermission,
[Parameter(Mandatory = $true)]
[string]$AdditionalAdminUPN
)

Write-Verbose "Setting SharePoint Owner on $Url"
$endpoint = "/api/ExecSharePointPerms"
$body = @{
TenantFilter = $CustomerTenantID
UPN = $CurrentAdminUPN
URL = $SiteUrl
RemovePermission = $RemovePermission
input = $AdditionalAdminUPN
}

Invoke-CIPPRestMethod -Endpoint $endpoint -Body $body -Method POST
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<#
.SYNOPSIS
Sets SharePoint site members with specified permissions.
.DESCRIPTION
The Set-CIPPSharePointSiteMembers function is used to set SharePoint site members with specified permissions. It sends a request to the CIPP API to execute the operation.
.PARAMETER CustomerTenantID
Specifies the ID of the customer's tenant.
.PARAMETER SharePointType
Specifies the type of SharePoint site.
.PARAMETER SiteUrl
Specifies the URL of the SharePoint site.
.PARAMETER AddPermission
Specifies whether to add or remove permissions for the user.
.PARAMETER GroupUPN
Specifies the UPN (User Principal Name) of the site group.
.PARAMETER UserToGiveAccessUPN
Specifies the UPN of the user to give access to.
.EXAMPLE
Set-CIPPSharePointSiteMembers -CustomerTenantID "contoso.onmicrosoft.com" -SharePointType "Group" -SiteUrl "https://contoso.sharepoint.com/sites/TeamSite" -AddPermission $true -GroupUPN "group@contoso.com" -UserToGiveAccessUPN "user@contoso.com"
Sets the SharePoint site members by adding permissions for the specified user.
.
#>
function Set-CIPPSharePointSiteMembers {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$CustomerTenantID,
[Parameter(Mandatory = $true)]
[string]$SharePointType,
[Parameter(Mandatory = $true)]
[string]$SiteUrl,
[Parameter(Mandatory = $true)]
[bool]$AddPermission,
[Parameter(Mandatory = $true)]
[string]$GroupUPN,
[Parameter(Mandatory = $true)]
[string]$UserToGiveAccessUPN
)

Write-Verbose "Setting SharePoint Member on $Url"
$endpoint = "/api/ExecSetSharePointMember"
$body = @{
TenantFilter = $CustomerTenantID
SharePointType = $SharePointType
URL = $SiteUrl
add = $AddPermission
GroupId = $GroupUPN
input = $UserToGiveAccessUPN
}

Invoke-CIPPRestMethod -Endpoint $endpoint -Body $body -Method POST
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ The Get-CIPPTeamsVoice function retrieves teams voice information for a specifie
The customer tenant ID for which to retrieve teams voice information. This parameter is mandatory.
.EXAMPLE
Get-CIPPTeamsVoice -CustomerTenantID "7ced1621-b8f7-4231-868c-bc6b1a2f1778"
Retrieves teams voice information for the customer tenant with the ID "7ced1621-b8f7-4231-868c-bc6b1a2f1778".
Get-CIPPTeamsVoice -CustomerTenantID "contoso.onmicrosoft.com"
Retrieves teams voice information for the customer tenant with the ID "contoso.onmicrosoft.com".
#>
function Get-CIPPTeamsVoice {
Expand Down
2 changes: 1 addition & 1 deletion Docs/Get-CIPPTeamsVoice.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ The customer tenant ID for which to retrieve teams voice information. This param

#### EXAMPLE 1
```powershell
PS > Get-CIPPTeamsVoice -CustomerTenantID "7ced1621-b8f7-4231-868c-bc6b1a2f1778"
PS > Get-CIPPTeamsVoice -CustomerTenantID "contoso.onmicrosoft.com"
```

48 changes: 48 additions & 0 deletions Docs/Set-CIPPOOO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Set-CIPPOOO
## SYNOPSIS
Sets the out of office settings for a user.
## DESCRIPTION
The Set-CIPPOOO function is used to set the out of office settings for a user in a customer's Exchange environment. It allows you to specify the customer tenant ID, user, auto reply state, external message, internal message, start time, and end time for the out of office settings.
# PARAMETERS

## **-CustomerTenantID**
> ![Foo](https://img.shields.io/badge/Type-String-Blue?) ![Foo](https://img.shields.io/badge/Mandatory-TRUE-Red?) \
The ID of the customer's tenant.

## **-User**
> ![Foo](https://img.shields.io/badge/Type-String-Blue?) ![Foo](https://img.shields.io/badge/Mandatory-TRUE-Red?) \
The user for whom the out of office settings should be set.

## **-autoreplystate**
> ![Foo](https://img.shields.io/badge/Type-String-Blue?) ![Foo](https://img.shields.io/badge/Mandatory-TRUE-Red?) \
The auto reply state. Valid values are 'Scheduled', 'Disabled', or 'Enabled'.

## **-externalmessage**
> ![Foo](https://img.shields.io/badge/Type-String-Blue?) ![Foo](https://img.shields.io/badge/Mandatory-FALSE-Green?) \
The external message to be sent as an auto reply.

## **-internalmessage**
> ![Foo](https://img.shields.io/badge/Type-String-Blue?) ![Foo](https://img.shields.io/badge/Mandatory-FALSE-Green?) \
The internal message to be sent as an auto reply.

## **-endtime**
> ![Foo](https://img.shields.io/badge/Type-DateTime-Blue?) ![Foo](https://img.shields.io/badge/Mandatory-FALSE-Green?) \
The end time for the out of office settings. This parameter is mandatory when autoreplystate is 'Scheduled'.

## **-starttime**
> ![Foo](https://img.shields.io/badge/Type-DateTime-Blue?) ![Foo](https://img.shields.io/badge/Mandatory-FALSE-Green?) \
The start time for the out of office settings. This parameter is mandatory when autoreplystate is 'Scheduled'.

#### EXAMPLE 1
```powershell
PS > Set-CIPPOOO -CustomerTenantID "contoso.onmicrosoft.com" -User "john.doe@contoso.onmicrosoft.com" -autoreplystate "Disabled"
```
#### EXAMPLE 2
```powershell
PS > Set-CIPPOOO -CustomerTenantID "contoso.onmicrosoft.com" -User "john.doe@contoso.onmicrosoft.com" -autoreplystate "Enabled"
```
#### EXAMPLE 3
```powershell
PS > Set-CIPPOOO -CustomerTenantID "contoso.onmicrosoft.com" -User "john.doe@contoso.onmicrosoft.com" -autoreplystate "Enabled" -externalmessage "I'm currently out of office." -internalmessage "I'm currently out of office." -starttime 2024-06-21 14:00" -endtime "2024-06-21 14:30""
```

32 changes: 32 additions & 0 deletions Docs/Set-CIPPOneDrivePerms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Set-CIPPOneDrivePerms
## SYNOPSIS
Sets permissions for a user on a OneDrive.
## DESCRIPTION
The Set-CIPPOneDrivePerms function is used to give or remove access permissions for a specified user on a OneDrive.
# PARAMETERS

## **-CustomerTenantID**
> ![Foo](https://img.shields.io/badge/Type-String-Blue?) ![Foo](https://img.shields.io/badge/Mandatory-TRUE-Red?) \
The ID of the customer's tenant.

## **-OneDriveUserUPN**
> ![Foo](https://img.shields.io/badge/Type-String-Blue?) ![Foo](https://img.shields.io/badge/Mandatory-TRUE-Red?) \
The User Principal Name (UPN) of the OneDrive user.

## **-RemovePermission**
> ![Foo](https://img.shields.io/badge/Type-Boolean-Blue?) ![Foo](https://img.shields.io/badge/Mandatory-TRUE-Red?) ![Foo](https://img.shields.io/badge/DefaultValue-False-Blue?color=5547a8)\
Specifies whether to remove the access permission for the specified user. If set to $true, the permission will be removed. If set to $false, the permission will be granted.

## **-GiveAccessToUPN**
> ![Foo](https://img.shields.io/badge/Type-String-Blue?) ![Foo](https://img.shields.io/badge/Mandatory-TRUE-Red?) \
The User Principal Name (UPN) of the user to whom access is being granted or removed.

#### EXAMPLE 1
```powershell
PS > Set-CIPPOneDrivePerms -CustomerTenantID "contoso.onmicrosoft.com" -OneDriveUserUPN "john@contoso.com" -RemovePermission $false -GiveAccessToUPN "jane@contoso.com"
```
#### EXAMPLE 2
```powershell
PS > Set-CIPPOneDrivePerms -CustomerTenantID "contoso.onmicrosoft.com" -OneDriveUserUPN "john@contoso.com" -RemovePermission $true -GiveAccessToUPN "jane@contoso.com"
```

Loading

0 comments on commit 4ae2f18

Please sign in to comment.