Public/Set-CiresonPortalRequestOfferingAsFavorite.ps1
function Set-CiresonPortalRequestOfferingAsFavorite { <# .SYNOPSIS Function to set a Request Ofering as Favorite for a specific User .DESCRIPTION Function to set a Request Ofering as Favorite for a specific User .PARAMETER UserID Specifies the User ID (GUID) .PARAMETER RequestOfferingId Specifies the Request Offering ID (GUID) .EXAMPLE Set-CiresonPortalRequestOfferingAsFavorite -RequestOfferingID 4c2e9de8-c70b-c2df-b0d0-a9820391d294 -UserID 7c7e9d78-c70b-c2df-b0d0-a9820391d294 .NOTES Francois-Xavier Cat lazywinadmin.com @lazywinadm github.com/lazywinadmin #> #requires -version 3 [CmdletBinding(SupportsShouldProcess = $True)] PARAM( [parameter(Mandatory)] [GUID]$UserID, [parameter(Mandatory)] [GUID]$RequestOfferingID ) BEGIN { TRY{ Write-Verbose -Message $(New-ScriptMessage -Block BEGIN -message 'Checking Pre-Requisites') [void](Get-CiresonPortalPSConfiguration -WarningAction Stop) } CATCH { # Stop the function Write-Error $Error[0] Throw "Not Connected to Cireson Portal" } } PROCESS { if($PSCmdlet.ShouldProcess($UserID,'Set Request Offering as Favorite')) { # Build the Query $URI = $CiresonPortalURL,"api/V3/ServiceCatalog/MarkFavorite?requestOfferingId=$RequestOfferingID&userId=$UserID" -join '/' Write-Verbose -Message $(New-ScriptMessage -Block PROCESS -message "Uri = $URI") # Invoke the Query Invoke-RestMethod $URI -Credential $CiresonPortalCred -Method Post } } } |