Get off work yesterday to get a bad news, SCVMM2012 SP1 in the "cloud" property of more than 300 virtual machines ... The concrete manifestation is in each already existing cloud, cannot see a virtual machine, the concrete manifestation is, when looking at the virtual machine, the cloud this piece is empty.
650) this.width=650; "src=" Http://www.ny9s.com/wp-content/uploads/2015/08/080715_0853_1.png "/>
How do you think this problem is going to happen? That's the ultimate tenant. No virtual machines are seen in the cloud in the SCAC and SCVMM consoles, and virtual machines actually exist.
So now it's time to find a way to recover these attributes.
First action, you need to import the VMM module
Import-module Virtualmachinemanager
First, pull a table and look at the current user group.
Get-scuserrole-vmmserver SC-VMMSP1 |select Name
650) this.width=650; "src=" Http://www.ny9s.com/wp-content/uploads/2015/08/080715_0853_2.png "/>
And see what the clouds are
Get-sccloud-vmmserver SC-VMMSP1 |select Name
650) this.width=650; "src=" Http://www.ny9s.com/wp-content/uploads/2015/08/080715_0853_3.png "/>
Well, basically get these two properties, compared to the luck of the virtual machine's cloud properties, but the virtual machine's user attributes are still there, so you can slowly back with PowerShell, the principle is that this virtual machine belongs to this user, then put into this user's cloud.
We'll fix it with two orders.
$Cloud = Get-sccloud-vmmserver Sc-vmmsp1 | where {$_. Name-like "Write the name of the cloud here"} get-vm| where {$_. Userrole-like "Write the name of the user group here"}| Set-scvirtualmachine-cloud $cloud |select Name
Because this is achieved by pipeline, so the speed is not fast ... Of course, it's much better not to do it manually.
In fact, there are a number of filtering methods, such as the use of the and method, similar to the following
#方法是这样的 (1-eq 1)-or (1-eq 2) #那么具体是怎么写的呢? Look at one of the following example get-vm|? {$_.userrole-like "admin"} |? {($_.vmhost-like "hahv1*")-or ($_.vmhost-like "hahv2*")-or ($_.vmhost-like "hahv3*")-or ($_.vmhost-like "hahv4*")}| Select Name,userrole,vmhost
According to the different user groups and the cloud, run a few more scripts, and slowly solve the problem, but there are also the following Ah, later on this problem? So my idea is to back up the cloud, the user group, the virtual machine relationship, and later bad good recovery. "Although there is no specific validation, there may be some problems with the service only." 】
With GET-VM, you can get the specific properties of the virtual machine, I list some of the more important attributes
HostName: This is the physical host name where the virtual machine resides
Vmhost: This is the physical host name where the virtual machine resides
Selfserviceuserrole: Here is the name of the creator's group
Cloudid:8cc833e1-a5e4-45fb-bb0a-bb38aaa41f2a
Cloud: Name
Grantedtolist: {User group authorized to access}
userroleid:7746c9da-a011-4cdc-9cb2-7b835f42c918
Userrole: User groups
Owner: The specified creator
StartAction: Automatic boot
Stopaction: Shut down after power outage or how to
Creationsource: Information about the service
Computertier: Information about the service
Here are the main use of two commands, one is set-scvirtualmachine one is get-scvirtualmachine Let's first look at the parameters it supports
-cloud Specify the name of the private cloud-computertier Specify the machine-level object-name Specify the virtual machine name-service Specify the service name #使用方法 Get-scservice, and then pipe delivery-vmhost Specify the physical host-vmmserver Specify the VMM server
The method of using the service as a parameter is slightly more specific, as shown in.
650) this.width=650; "src=" Http://www.ny9s.com/wp-content/uploads/2015/08/080715_0853_4.png "/>
Set this block can set a lot of properties, I first give a Google version of the translation, can make a look
Detailed description
The Set-scvirtualmachine Small command changes one or more properties of a virtual machine that is managed by the Virtual Machine Manager (VMM). The properties that you can change include the following:
-virtual machines associated with the cloud.
-the name, owner, and description of the virtual machine.
-The BIOS boot order, if deployed on a Hyper-V host.
-The amount that the resource uses on the host of the virtual machine. These include:
-the maximum number of CPU resources a host can use for a virtual machine.
-The CPU of the intended host used by the virtual machine.
-The amount of CPU resources on the host computer uses a virtual machine relative to the other virtual machines on the same host.
-The amount of host memory that a virtual machine can use.
-The amount of bandwidth the host can use for virtual machines on the network.
-The hardware settings for the virtual machine are hosted on unrelated resources. These include:
-the number of CPUs.
-the type of CPU.
-Number of disk input/output operations per second (IOPS).
-Limits (for older operating systems, such as Windows NT 4.0) the functionality of the CPU.
-cost center, which filters the label of the virtual machine with the standard, and the custom settings.
-Set up to enable various optional features, including:
-enable or disable library objects so that they are available, or temporarily unavailable, to the user.
-Enable the backup virtual machine on the Hyper-V host Volume Shadow Copy service.
-Enables data exchange between a single key/value pair of virtual machines and their Hyper-V hosts.
-The shutdown of virtual machines enabled from the console of Hyper-V.
-Enables time synchronization between the Hyper-V hosts of the virtual machine.
-Enable the BIOS value for the NumLock key for the virtual machine on the Hyper-V host.
-Sets whether the virtual machine is highly available, that is, the virtual machine is deployed on the node of the Hyper-V host cluster or Citrix XenServer host cluster.
-Set to determine whether the virtualization Guest service installation is deployed on a virtual machine on a Hyper-V host.
-Number of seconds before the virtual machine is started for delay.
-the Environment ID is used for a virtual machine operating system.
-Start and stop the operation of the virtual machine.
-Environment limits the number of self-service users a virtual machine can create.
-Sets the role for the switch, who belongs to multiple roles self-service users use to manage virtual machines.
-Set the ESX host to the virtual machine on the VMware resource pool assignment.
If you want to change the properties of a virtual floppy drive, virtual CD-ROM, virtual network adapter, or virtual SCSI adapter associated with a specific virtual machine, use set-scvirtualfloppydrive, set scvirtualdvddrive, Sets the Scvirtualnetworkadapter, or Set-scvirtualscsiadapter cmdlet, respectively.
Export section, here Export the attribute angle, but the import part only writes the cloud, if the unexpected situation occurs, the user right part also lost, that also can modify a recovery.
import-module virtualmachinemanager $vmmserver = "Sc-vmmsp1" $date 1 = date $extime = (get-date -format ' yyyymmddhhmm ') $filename = "D:/vmmreport " + $extime + ". txt " $filename 2 = " D:/hvcloud " + $extime + ". csv" echo "< #记录用户组" |out-file -encoding utf8 -force $filename Get-scuserrole -vmmserver sc-vmmsp1|select name|out-file -append -encoding utf8 -Force $filename echo "#记录云" |out-file -append -encoding utf8 -force $filename get-sccloud -vmmserver sc-vmmsp1 |select name|out-file -append -Encoding utf8 -Force $filename echo "#>" |out-file -append - encoding utf8 -force $filename get-vm -name *|? {$_. hostname -notlike "hv-re-bj*" -and $_.cloud -ne $null}|select name,hostname,cloud,owner,operatingsystem,computernamestring, startaction,stopaction,hostgrouppath,description,cpucount | export-csv -encoding utf8 -force $filename 2
Import section, you need to define the CSV file manually
$filenamecsv = "D:/hvcloud201508071645.csv" $vmmserver = "Sc-vmmsp1" Import-csv-path $filenamecsv | foreach {$cloud 2 = $_.cloud $cloud = Get-sccloud-vmmserver $vmmserver |? {$_.name-eq $cloud 2} $name =$_.name $hostname =$_.hostname $VM = get-scvirtualmachine-vmmserver $vmmserver-name $name | where {$_. Vmhost.name-eq $hostname} set-vm-vm $vm-cloud $cloud |select Name,vmhost}
Microsoft Cloud Solution High-end top group "236804566" to share the achievement of cattle B road
Welcome to Sina Weibo @ Fat nine Uncle
This article is from the "Nine uncle-Microsoft Private Cloud" blog, please make sure to keep this source http://jiushu.blog.51cto.com/972756/1683154
Backup and restore of "cloud" attributes in SCVMM