Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

Set-SCGuestInfo

Updated: September 27, 2012

Applies To: System Center 2012 - Virtual Machine Manager

Set-SCGuestInfo

Sets the value associated with a key for a key/value pair in a guest operating system.

Syntax

Parameter Set: MultipleKvpKeys
Set-SCGuestInfo [-VM] <VM> -KvpMap <Hashtable> [-JobVariable <String> ] [-PROTipID <Guid> ] [-RunAsynchronously] [ <CommonParameters>]

Parameter Set: SingleKvpKey
Set-SCGuestInfo [-VM] <VM> [-Key] <String> [[-Value] <String> ] [-JobVariable <String> ] [-PROTipID <Guid> ] [-RunAsynchronously] [ <CommonParameters>]




Detailed Description

The Set-SCGuestInfo cmdlet sets the value associated with a key for a key/value pair in a guest operating system.

For more information about Set-SCGuestInfo, type: "Get-Help Set-SCGuestInfo -online".

Parameters

-JobVariable<String>

Specifies that job progress is tracked and stored in the variable named by this parameter.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Key<String>

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


Aliases

none

Required?

true

Position?

2

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-KvpMap<Hashtable>

Specifies a hashtable 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?

true (ByValue)

Accept Wildcard Characters?

false

-PROTipID<Guid>

Specifies the ID of the PRO tip that triggered this action. This allows for auditing of PRO tips.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-RunAsynchronously

Indicates that the job runs asynchronously so that control returns to the command shell immediately.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Value<String>

Specifies a string used to attribute an object or property.


Aliases

none

Required?

false

Position?

3

Default Value

none

Accept Pipeline Input?

true (ByValue)

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.

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

1: Set a single key/value pair.

The first command gets the virtual machine object named VM01 and stores the object in the $VM variable.

The second command sets a key/value pair for VM01.


PS C:\> $VM = Get-SCVirtualMachine "VM01"PS C:\> Set-SCGuestInfo -VM $VM -Key Key -Value Value

2: Set a key to a value for a key/value pair.

This command sets the key to Microsoft.Lab.Isolation.ServerVersion and the value to 1.0.1101 for the virtual machine named VM01. If the key does not exist, it will be created with the specified value. If the key already exists, its value will be overwritten using the value specified in this command.

You can use the Read-SCGuestInfo cmdlet to provide the key and return its corresponding value.


PS C:\> Get-SCVirtualMachine -Name "VM01" | Set-SCGuestInfo -Key Microsoft.Lab.Isolation.ServerVersion -Value 1.0.1101

3: Set multiple key/value pairs.

The first command gets the virtual machine object named Win2k8R2 and stores the object in the $VM variable.

The second command creates a hashtable named $ValuesMap that contains the corresponding keys and values for the key/value pairs. Values can be set to a string, an empty string, or $null. Setting a value to $null deletes the key.

The third command sets the key/value pairs for the virtual machine named Win2k8R2.

The last command reads back the key/value pairs for the virtual machine named Win2k8R2.


PS C:\> $VM = Get-SCVirtualMachine -Name "Win2k8R2"PS C:\> $ValuesMap  = @{"Key1" = "avalue1"; "Key2IsEmptyString" = "" ; "Key3" = "value3"}PS C:\> Set-SCGuestInfo -VM $VM -KvpMap $ValuesMapPS C:\> Read-SCGuestInfo -VM $VM -KvpMap $ValuesMap | select KvpMap

4: Modify a set of values for a set of key/value pairs.

The first command gets the virtual machine object named Win2k8R2 and stores the object in the $VM variable.

The second command creates a hashtable named $ValuesMap that contains the corresponding keys and values for the key/value pairs. Values can be set to a string, an empty string, or $null. Setting a value to $null deletes the key.

The third command sets the key/value pairs for the virtual machine named Win2k8R2.

The fourth command reads back the key/value pairs for the virtual machine named Win2k8R2.

The fifth command creates a new hashtable where a specific key is changed to a different value.

The sixth command sets the modified value for the specified key in the hashtable.

The last two commands read back the key/value pairs for the virtual machine named Win2k8R2, including the modifiied value for the key Key2IsEmptyString.


PS C:\> $VM = Get-SCVirtualMachine -Name "Win2k8R2"PS C:\> $ValuesMap  = @{"Key1" = "avalue1"; "Key2IsEmptyString" = "" ; "Key3" = "value3"}PS C:\> Set-SCGuestInfo -VM $VM -KvpMap $ValuesMapPS C:\> Read-SCGuestInfo -VM $VM -KvpMap $ValuesMap | select KvpMapPS C:\> $ValuesMap  = @{"Key2IsEmptyString" = "KeyIsNoLongerEmpty"}PS C:\> Set-SCGuestInfo -VM $VM -KvpMap $ValuesMapPS C:\> $ValuesMap  = @{"Key1" = $null; "Key2IsEmptyString" = $null; "Key3" = $null}PS C:\> Read-SCGuestInfo -VM $VM -KvpMap $ValuesMap | select KvpMap

