I tried to run your script, and everything runs fine... first I tried the line "Get-AZVMImage..." which displayed me the correct/expected image information
Then I tried the complete script in a cloud shell... this is what I got... but still with the expected image information but an error in the windows configuration
$vmConfig | Set-AzVMBootDiagnostic -Disable
Name : puppet
DiagnosticsProfile : {BootDiagnostics}
HardwareProfile : {VmSize}
NetworkProfile : {NetworkInterfaces}
OSProfile : {ComputerName, AdminUsername, AdminPassword, WindowsConfiguration}
Plan : {Name, Publisher, Product}
StorageProfile : {ImageReference}
New-AzVM -ResourceGroupName $ResourceGroupName -Location $LocationName -VM $vmConfig
New-AzVM: The value of parameter windowsConfiguration is invalid.
ErrorCode: InvalidParameter
ErrorMessage: The value of parameter windowsConfiguration is invalid.
ErrorTarget: windowsConfiguration
StatusCode: 400
ReasonPhrase: Bad Request
OperationID : a9e75dc1-6ae6-4cd4-88df-06877c37d1ef
Actually, I don't know how this is related to your image-publisher problem, I was able to run your code several times and always got the correct/expected publisher information back...