Read-SCGuestInfo
Read-SCGuestInfo
Retrieves the value associated with a key in a guest operating system.
構文
Parameter Set: MultipleKvpKeys
Read-SCGuestInfo [-VM] <VM> -KvpMap <Hashtable> [ <CommonParameters>]
Parameter Set: SingleKvpKey
Read-SCGuestInfo [-VM] <VM> [-Key] <String> [ <CommonParameters>]
詳細説明
The Read-SCGuestInfo cmdlet retrieves the value associated with a key (key/value pair) in a guest operating system.
パラメーター
-Key<String>
Specifies the key in a key/value pair (KVP).
エイリアス |
none |
必須? |
true |
位置は? |
2 |
既定値 |
none |
パイプライン入力を許可する |
false |
ワイルドカード文字を許可する |
false |
-KvpMap<Hashtable>
Specifies a hash table of key/value pairs (KVPs) corresponding to the KVP values exposed by Hyper-V.
エイリアス |
none |
必須? |
true |
位置は? |
named |
既定値 |
none |
パイプライン入力を許可する |
false |
ワイルドカード文字を許可する |
false |
-VM<VM>
Specifies a virtual machine object.
エイリアス |
none |
必須? |
true |
位置は? |
1 |
既定値 |
none |
パイプライン入力を許可する |
True (ByValue) |
ワイルドカード文字を許可する |
false |
<CommonParameters>
このコマンドレットは次の共通パラメーターをサポートします。-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer、-OutVariable.詳細については、以下を参照してください。 about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216)。
入力
入力型は、コマンドレットにパイプできるオブジェクトの型です。
出力
出力型は、コマンドレットによって生成されるオブジェクトの型です。
- String
例
Example Example 1: Get the IntegrationServicesVersion value for a specified key for a virtual machine.
The first command gets the virtual machine object named $VM01, and then stores the object in the $VM variable.
The second command returns the IntegrationServicesVersion key/value pair for virtual machine VM01.
PS C:\> $VM = Get-SCVirtualMachine -Name "VM01"
PS C:\> Read-SCGuestInfo -VM $VM -Key "FullyQualifiedDomainName"
Example Example 2: Get the IntegrationServicesVersion value for a specified key for a virtual machine by using the pipeline operator.
This command returns the IntegrationServicesVersion key/value pair for virtual machine VM01.
PS C:\> Get-SCVirtualMachine -Name "VM01" | Read-SCGuestInfo -Key IntegrationServicesVersion
Example Example 3: Get multiple KVP values based on specified keys for a virtual machine.
The first command creates an array named $ValuesMap.
The second and third commands add values to the $ValuesMap array.
The fourth command gets the virtual machine object named VM02, and then stores the object in the $VM variable.
The last command returns the IntegrationServicesVersion and NetworkAddressIPv4 key/value pairs for virtual machine VM02.
PS C:\> $ValuesMap = @{}
PS C:\> $ValuesMap.Add("NetworkAddressIPv4", $Null)
PS C:\> $ValuesMap.Add("IntegrationServicesVersion", $Null)
PS C:\> $VM = Get-SCVirtualMachine "VM02"
PS C:\> Read-SCGuestInfo -VM $vm -KvpMap $ValuesMap
Example Example 4: Read multiple data types through a hashtable.
The first command gets the virtual machine object named VM03, and then stores the object in the $VM variable.
The second command creates an array named $ValuesMap.
The third command adds NetworkAddressIPv4 to the $ValuesMap array.
The fourth command gets the NetworkAddressIPv4 key/value pair for VM03.
The fifth command adds NetworkAddressIPv6 to the $ValuesMap array.
The sixth command gets the NetworkAddressIPv6 key/value pair for VM03.
The seventh command creates an array named $ValuesMap2 that contains NetworkAddressIPv4 and FullyQualifiedDomainName.
The last command returns the key/value pairs for NetworkAddressIPv4 and FullyQualifiedDomainName for VM03.
PS C:\> $VM = Get-SCVirtualMachine -Name "VM03"
PS C:\> $ValuesMap = @{}
PS C:\> $ValuesMap.Add("NetworkAddressIPv4", $Null)
PS C:\> Read-SCGuestInfo -VM $VM -KvpMap $ValuesMap
PS C:\> $ValuesMap.Add("NetworkAddressIPv6", $Null)
PS C:\> Read-SCGuestInfo -VM $VM -KvpMap $ValuesMap
PS C:\> $ValuesMap2 = @{"NetworkAddressIPv4" = $Null; "FullyQualifiedDomainName" = $Null}
PS C:\> Read-SCGuestInfo -VM $VM -KvpMap $ValuesMap2
Example 5: Read keys that do not exist
The first command gets the virtual machine object named VM01, and then stores the object in the $VM variable.
The second, fourth, and sixth commands each create a set of keys that are $Null, and then stores the set in the $KeysDoNotExist variable.
The third, fifth, and seventh commands read the KVPMap in $KeysDoNotExist and displays the results.
PS C:\> $VM = Get-SCVirtualMachine -Name "VM01"
PS C:\> $KeysDoNotExist = @{"o1ff1" = $Null; "o1ff2" = $Null; "o1ff3" = $Null ; "o1ff4" = $Null }
PS C:\> Read-SCGuestInfo -VM $VM -KVPMap $KeysDoNotExist
PS C:\> $KeysDoNotExist = @{"off4" = $Null; "o1ff2" = $Null; "o1ff3" = $Null ; "o1ff4" = $Null }
PS C:\> Read-SCGuestInfo -VM $VM -KVPMap $KeysDoNotExist
PS C:\> $KeysDoNotExist = @{"o1ff1" = $Null; "o1ff2" = $Null; "off4" = $Null ; "o1ff4" = $Null }
PS C:\> Read-SCGuestInfo -VM $VM -KVPMap $KeysDoNotExist