-
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 #6 from BNWEIN/Dev
Added Functions
- Loading branch information
Showing
14 changed files
with
426 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
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' | ||
} |
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
52 changes: 52 additions & 0 deletions
52
CIPPAPIModule/public/Teams-Sharepoint/OneDrive/Set-CIPPOneDrivePerms.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,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 | ||
} |
54 changes: 54 additions & 0 deletions
54
CIPPAPIModule/public/Teams-Sharepoint/Sharepoint/Set-CIPPSharePointSiteAdmin.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,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 | ||
} |
60 changes: 60 additions & 0 deletions
60
CIPPAPIModule/public/Teams-Sharepoint/Sharepoint/Set-CIPPSharePointSiteMembers.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,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 | ||
} |
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,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** | ||
>   \ | ||
The ID of the customer's tenant. | ||
|
||
## **-User** | ||
>   \ | ||
The user for whom the out of office settings should be set. | ||
|
||
## **-autoreplystate** | ||
>   \ | ||
The auto reply state. Valid values are 'Scheduled', 'Disabled', or 'Enabled'. | ||
|
||
## **-externalmessage** | ||
>   \ | ||
The external message to be sent as an auto reply. | ||
|
||
## **-internalmessage** | ||
>   \ | ||
The internal message to be sent as an auto reply. | ||
|
||
## **-endtime** | ||
>   \ | ||
The end time for the out of office settings. This parameter is mandatory when autoreplystate is 'Scheduled'. | ||
|
||
## **-starttime** | ||
>   \ | ||
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"" | ||
``` | ||
|
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,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** | ||
>   \ | ||
The ID of the customer's tenant. | ||
|
||
## **-OneDriveUserUPN** | ||
>   \ | ||
The User Principal Name (UPN) of the OneDrive user. | ||
|
||
## **-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. | ||
|
||
## **-GiveAccessToUPN** | ||
>   \ | ||
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" | ||
``` | ||
|
Oops, something went wrong.