Skip to content

Commit

Permalink
Merge pull request KelvinTegelaar#1251 from JohnDuprey/dev
Browse files Browse the repository at this point in the history
Update New-PwPushLink.ps1
  • Loading branch information
JohnDuprey authored Jan 20, 2025
2 parents 982e49a + eaccbaa commit 1313a50
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Modules/CippExtensions/Public/PwPush/New-PwPushLink.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function New-PwPushLink {
[CmdletBinding()]
[CmdletBinding(SupportsShouldProcess)]
Param(
$Payload
)
$Table = Get-CIPPTable -TableName Extensionsconfig
$Configuration = ((Get-CIPPAzDataTableEntity @Table).config | ConvertFrom-Json).PWPush
if ($Configuration.Enabled) {
if ($Configuration.Enabled -eq $true) {
Set-PwPushConfig -Configuration $Configuration
$PushParams = @{
Payload = $Payload
Expand All @@ -14,15 +14,17 @@ function New-PwPushLink {
if ($Configuration.ExpireAfterViews) { $PushParams.ExpireAfterViews = $Configuration.ExpireAfterViews }
if ($Configuration.DeletableByViewer) { $PushParams.DeletableByViewer = $Configuration.DeletableByViewer }
try {
$Link = New-Push @PushParams | Select-Object Link, LinkRetrievalStep
if ($Configuration.RetrievalStep) {
$Link.Link = $Link.LinkRetrievalStep
if ($PSCmdlet.ShouldProcess('Create a new PwPush link')) {
$Link = New-Push @PushParams
if ($Configuration.RetrievalStep) {
return $Link.LinkRetrievalStep
}
return $Link.Link
}
$Link | Select-Object -ExpandProperty Link
} catch {
$LogData = [PSCustomObject]@{
'Response' = $Link
'Exception' = Get-CippException -Exception $_
'Response' = $Link
'Exception' = Get-CippException -Exception $_
}
Write-LogMessage -API PwPush -Message "Failed to create a new PwPush link: $($_.Exception.Message)" -Sev 'Error' -LogData $LogData
throw 'Failed to create a new PwPush link, check the log book for more details'
Expand Down

0 comments on commit 1313a50

Please sign in to comment.