Import-SpbmStoragePolicy error – Object reference not set to an instance of an object

In a previous post I’ve talked about issues in the StoragePolicy and Tag cmdlets in PowerCLI. I found a workaround by ignoring certificate warnings and setting my date format to en-US.

Today I tried to replicate some Storage Policies from one vCenter to another and I found that I got new errors…

I can export the policies without issues, but when I try to Import the policy to the new vCenter I get the following error: “Object reference not set to an instance of an object”. Update 2018-04-06: VMware has confirmed the issue and stated it will be fixed in PowerCLI 10.1

I double-checked my workaround found in the mentioned blog post, but that was in place. I tried the same command on a machine without the workaround and I got the same error.

There has been released a new version of PowerCLI so I tried to update PowerCLI (which by the way is really easy with the move to PSGallery).

Even with the latest version (VMware.VimAutomation.Storage I get the same error

I did try the Tag cmdlet as the screenshot shows which didn’t work on this machine earlier, and that bug seems to be fixed in this release!

I’ve filed a Support Request with VMware, but I guess I might need to argue a bit to have them look in to it. Last time I were told that PowerCLI wasn’t supported, even though this post from the PowerCLI PM, Kyle Ruddy, clearly states that it should be.

To be continued…


Working with Cloud Infrastructure @ Intility, Oslo Norway. VMware vExpert. Mainly focused on automating Datacenter stuff. All posts are personal

2 thoughts to “Import-SpbmStoragePolicy error – Object reference not set to an instance of an object”

  1. Hi Rudy,

    What is the stack trace of the error after this cmdlet fails? It can be seen up to the level it is available as below:

    $e = $error[0]

    1. PS C:> Import-SpbmStoragePolicy -FilePath D:\temp\policy.xml -Name $policy.Name -Description $policy.Description -Serve
      r server
      Import-SpbmStoragePolicy : 19.03.2018 22.54.48 Import-SpbmStoragePolicy Object reference not set to an i
      nstance of an
      At line:1 char:1
      + Import-SpbmStoragePolicy -FilePath D:\temp\policy.xml -Name $policy.N …
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : NotSpecified: (:) [Import-SpbmStoragePolicy], VimException
      + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.Storage.Commands.Cmdlets.Spbm.ImportSp

      PS C:> $e = $error[0]
      PS C:> $e.Exception.StackTrace
      PS C:> $e.Exception.InnerException.StackTrace
      at VMware.VimAutomation.Storage.Impl.V1.Utils.PbmProxyObjectHelper.ValidateSpbmCommonRule(StorageClient client, SpbmR
      ule[] commonRule)
      at VMware.VimAutomation.Storage.Impl.V1.Utils.PbmProxyObjectHelper.ValidateStoragePolicySpec(StorageClient client, St
      ring name, SpbmRuleSet[] ruleSets, SpbmRule[] commonRule)
      at VMware.VimAutomation.Storage.Impl.V1.Service.SpbmProfileServiceImpl.NewSpbmStoragePolicy(String name, String descr
      iption, SpbmRuleSet[] ruleSets, SpbmRule[] commonRule)
      at VMware.VimAutomation.Storage.Impl.V1.Service.SpbmProfileServiceImpl.ImportStoragePolicy(String filePath, String na
      me, String description)
      at VMware.VimAutomation.Storage.Commands.Cmdlets.Spbm.ImportSpbmStoragePolicy.DoWork(StorageClient client, List1 moL
      at VMware.VimAutomation.Storage.Commands.StorageCmdletBase.DoWork(VIConnection connection, List
      1 moList)
      at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.BaseCmdlet.DoWorkEx(VIConnection connection, List1 moList)
      at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.ConnectionDispatchHelper.ExecuteRunlist(Dictionary
      2 runlist, DoWorkD
      elegate doWorkDelegate, UidDispatchHelper uidDispatchHelper, List`1 result)
      PS C:> $e.Exception.InnerException.InnerException.StackTrace

Leave a Reply

Your email address will not be published. Required fields are marked *