Hello, tdubb123-
The issue is with the value that you are providing for the "Name" key in the -Filter hashtable in the Get-View call -- the value should be a string, but you are using a VirtualMachineImpl object. The error that you are getting:
Invalid object specified for the Filter parameter - 'Hashtable{String,VirtualMachineImpl}'. Filter accepts objects of type 'Hashtable{String, String}'
tries to point that out. That is to say, $vmname is not a String -- it is the entire VirtualMachineImpl object returned from Get-VM. So, to use that variable in the Filter in the Get-View call, you would need to access the .Name property of the variable. Like:
Get-View-ViewTypeVirtualMachine-Filter @{"Name"=$vmname.Name}
And, maybe to help avoid such confusion, naming that variable "$vm" or the likes would be better, since the contents of the variable are not just the VM's name, but the whole VM object.
That work for you?