-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Expand file tree
/
Copy pathPush-CIPPOffboardingTask.ps1
More file actions
38 lines (30 loc) · 1.05 KB
/
Push-CIPPOffboardingTask.ps1
File metadata and controls
38 lines (30 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function Push-CIPPOffboardingTask {
<#
.SYNOPSIS
Generic wrapper to execute individual offboarding task cmdlets
.DESCRIPTION
Executes the specified cmdlet with the provided parameters as part of user offboarding
.FUNCTIONALITY
Entrypoint
#>
[CmdletBinding()]
param($Item)
$Cmdlet = $Item.Cmdlet
$Parameters = $Item.Parameters | ConvertTo-Json -Depth 5 | ConvertFrom-Json -AsHashtable
try {
Write-Information "Executing offboarding cmdlet: $Cmdlet"
# Check if cmdlet exists
$CmdletInfo = Get-Command -Name $Cmdlet -Module CIPPCore -ErrorAction SilentlyContinue
if (-not $CmdletInfo) {
throw "Cmdlet $Cmdlet does not exist"
}
# Execute the cmdlet with splatting
$Result = & $Cmdlet @Parameters
Write-Information "Completed $Cmdlet successfully"
return $Result
} catch {
$ErrorMsg = "Failed to execute $Cmdlet : $($_.Exception.Message)"
Write-Information $ErrorMsg
return $ErrorMsg
}
}