Read-SCGuestInfo

Read-SCGuestInfo

Retrieves the value associated with a key in a guest operating system.

Syntax

Parameter Set: MultipleKvpKeys
Read-SCGuestInfo [-VM] <VM> -KvpMap <Hashtable> [ <CommonParameters>]

Parameter Set: SingleKvpKey
Read-SCGuestInfo [-VM] <VM> [-Key] <String> [ <CommonParameters>]

Detailed Description

The Read-SCGuestInfo cmdlet retrieves the value associated with a key (key/value pair) in a guest operating system.

Parameters

-Key<String>

Specifies the key in a key/value pair (KVP).

Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-KvpMap<Hashtable>

Specifies a hash table of key/value pairs (KVPs) corresponding to the KVP values exposed by Hyper-V.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-VM<VM>

Specifies a virtual machine object.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • String

Examples

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

Set-SCGuestInfo

Get-SCVirtualMachine