Get list of all VMs from a list of HV servers
hello everyone,
i trying create ps script pull data list of hv servers, stored in csv file, , result must name of host , name of vms.
if run script 1 hv host works, i've added foreach , contect read list of hv servers , bring list of vms i've receive error "get-wmiobject : invalid namespace "root\virtualization". me on this?
script:
[parameter(mandatory=$true)][string]$hvhost,
$hvhost = get-content c:\hvservers.txt | {$_}
foreach ($i in $hvhost){
echo "$i";
get-vm |sort-object hostname |select-object hostname, name | export-csv c:\vmlist.txt -notypeinformation;
}
error:
get-wmiobject : invalid namespace "root\virtualization"@ c:\windows\system32\windowspowershell\v1.0\modules\hyperv\hyperv.ps1:455 char:2
+ get-wmiobject -computername $server -namespace "root\virtualization" -query $wq ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ categoryinfo : invalidargument: (:) [get-wmiobject], managementexception
+ fullyqualifiederrorid : getwmimanagementexception,microsoft.powershell.commands.getwmiobjectcommand
thanks, best regards.
hi,
are using csv file input? script not show that.
additionally, you're never using current loop iteration you'll never querying server in question.
Windows Server > Windows PowerShell
Comments
Post a Comment