I am currently trying to create a script that will get the whencreated date from AD and then populate a custom attribute (called BuildDate) with the information. If I try to run the script below i get "Value is a read only property". If I look at the values without trying to set them I can see the information. Any assistance would be appreciated.
$vm = Get-VM -Name vmname
$cdate = Get-QADComputer -Name $vm
foreach ($field in $vm.CustomFields)
{
if ($field.Key -eq "BuildDate")
{$field.Value = $cdate.whencreated
}
}
The VI Toolkit contains cmdlets (New-CustomField, Set-CustomField, Remove-CustomField) to manipulate the custom attributes.
Did you try using those ?
You can't write to the SDK properties like that.
You have to use the SDK methods to change settings.
But like I said, there is in fact no need to use the SDK, you can use the VITK cmdlets.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The VI Toolkit contains cmdlets (New-CustomField, Set-CustomField, Remove-CustomField) to manipulate the custom attributes.
Did you try using those ?
You can't write to the SDK properties like that.
You have to use the SDK methods to change settings.
But like I said, there is in fact no need to use the SDK, you can use the VITK cmdlets.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Worked like a charm. Thanks for your input.