5: Delete a key/value pair using two methods.

The first command gets the virtual machine object named Win2k8R2 and stores the object in the $VM variable.

The next three commands create two keys and their values and return them to the console for virtual machine Win2k8R2.

The fifth command deletes the key/value pair Key1 by calling Set-SCGuestInfo without specifying the value parameter.

The sixth and seventh commands create a new Hashtable with Null as the value for key Key2. Then, key Key2 is deleted by calling the Set-SCGuestInfo command.

The last command shows that both keys that were initially created are now deleted via two separate methods.


PS C:\> $VM = Get-SCVirtualMachine -Name "Win2k8R2"PS C:\> $ValuesMap  = @{"Key1" = "avalue1"; "Key2" = "avalue2"}PS C:\> Set-SCGuestInfo -VM $VM -KvpMap $ValuesMapPS C:\> Read-SCGuestInfo -VM $VM -KvpMap $ValuesMap | select KvpMapPS C:\> Set-SCGuestInfo -VM $VM -Key Key1PS C:\> $KvpsToDelete  = @{"Key2" = $null}PS C:\> Set-SCGuestInfo -VM $VM -KvpMap $KvpsToDeletePS C:\> Read-SCGuestInfo -VM $VM -KvpMap $ValuesMap | select KvpMap

6: Set multiple values where one value is empty.

The first command gets the virtual machine object named VM01 and stores the object in the $VM variable.

The second command creates a hashtable named $ValuesMap3 that contains the corresponding keys and values for the key/value pairs. Values can be set to a string, an empty string, or $null. Setting a value to $null deletes the key.

The third command sets the values for the specified keys in the hashtable.

The last command reads back the key/value pairs for the virtual machine named VM01.


PS C:\> $VM = Get-SCVirtualMachine -Name "VM01"PS C:\> $ValuesMap3 = @{"VSLM1" = "value1"; "VLSM2" = "value2" ; "VLSM3" = "value3" ; "VLDM4" = ""}PS C:\> Set-SCGuestInfo -VM $VM -KVPMap $ValuesMap3PS C:\> Read-SCGuestInfo -VM $VM -KVPMap $ValuesMap3 | select KVPMap

7: Delete one value and set another value to empty.

The first command gets the virtual machine object named VM01 and stores the object in the $VM variable.

The second command creates a hashtable named $ValuesMap4 that contains the corresponding keys and values for the key/value pairs. Values can be set to a string, an empty string, or $null. Setting a value to $null deletes the key.

The third command sets the values for the specified keys in the hashtable.

The fourth command deletes key VLSM2 and sets key VSLM1 to empty by calling the Set-SCGuestInfo command.

The last command reads back the key/value pairs for the virtual machine named VM01.


PS C:\> $VM = Get-SCVirtualMachine -Name "VM01"PS C:\> $ValuesMap4 = @{"VLSM2" = $null; "VSLM1" = "" }PS C:\> Set-SCGuestInfo -VM $VM -KVPMap $ValuesMap4PS C:\> Read-SCGuestInfo -VM $VM -KVPMap $ValuesMap4 | select KVPMap

8: Set one value and delete another value.

The first command gets the virtual machine object named VM01 and stores the object in the $VM variable.

The second command creates a hashtable named $ValuesMap5 that contains the corresponding keys and values for the key/value pairs. Values can be set to a string, an empty string, or $null. Setting a value to $null deletes the key.

The fourth command sets key VSLM1 to "data again" and deletes key VLSM3 by calling the Set-SCGuestInfo command.

The last command reads back the key/value pairs for the virtual machine named VM01.


PS C:\> $VM = Get-SCVirtualMachine -Name "VM01"PS C:\> $ValuesMap5 = @{"VSLM1" = "data again"; "VLSM3" = $null }PS C:\> Set-SCGuestInfo -VM $VM -KVPMap $ValuesMap5PS C:\> Read-SCGuestInfo -VM $VM -KVPMap $ValuesMap5 | select KVPMap

9: Ignore the deletion of keys that do not exist.

The first command gets the virtual machine object named VM01 and stores the object in the $VM variable.

The second command creates a hashtable named $ValuesMap5 that contains the corresponding keys and values for the key/value pairs. Setting a value to $null deletes the key.

The third command sets the values to $null for the specified keys in the hashtable.

The last command deletes all keys in the hashtable except for key o1ff1 by calling the Set-SCGuestInfo cmdlet.


PS C:\> $VM = Get-SCVirtualMachine -Name "VM01"PS C:\> $KeysDoNotExist  = @{"o1ff1" = $null; "o1ff2" = $null; "o1ff3" = $null ; "o1ff4" = $null }PS C:\> Set-SCGuestInfo -VM $VM -KVPMap $KeysDoNotExistPS C:\> Set-SCGuestInfo -VM $VM -Key "o1ff1"

Related topics

 
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.