PowerShell enables bulk collection of virtual machines in SCVMM ip-continued

Source: Internet
Author: User

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

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.