From 7e23f85fe1c70c57569cd514b024955d36053392 Mon Sep 17 00:00:00 2001 From: JJ Fullmer Date: Sat, 17 Aug 2024 22:17:08 -0600 Subject: [PATCH] Add get-fogversion #10 - Updated dynamic params to be contextual to the version --- FogApi/Private/Get-DynmicParam.ps1 | 36 +++++++++++++++++++++--------- FogApi/Public/Find-FogObject.ps1 | 3 +++ 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/FogApi/Private/Get-DynmicParam.ps1 b/FogApi/Private/Get-DynmicParam.ps1 index 349c107..5c58d93 100644 --- a/FogApi/Private/Get-DynmicParam.ps1 +++ b/FogApi/Private/Get-DynmicParam.ps1 @@ -32,17 +32,31 @@ the position to put the dynamic parameter in $attributeCollection.Add($attributes) - $coreObjects = @( - "clientupdater", "dircleaner", "greenfog", "group", "groupassociation", - "history", "hookevent", "host", "hostautologout", "hostscreensetting", "image", - "imageassociation", "imagepartitiontype", "imagetype", "imaginglog", "inventory", "ipxe", - "keysequence", "macaddressassociation", "module", "moduleassociation", "multicastsession", - "multicastsessionassociation", "nodefailure", "notifyevent", "os", "oui", "plugin", - "powermanagement", "printer", "printerassociation", "pxemenuoptions", "scheduledtask", - "service", "setting", "snapin", "snapinassociation", "snapingroupassociation", "snapinjob", - "snapintask", "storagegroup", "storagenode", "task", "tasklog", "taskstate", "tasktype", - "unisearch", "user", "usercleanup", "usertracking", "virus" - ); + if ((Get-FogVersion) -like '1.6*') { + $coreObjects = @( + "group", "groupassociation", "history", "hookevent", "host", "hostautologout", + "hostscreensetting", "image", "imageassociation", "imagepartitiontype", "imagetype", + "imaginglog", "inventory", "ipxe", "keysequence", "macaddressassociation", "module", + "moduleassociation", "multicastsession", "multicastsessionassociation", "nodefailure", + "notifyevent", "os", "oui", "plugin", "powermanagement", "printer", "printerassociation", + "pxemenuoptions", "scheduledtask", "setting", "snapin", "snapinassociation", + "snapingroupassociation", "snapinjob", "snapintask", "storagegroup", "storagenode", "task", + "tasklog", "taskstate", "tasktype", "unisearch", "user", "usertracking", "setting", "user" + ); + } else { + $coreObjects = @( + "clientupdater", "dircleaner", "greenfog", "group", "groupassociation", + "history", "hookevent", "host", "hostautologout", "hostscreensetting", "image", + "imageassociation", "imagepartitiontype", "imagetype", "imaginglog", "inventory", "ipxe", + "keysequence", "macaddressassociation", "module", "moduleassociation", "multicastsession", + "multicastsessionassociation", "nodefailure", "notifyevent", "os", "oui", "plugin", + "powermanagement", "printer", "printerassociation", "pxemenuoptions", "scheduledtask", + "service", "setting", "snapin", "snapinassociation", "snapingroupassociation", "snapinjob", + "snapintask", "storagegroup", "storagenode", "task", "tasklog", "taskstate", "tasktype", + "unisearch", "user", "usercleanup", "usertracking", "virus" + ); + } + $coreTaskObjects = @("group", "host", "multicastsession", "scheduledtask", "snapinjob", "snapintask", "task"); $coreActiveTaskObjects = @("multicastsession", "powermanagement", "scheduledtask", "snapinjob", "snapintask", "task"); } diff --git a/FogApi/Public/Find-FogObject.ps1 b/FogApi/Public/Find-FogObject.ps1 index 15c4889..8d36b5c 100644 --- a/FogApi/Public/Find-FogObject.ps1 +++ b/FogApi/Public/Find-FogObject.ps1 @@ -53,6 +53,9 @@ function Find-FogObject { $paramDict | ForEach-Object { New-Variable -Name $_.Keys -Value $($_.Values.Value);} # $paramDict; Write-Verbose "Building uri and api call for $($paramDict.keys) $($paramDict.values.value)"; + if (($null -eq $coreObject) -and (Get-FogVersion -like '1.6*')) { + $coreObject = "unisearch"; + } switch ($type) { search { if ($coreObject -ne "unisearch") {