Functions/New-IAConfiguration.ps1
Function New-IAConfiguration { Param( [Parameter(Mandatory = $true)] [String]$Name, [Parameter(Mandatory = $true)] $IAConfigurationDataModel, [Switch]$Passthru, [Switch]$CleanUpEmptyProperties ) if($CleanUpEmptyProperties){ $PropertyNames = $IAConfigurationDataModel | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name foreach($item in $PropertyNames){ if([String]::IsNullOrEmpty($IAConfigurationDataModel."$item")){ $IAConfigurationDataModel.PSObject.Properties.Remove($item) } } } $Uri = "configmgr/$($Name)s" $Body = $IAConfigurationDataModel | ConvertTo-Json Write-Verbose "Body: $Body" $response = Invoke-IAQuery -QueryUrl $Uri -Method Post -Body $Body if($PassThru){ if ($null -eq $response) { return $null } return $response } } |