VMware Cloud Community
invalidusernam2
Contributor
Contributor

Customization spec created with powercli does not exist.

I can see it in the vsphere client and cannot remove or edit it. If I choose edit I get a pop-up that says "Specification <nameofspec> does not exist."  If I try to remove and choose yes to the prompt nothing happens.

Additionally the Get-OSCustomizationSpec cmdlet is now broken.

Get-OSCustomizationSpec : 7/10/2017 10:38:57 AM Get-OSCustomizationSpec         The object or item referred to could not be found.

At line:1 char:1

+ Get-OSCustomizationSpec

+ ~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-OSCustomizationSpec], NotFound

    + FullyQualifiedErrorId : Client20_VmHostServiceImpl_GetCUstomizationSpecItem_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetOSCustomizationSpec

Dan

18 Replies
LucD
Leadership
Leadership

Stop/start your PowerShell session.

Connect, then do a Get-OSCustomizationSpec (without any parameters).

Is the spec you are looking for in there?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
invalidusernam2
Contributor
Contributor

I've tried multiple sessions, different pc's. 

Get-OSCustomizationSpec : 7/10/2017 10:38:57 AM Get-OSCustomizationSpec         The object or item referred to could not be found.

At line:1 char:1

+ Get-OSCustomizationSpec

+ ~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Get-OSCustomizationSpec], NotFound

    + FullyQualifiedErrorId : Client20_VmHostServiceImpl_GetCUstomizationSpecItem_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetOSCustomizationSpec

If I specify a good custom spec (where I can edit the settings in vsphere) it is returned in shell. I don't know what's causing the problem specs to be blank. I can see them in sql customization table as well.

0 Kudos
LucD
Leadership
Leadership

Does this return the OSCustomizationSpec objects?

$si = Get-View ServiceInstance

$oscMgr = Get-View -Id $si.Content.CustomizationSpecManager

$oscMgr.Info | Format-Table -AutoSize


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
invalidusernam2
Contributor
Contributor

Appears it's a problem with a leading space in the customspec name.

Name                     Description                                Type    ChangeVersion LastUpdateTime

----                     -----------                                ----    ------------- --------------

...                                                                 Windows 1499705608    7/10/2017 4:53:28 PM

...                                                                 Windows 1499705607    7/10/2017 4:53:27 PM

...                                                                 Windows 1499705606    7/10/2017 4:53:26 PM

2008 std x64 (Internel)                                             Windows 1458333898    3/18/2016 8:44:58 PM

centos                                                              Linux   1405372641    7/14/2014 9:17:21 PM

$oscmgr.infor[0]

Name           :

                 mycustomspecname

Description    :

Type           : Windows

ChangeVersion  : 1499705608

LastUpdateTime : 7/10/2017 4:53:28 PM


I tried renaming it but that didn't do it.

0 Kudos
LucD
Leadership
Leadership

Does this return the OSCustomizationSpec?

Get-OSCustomizationSpec -Name "*mycustomspecname"


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
invalidusernam2
Contributor
Contributor

Unfortunately not.

0 Kudos
LucD
Leadership
Leadership

Does this return the OSCustomizationSpec?

The "mycustomspecname" need to be replaced by the part of the name that is readable/has viewable characters.

$si = Get-View ServiceInstance

$oscMgr = Get-View -Id $si.Content.CustomizationSpecManager

$oscMgr.Info | where{$_.Name -match "mycustomspecname"}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
invalidusernam2
Contributor
Contributor

yes, as does the above. There are no associate methods on the objects though.

Untitled.png

I even tried this with no luck.

PS C:\Users> $n = ($oscMgr.Info | where{$_.Name -match "stl"})[0].name

PS C:\Users> Get-OSCustomizationSpec -name $n

Get-OSCustomizationSpec : 7/11/2017 7:57:19 AM  Get-OSCustomizationSpec         The object or item referred to could not be found.

0 Kudos
LucD
Leadership
Leadership

Not on the objects, but there is on the manager.

I assume you're able to slect one of the problematic OSCustomizationSpecs, based on Name match but perhaps also ChangeVersion and/or LastUpdateTime.

Then use the Name of the object to remove it.

Does that work?

$si = Get-View ServiceInstance

$oscMgr = Get-View -Id $si.Content.CustomizationSpecManager

$ospc = $oscMgr.Info | where{$_.Name -match "mycustomspecname"}

$oscMgr.DeleteCustomizationSpec($ospc.Name)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
invalidusernam2
Contributor
Contributor

Interesting but no dice.

Exception calling "DeleteCustomizationSpec" with "1" argument(s): "The object or item referred to could not be found."

0 Kudos
invalidusernam2
Contributor
Contributor

If you'd like to reproduce this.

$r = [pscustomobject]@{name = "`nmycustomspec"}

$r.name

$oscustomization = @{

Name = $r.name

domain = 'test'

fullname = 'test'

Orgname = 'test'

ProductKey = 'D2N9P-3P6X9-2R39C-7RTCD-MDVJX'

AdminPassword = 'Password'

Timezone = 'Eastern (U.S. and Canada)'

Licensemode = 'Perserver'

LicenseMaxConnections = 5

ChangeSid = $true

}

$spec = New-OSCustomizationSpec @oscustomization -Domaincredentials $buildcred -Confirm:$false

0 Kudos
LucD
Leadership
Leadership

Is that a backtick in the name?

So there is in fact a <NewLine> character at the beginning of the name?

Did you already try the Delete method with that specific name?

The Delete method just wants a string with the name of the OSCustomizationSpec


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
invalidusernam2
Contributor
Contributor

There is a return yes. Short story: The data came out of a bad sql import that I didn't expect to have to handle. I wrote an automated build process taking information from a helpdesk request.  Customer submitted the server name with a leading space. For some reason powershell/sql thinks this is a carriage return.

To reproduce the behavior you can try it with the `n.

No, the delete method does not work. Exception calling "DeleteCustomizationSpec" with "1" argument(s): "The object or item referred to could not be found."

0 Kudos
LucD
Leadership
Leadership

I'll try to recreate that in my lab.

And more imp[ortantly, see if I can come up with a removal procedure (short from manipulating the DB)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

LucD
Leadership
Leadership

Can you try this variation?

That seems to work for me.

$si = Get-View ServiceInstance

$oscMgr = Get-View -Id $si.Content.CustomizationSpecManager

$ospc = $oscMgr.Info | where{$_.Name -like "*mycustomspec"}

$oscMgr.DeleteCustomizationSpec($ospc.Name)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
LucD
Leadership
Leadership

And this also seems to work for me.

Provided of course the first character in the name is indeed a <NewLine>

$si = Get-View ServiceInstance

$oscMgr = Get-View -Id $si.Content.CustomizationSpecManager

$name = [Char]0x0a + "mycustomspec"

$oscMgr.DeleteCustomizationSpec($name)


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
LucD
Leadership
Leadership

And of course, this works as well this way.

Get-OSCustomizationSpec -Name ([char]0x0a + "mycustomspec") |

Remove-OSCustomizationSpec -Confirm:$false


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jakerpowercli
VMware Employee
VMware Employee

The following seems to work just fine, no need for ascii char hex:

```

Get-OSCustomizationSpec -name "`n*"

```

If you want all of the specs containing the newline char to be deleted, you can simply pipe that to Remove-OSCustomizationSpec:

```
Get-OSCustomizationSpec -name "`n*" | Remove-OSCustomizationSpec

```

0 Kudos