Skip to content

Commit

Permalink
Merge pull request #22 from BNWEIN/Dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
BNWEIN authored Sep 30, 2024
2 parents 617db4b + b8cf6c1 commit f202fd1
Show file tree
Hide file tree
Showing 156 changed files with 1,418 additions and 680 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.6'
ModuleVersion = '1.1.7'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
10 changes: 3 additions & 7 deletions CIPPAPIModule/CIPPAPIModule.psm1
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
$Functions = @(Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -Recurse -ErrorAction SilentlyContinue) + @(Get-ChildItem -Path $PSScriptRoot\private\*.ps1 -ErrorAction SilentlyContinue)
foreach ($import in @($Functions))
{
try
{
foreach ($import in @($Functions)) {
try {
. $import.FullName
}
catch
{
} catch {
Write-Error -Message "Failed to import function $($import.FullName): $_"
}
}
16 changes: 8 additions & 8 deletions CIPPAPIModule/private/Invoke-CIPPPreFlightCheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ function Invoke-CIPPPreFlightCheck {
[CmdletBinding()]
param ()
if ($null -eq $Script:CIPPClientID -or
$null -eq $Script:CIPPClientSecret -or
$null -eq $Script:CIPPAPIUrl -or
$null -eq $Script:TenantID) {
throw "Cannot continue: CIPP API information not found. Please run Set-CIPPAPIDetails before connecting to the API."
$null -eq $Script:CIPPClientSecret -or
$null -eq $Script:CIPPAPIUrl -or
$null -eq $Script:TenantID) {
throw 'Cannot continue: CIPP API information not found. Please run Set-CIPPAPIDetails before connecting to the API.'
break
}
Get-TokenExpiry
if ((-not $Script:ExpiryDateTime) -or ($script:ExpiryDateTime -lt (Get-Date))) {
write-Verbose "Token expired or not found. Connecting to CIPP"
Write-Verbose 'Token expired or not found. Connecting to CIPP'
$request = @{
CIPPClientID = $script:CIPPClientID
CIPPClientID = $script:CIPPClientID
CIPPClientSecret = $script:CIPPClientSecret
CIPPAPIUrl = $script:CIPPAPIUrl
TenantID = $TenantID
CIPPAPIUrl = $script:CIPPAPIUrl
TenantID = $TenantID
}

Connect-CIPP @request
Expand Down
6 changes: 3 additions & 3 deletions CIPPAPIModule/public/CIPP/Core/Get-CIPPAccessCheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ function Get-CIPPAccessCheck {
)

Write-Verbose "Running tenant access check for $CustomerTenantID"
$Endpoint = "/api/execaccesschecks"
$Endpoint = '/api/execaccesschecks'

$params = @{
tenants = "true"
tenants = 'true'
}
$body = @{
tenantid = $CustomerTenantID
tenantid = $CustomerTenantID
}
Invoke-CIPPRestMethod -Endpoint $Endpoint -Body $body -Params $params -Method POST
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ function Get-CIPPExecAPIPermissionsList {
[CmdletBinding()]
Param()

Write-Verbose "Getting CIPP Logs"
$endpoint = "/api/ExecAPIPermissionList"
Write-Verbose 'Getting CIPP Logs'
$endpoint = '/api/ExecAPIPermissionList'

Invoke-CIPPRestMethod -Endpoint $endpoint
}
Expand Down
10 changes: 5 additions & 5 deletions CIPPAPIModule/public/CIPP/Core/Get-CIPPFunctionParameters.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ function Get-CIPPFunctionParameters {
[bool]$Compliance = $false
)

Write-Verbose "Getting Function Parameters"
$Endpoint = "/api/ListFunctionParameters"
Write-Verbose 'Getting Function Parameters'
$Endpoint = '/api/ListFunctionParameters'

$params = @{
Module = $Module
Function = $Function
Compliance = $Compliance
Module = $Module
Function = $Function
Compliance = $Compliance
}

Invoke-CIPPRestMethod -Endpoint $Endpoint -Params $params
Expand Down
2 changes: 1 addition & 1 deletion CIPPAPIModule/public/CIPP/Core/Get-CIPPKnownIPDB.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function Get-CIPPKnownIPDB {
)

Write-Verbose "Getting Known IP Database for $CustomerTenantID"
$endpoint = "/api/listknownipdb"
$endpoint = '/api/listknownipdb'
$params = @{
tenantfilter = $CustomerTenantID
}
Expand Down
22 changes: 11 additions & 11 deletions CIPPAPIModule/public/CIPP/Core/Get-CIPPLogs.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ function Get-CIPPLogs {
Param(
[Parameter(Mandatory = $false)]
[ValidateSet(
"error",
"alert",
"debug",
"info",
"warn",
"critical"
'error',
'alert',
'debug',
'info',
'warn',
'critical'
)]
[string]$Severity,

[Parameter(Mandatory = $false)]
[string]$DateFilter = (Get-Date -Format "yyyyMMdd")
[string]$DateFilter = (Get-Date -Format 'yyyyMMdd')
)

$endpoint = "/api/ListLogs"
$endpoint = '/api/ListLogs'


$Params = @{
'Filter' = $True
'Filter' = $True
'DateFilter' = $DateFilter
}

if($Severity){
if ($Severity) {
$Params['Severity'] = $Severity
}

Write-Verbose "Getting CIPP Logs"
Write-Verbose 'Getting CIPP Logs'
Invoke-CIPPRestMethod -Endpoint $endpoint -Param $Params
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function Get-CIPPPublicPhishingCheck {
)

Write-Verbose "Getting public phishing check $CustomerTenantID"
$endpoint = "/api/publicphishingcheck"
$endpoint = '/api/publicphishingcheck'
$params = @{
tenantfilter = $CustomerTenantID
}
Expand Down
26 changes: 13 additions & 13 deletions CIPPAPIModule/public/CIPP/Core/Set-CIPPExecCPVPerms.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@ Refreshes the CPV permissions for the customer tenant with the ID "87654321-4321
#>
function Set-CIPPExecCPVPerms {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[guid]$CustomerTenantID,
[Parameter(Mandatory = $false)]
[ValidateSet(
"true",
"false"
)]
[string]$resetsp = "false"
)
Param(
[Parameter(Mandatory = $true)]
[guid]$CustomerTenantID,
[Parameter(Mandatory = $false)]
[ValidateSet(
'true',
'false'
)]
[string]$resetsp = 'false'
)

Write-Verbose "Refreshing CPV for $CustomerTenantID"
$endpoint = "/api/execcpvpermissions"
$endpoint = '/api/execcpvpermissions'
$params = @{
tenantfilter = $CustomerTenantID
ResetSP = $resetsp
tenantfilter = $CustomerTenantID
ResetSP = $resetsp
}
Invoke-CIPPRestMethod -Endpoint $endpoint -Params $params
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ function Get-CIPPExcludedLicenses {
[CmdletBinding()]
Param()

Write-Verbose "Getting Excluded License List"
Write-Verbose 'Getting Excluded License List'

$endpoint = "/api/execexcludelicenses"
$endpoint = '/api/execexcludelicenses'
$params = @{
List = "true"
List = 'true'
}

Invoke-CIPPRestMethod -Endpoint $endpoint -Params $params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ function Get-CIPPExcludedTenants {
[switch]$ListAll
)

Write-Verbose "Getting Excluded Tenants List"
Write-Verbose 'Getting Excluded Tenants List'

$endpoint = "/api/execexcludetenant"
$endpoint = '/api/execexcludetenant'
if (!$listAll) {
$params = @{
List = "true"
List = 'true'
}
} else {
$params = @{
ListAll = "true"
ListAll = 'true'
}
}

Expand Down
4 changes: 2 additions & 2 deletions CIPPAPIModule/public/CIPP/Settings/Get-CIPPVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ function Get-CIPPVersion {
[CmdletBinding()]
Param()

Write-Verbose "Getting CIPP Version"
$endpoint = "/api/Getversion"
Write-Verbose 'Getting CIPP Version'
$endpoint = '/api/Getversion'

Invoke-CIPPRestMethod -Endpoint $endpoint
}
10 changes: 5 additions & 5 deletions CIPPAPIModule/public/CIPP/Settings/Set-CIPPExcludeLicense.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ function Set-CIPPExcludeLicense {

# Ensure only one of the switches is used
if ($AddExclusion -and $RemoveExclusion) {
throw "You cannot use both -AddExclusion and -RemoveExclusion switches at the same time."
throw 'You cannot use both -AddExclusion and -RemoveExclusion switches at the same time.'
}

if (-not $AddExclusion -and -not $RemoveExclusion) {
throw "You must specify either -AddExclusion or -RemoveExclusion switch."
throw 'You must specify either -AddExclusion or -RemoveExclusion switch.'
}

$endpoint = "/api/execexcludelicenses"
$endpoint = '/api/execexcludelicenses'

if ($RemoveExclusion) {
$params = @{
GUID = $LicenseGUID
GUID = $LicenseGUID
RemoveExclusion = $true
}
Write-Verbose "Removing License $LicenseGUID from the exclusion list."
Expand All @@ -62,7 +62,7 @@ function Set-CIPPExcludeLicense {
AddExclusion = $true
}
$body = @{
GUID = $LicenseGUID
GUID = $LicenseGUID
SKUName = $SKUName
}
Write-Verbose "Adding License $LicenseGUID to the exclusion list."
Expand Down
8 changes: 4 additions & 4 deletions CIPPAPIModule/public/CIPP/Settings/Set-CIPPExcludeTenant.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ function Set-CIPPExcludeTenant {

# Ensure only one of the switches is used
if ($AddExclusion -and $RemoveExclusion) {
throw "You cannot use both -AddExclusion and -RemoveExclusion switches at the same time."
throw 'You cannot use both -AddExclusion and -RemoveExclusion switches at the same time.'
}

if (-not $AddExclusion -and -not $RemoveExclusion) {
throw "You must specify either -AddExclusion or -RemoveExclusion switch."
throw 'You must specify either -AddExclusion or -RemoveExclusion switch.'
}

$endpoint = "/api/execexcludetenant"
$endpoint = '/api/execexcludetenant'

if ($RemoveExclusion) {
$params = @{
TenantFilter = $CustomerTenantID
TenantFilter = $CustomerTenantID
RemoveExclusion = $true
}
Write-Verbose "Removing Tenant $CustomerTenantID from the exclusion list."
Expand Down
14 changes: 7 additions & 7 deletions CIPPAPIModule/public/CIPP/Settings/Set-CIPPPasswordSettings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ function Set-CIPPPasswordSettings {
Param(
[Parameter(Mandatory = $false)]
[ValidateSet(
"Correct-Battery-Horse",
"Classic"
)]
'Correct-Battery-Horse',
'Classic'
)]
[string]$Type,
[Parameter(Mandatory = $false)]
[bool]$List
)

Write-Verbose "Getting CIPP Password Settings"
Write-Verbose 'Getting CIPP Password Settings'

$endpoint = "/api/execpasswordconfig"
$endpoint = '/api/execpasswordconfig'

if ($List) {
$params = @{
List = "true"
List = 'true'
}
Invoke-CIPPRestMethod -Endpoint $endpoint -Params $params
} else {
$body = @{
passwordType = $Type
}
Invoke-CIPPRestMethod -Endpoint $endpoint -Body $body -Method "POST"
Invoke-CIPPRestMethod -Endpoint $endpoint -Body $body -Method 'POST'
}
}
38 changes: 19 additions & 19 deletions CIPPAPIModule/public/Email-Exchange/Add-CIPPContact.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@ Adds a contact with the specified details to the customer's tenant.
#>
function Add-CIPPContact {
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$CustomerTenantID,
[Parameter(Mandatory = $true)]
[string]$DisplayName,
[Parameter(Mandatory = $true)]
[string]$ExternalEmailAddress,
[Parameter(Mandatory = $true)]
[string]$FirstName,
[Parameter(Mandatory = $true)]
[string]$LastName

)
Param(
[Parameter(Mandatory = $true)]
[string]$CustomerTenantID,
[Parameter(Mandatory = $true)]
[string]$DisplayName,
[Parameter(Mandatory = $true)]
[string]$ExternalEmailAddress,
[Parameter(Mandatory = $true)]
[string]$FirstName,
[Parameter(Mandatory = $true)]
[string]$LastName

)

Write-Verbose "Adding Contact in tenant: $CustomerTenantID"
$Endpoint = "/api/addcontact"
$Endpoint = '/api/addcontact'
$body = @{
tenantid = $CustomerTenantID
displayName = $DisplayName
email = $ExternalEmailAddress
FirstName = $FirstName
LastName = $LastName
tenantid = $CustomerTenantID
displayName = $DisplayName
email = $ExternalEmailAddress
FirstName = $FirstName
LastName = $LastName
}
Invoke-CIPPRestMethod -Endpoint $Endpoint -Body $body -Method POST
}
4 changes: 2 additions & 2 deletions CIPPAPIModule/public/Email-Exchange/Get-CIPPCalendarPerms.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ function Get-CIPPCalendarPerms {
)

Write-Verbose "Getting user calendar permissions for user: $UserID"
$Endpoint = "/api/listcalendarpermissions"
$Endpoint = '/api/listcalendarpermissions'
$Params = @{
tenantfilter = $CustomerTenantID
userId = $UserID
userId = $UserID
}
Invoke-CIPPRestMethod -Endpoint $Endpoint -Params $Params
}
Loading

0 comments on commit f202fd1

Please sign in to comment.