PowerShell enables bulk collection of virtual machine IPs in SCVMM

Source: Internet
Author: User

First, this script has a functional limit: only for Windows virtual machines that have agents installed .

Let's take a look at the script that you used to write the cmd phase. http://jiushu.blog.51cto.com/972756/1419862 This stage of scripting ideas are full of humanistic care

Invoke-command-computername Hahv1,hahv2,hahv3-command{get-vmnetworkadapter-all | Select-object vmname,ipaddresses | format-table > D: $env: Computername.csv} #导出IP地址 # What do you mean by the bottom three copy? Copy files from different hosts to run script D-disk copy \hahv1d$hahv1.csv d:copy \hahv2d$hahv2.csv d:copy \hahv3d$hahv3.csv D: #PowerShell中运行cmd命令不太方便 , because the cmd command has some similar to PowerShell, but the function is different, so write a command with Ech, that is, to combine the local CSV file, attach to a file called Cp.cmd echo "copy *.csv hv.csv/y" >d:/ CP.CMDD: #运行这个拷贝, end. Cp.cmd

↑ The above script does not use .

Let's see how the new writing is written. Scripts need to be used in SCVMM's PowerShell, and if they are running silently, load the module first

echo----This script shows the corresponding relationship between the virtual machine IP address and the computer name of all Hyper-V hosts in the current SCVMM echo----IP address is from a Hyper-V host, so you can only target Windows virtual machines that have agents installed at this stage. echo----can be combined with the mail sending function to send echo "----powerd by nine uncles" $CC = Get-vmhost|select Computername$cc|foreach {The host of the virtual machine in the current list is: ($_. ComputerName) Invoke-command-computername $_.computername-command{get-vmnetworkadapter-all | Select-object vmname,ipaddresses|ft}}

The above code 7 lines, 4 lines are the description, so you this time the code efficiency is really improved. But because this is plainly done on the target computer, so the efficiency is the same as before, and finally we look at the effect

"Shut down the machine can not see, Linux can not see, no agent can not see."

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6D/15/wKiom1Vb5orhJ0_gAAPv9VRFbss726.jpg "title=" 2015-5-20 9-31-48.jpg "alt=" Wkiom1vb5orhj0_gaapv9vrfbss726.jpg "/>

This article is from the "Nine uncle-Microsoft Private Cloud" blog, please make sure to keep this source http://jiushu.blog.51cto.com/972756/1653026

PowerShell implements bulk collection of virtual machine IPs in SCVMM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.