CiscoDevNet / intersight-powershell

Cisco Intersight PowerShell
Apache License 2.0
16 stars 4 forks source link

No longer able to add policies using PolicyBucket.Add() on UCS Server Profile (CIMC) #169

Closed mdk85-start closed 1 month ago

mdk85-start commented 1 month ago

Describe the bug I am seeing issues while adding a new existing policy on existing an ucs server profile for cimc, where $serverProfile.policyBucket.Add method doesn't execute.

When i ran this code couple of weeks it was able to attach the policy into UCS Server Profile (~200) . But now it doesn't execute.

Also when i run Set-IntersightServerProfile, I am seeing the following error

Code - $serverProfileKVM = $serverProfileDetail | Set-IntersightServerProfile

"Set-IntersightServerProfile: Object serialized to Array. JObject instance expected"

To Reproduce Steps to reproduce the behavior

    $org = Get-IntersightOrganizationOrganization -Name "default"
    $kvmPolicy = Get-IntersightKvmpolicy -Name "base:base:base:global:base:01" -Organization $org

    $serverProfileDetail = Get-IntersightServerProfile -Name $serverProfile -Organization $org
    $serverProfileName = $serverProfileDetail.Name
    $serverProfileDetail.PolicyBucket.Add($kvmPolicy)

    $ScheduledActions11 = Initialize-IntersightPolicyScheduledAction -Action "Deploy"
    $ScheduledActions21 = Initialize-IntersightPolicyScheduledAction -Action "Activate" -ProceedOnReboot $false

    $serverProfileKVM = $serverProfileDetail | Set-IntersightServerProfile 
    $serverProfileKVM | Set-IntersightServerProfile -ScheduledActions @($ScheduledActions11, $ScheduledActions21) -Action "Deploy" | Out-Null**

Version used

Expected behavior Add additional policies into UCS Server Profile

Screenshots image

Additional context Add any other context about the problem here.

Ghufz commented 1 month ago

Please use your script with latest released module version https://www.powershellgallery.com/packages/Intersight.PowerShell/1.0.11.18775

mdk85-start commented 1 month ago

@Ghufz : the new module fixed the issue. Thanks for fixing the resolution quickly! :)

mdk85-start commented 1 month ago

Using contain() method in PolicyBucket, how do i find a policy inside $serverProfile.PolicyBucket.Contain() ?

Ghufz commented 1 month ago

PolicyBucket is complex type so contains will not solve your issue, either use compare-object cmdlet, or simply iterate on policy bucket and check