Admin/Site/Set-SDPSite.ps1
|
Function Set-SDPSite { <# .SYNOPSIS Update Site .PARAMETER SiteId Site id .PARAMETER InputData Input data as hashtable or JSON string .EXAMPLE $InputData = @{ site = @{ name = "Wsparcie obsługi komputera" description = "Testowy" } } $Site = Set-SDPSite -SiteId 54321 -InputData $InputData .NOTES Author: Michal Gajda #> [CmdletBinding( SupportsShouldProcess=$True, ConfirmImpact="Low" )] param ( [String]$UriSDP, [String]$ApiKey, [Parameter(Mandatory=$true, ValueFromPipeline)] [Int]$SiteId, [Parameter(Mandatory=$true)] $InputData ) Begin { #Create headers if(!$MyInvocation.BoundParameters.ContainsKey("UriSDP")) { if($Global:UriSDP) { $UriSDP = $Global:UriSDP } else { Write-Error "UriSDP parameter is required or run Set-SDPApiConnection first." -ErrorAction Stop } } if(!$MyInvocation.BoundParameters.ContainsKey("ApiKey")) { if($Global:ApiKey) { $ApiKey = $Global:ApiKey } else { Write-Error "ApiKey parameter is required or run Set-SDPApiConnection first." -ErrorAction Stop } } } Process { $InvokeParams = @{ UriSDP = $UriSDP ApiKey = $ApiKey Method = "PUT" EntityUri = "/api/v3/sites/$SiteId" InputData = $InputData } #Send request If ($PSCmdlet.ShouldProcess($SiteId,"Update site by id")) { $Result = Invoke-SDPAPIEntity @InvokeParams $Results = $Result.site } #Return result if($MyInvocation.BoundParameters.ContainsKey("Debug")) { Return $Result } else { Return $Results } } End{} } |