Because I improved the technology, so the script is improving, thanks to my colleagues to teach me the C # syntax, this script is better. Nonsense not much to say, directly on the code.
#powerd by Nine tert # get an IP address in bulk from VMM and hyper-V for easier alignment. More accurate. #转载必须注明出处, this can be improved. Param ( [string] $vmmServer = "SC-VMMSP1" ) import-module virtualmachinemanagerget-scvmmserver -computername $vmmServer -SetAsDefault | Out-null$vms = get-vm -allforeach ( $VM in $VMs ) { $ info_name = $VM. name $allVMS = get-scipaddress foreach ($item in $allVMS) { if ( $VM. name -eq $item. description -and ($VM. isprimaryvm -eq "false") ) { Write-Host "=========================== = = " -foregroundcolor ' Red ' write-host 1☆ name ☆: $info _name; write-host 2☆ Physical host ☆: ($VM. Vmhost.fqdn) $VVMMHHSS = $VM .vmhost.computername $NB = "invoke-command -computername $vvmmhhss -command{(get-vmnetworkadapter -VMName ' $info _name '). ipaddresses} " write-host 3☆ the ip☆ $item obtained from VMM. address; write-host 4☆ ip☆ obtained from Hyper-V powershell $NB } }}
The specific effect is as follows
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/07/wKiom1VxS2vC_qLFAAJKUG4aX2c793.jpg "title=" 2015-6-5 15-08-56.jpg "alt=" Wkiom1vxs2vc_qlfaajkug4ax2c793.jpg "/>
So here I actually found a more interesting place, the above example also used
echo if there are two variables added, then it is actually written in two rows by default. Write-host but don't use the alias Echo, with WR, multiple variables can be displayed on one line. In addition, in the back of the WR plus-nonewline can not be changed line plus-foregroundcolor ' Blue ' can be changed color
This article is from the "Nine uncle-Microsoft Private Cloud" blog, please make sure to keep this source http://jiushu.blog.51cto.com/972756/1658890
PowerShell enables bulk collection of virtual machines in SCVMM ip-continued