CiscoDevNet / intersight-powershell

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

New-IntersightBulkMoCloner throws Object reference not set to an instance of an object. #147

Closed davidstanaway closed 3 months ago

davidstanaway commented 6 months ago

Describe the bug Using New-IntersightBulkMoCloner to clone an IntersightServerProfileTemplate to an IntersightServerProfile throws an error: Object reference not set to an instance of an object.

To Reproduce Steps to reproduce the behavior Using examples/server/DeriveServerProfileFromTemplate.ps1 but with our own server profile template and org values, no server profile is derived, or object returned and the command throws an error.

$source = Get-IntersightServerProfileTemplate -Name "server_template" $orgRef = Get-IntersightOrganizationOrganization -Name default $targetProfile = Initialize-IntersightServerProfile -Name cloned-server-profile -Description "cloned from template" -Organization (Get-IntersightMoMoRef -ManagedObject ($orgRef)) New-IntersightBulkMoCloner -Sources $source -Targets $targetProfile

Version used

Expected behavior A clear and concise description of what you expected to happen.

I expect a server profile to be created called in above example cloned-server-profile the same as if I had derived profiles from the server profile template named "server_template" in above example, in the organization default.

Screenshots If applicable, add screenshots to help explain your problem. image

Additional context Add any other context about the problem here.

davidstanaway commented 6 months ago

This is probably tied to https://github.com/CiscoDevNet/intersight-powershell/issues/139

davidstanaway commented 6 months ago

This is probably tied to #139

Can't role back to that version as we are using New-IntersightVnicVnicTemplate which is a new feature.

tgrabrian commented 3 months ago

Any updates on this one? Currently running into this bug. It was indeed working just fine on previous versions of this PowerShell module.

Ghufz commented 3 months ago

This issue has been fixed in Intersight.PowerShell module version 1.0.11.17956.

This issue also requires a backend fix, which will be available in production by in coming weeks.

As a workaround for the backend issue, The New-IntersightBulkMoCloner cmdlet can use with the -json switch parameter.

$src = Initialize-IntersightMoBaseMo -Moid xxxxxxxxxxxxxxxx -ClassId ServerProfileTemplate -ObjectType ServerProfileTemplate
$targ = Initialize-IntersightServerProfile -Name ps_cloned_profile
$result = New-IntersightBulkMoCloner -Sources @($src) -Targets @($targ) -Json | ConvertFrom-json
Ghufz commented 3 months ago

Cmdlet is working as expected in released version 1.0.11.18012