< Back

Set-HPERedfishData

Tue Jan 14, 2020 2:02 am

NAME Set-HPERedfishData



SYNOPSIS

Executes HTTP PATCH method on destination server.





SYNTAX

Set-HPERedfishData [-Odataid] <String> [[-Setting] <Object>] [[-Session] <PSObject>]

[-DisableCertificateAuthentication] [<CommonParameters>]





DESCRIPTION

Executes HTTP PATCH method at the specified Odataid. This cmdlet is used to update the value of an editable

property in the redfish data source. A property name and the new value must be provided to modify a value. If the

Property name is left blank or not specified, then the PATCH is done using the Value parameter on the Odataid.





PARAMETERS

-Odataid <String>

Odataid where the property is to be modified.



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue, ByPropertyName)

Accept wildcard characters? false



-Setting <Object>

Specifies a JSON string or a hashtable which has the name of the setting to be modified and the corresponding

value. This parameter is the payload body of the HTTP PATCH request. Multiple properties can be modified using

the same request by stating multiple name-value pairs in the same hashtable structure.

Example 1: $setting = @{'property1'= 'value1'}

Example 2: $setting = @{'property1'= 'value1'; 'property2'='value2'}

This can also be a complex(nested) hashtable.

Example: $priv = @{}

$priv.Add('RemoteConsolePriv',$true)

$priv.Add('iLOConfigPriv',$true)

$priv.Add('VirtualMediaPriv',$true)

$priv.Add('UserConfigPriv',$true)

$priv.Add('VirtualPowerAndResetPriv',$true)



$hp = @{}

$hp.Add('LoginName','user1')

$hp.Add('Privileges',$priv)



$oem = @{}

$oem.Add('Hp',$hp)



$user = @{}

$user.Add('UserName','adminUser')

$user.Add('Password','password123')

$user.Add('Oem',$oem)



This example shows a complex $user object that is used as 'Setting' parameter value to update

properties/privileges of a user. This is passed to the Odataid of the user whose details are to be updated.



Required? false

Position? 2

Default value

Accept pipeline input? true (ByPropertyName)

Accept wildcard characters? false



-Session <PSObject>

Session PSObject returned by executing Connect-HPERedfish cmdlet. It must have RootURI to create the complete

URI along with the Odataid parameter. The root URI of the Redfish data source and the X-Auth-Token session

identifier required for executing this cmdlet is obtained from Session parameter.



Required? false

Position? 3

Default value

Accept pipeline input? true (ByPropertyName)

Accept wildcard characters? false



-DisableCertificateAuthentication [<SwitchParameter>]

If this switch parameter is present then server certificate authentication is disabled for the execution of

this cmdlet. If not present it will execute according to the global certificate authentication setting. The

default is to authenticate server certificates. See Enable-HPERedfishCertificateAuthentication and

Disable-HPERedfishCertificateAuthentication to set the per PowerShell session default.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

System.String

You can pipe the Odataid to Set-HPERedfishData. Odataid points to the location where the PATCH method is to be

executed.





OUTPUTS

System.Management.Automation.PSCustomObject

Set-HPERedfishData returns a PSObject that has message from the HTTP response. The response may be informational

or may have a message requiring an action like server reset.





NOTES





- Edit-HPERedfishData is for HTTP PUT method

- Invoke-HPERedfishAction is for HTTP POST method

- Remove-HPERedfishData is for HTTP DELETE method

- Set-HPERedfishData is for HTTP PATCH method



See typical usage examples in the HPERedfishExamples.ps1 file installed with this module.



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>$setting = @{'IndicatorLED' = 'Lit'}



PS C:\\> $ret = Set-HPERedfishData -Odataid /redfish/v1/systems/1/ -Setting $setting -Session $s

PS C:\\> $ret.error



@Message.ExtendedInfo code message

--------------------- ---- -------

{@{MessageId=Base.0.10.Success}} iLO.0.10.ExtendedInfo See @Message.ExtendedInfo for more inf...



This example shows updating the 'IndicatorLED' field in computer system setting to set the value to 'Lit'.









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>$LoginNameToModify = 'TimHorton'



PS C:\\> $accounts = Get-HPERedfishDataRaw -Odataid '/redfish/v1/AccountService/Accounts/' -Session $s

PS C:\\> $reqAccount = $null

foreach($acc in $accounts.Members.'@odata.id')

{

$accountInfo = Get-HPERedfishDataRaw -Odataid $acc -Session $s

if($accountInfo.UserName -eq $LoginNameToModify)

{

$reqAccount = $accountInfo

break;

}

}

PS C:\\> $priv = @{}

$priv.Add('VirtualMediaPriv',$false)

$priv.Add('UserConfigPriv',$false)



$hp = @{}

$hp.Add('Privileges',$priv)



$oem = @{}

$oem.Add('Hp',$hp)



$user = @{}

$user.Add('Oem',$oem)



PS C:\\> $ret = Set-HPERedfishData -Odataid $reqAccount.'@odata.id' -Setting $user -Session $s

PS C:\\> $ret



Messages Name Type

-------- ---- ----

{@{MessageID=Base.0.10.AccountModified}} Extended Error Information ExtendedError.0.9.6



This example shows modification of user privilege for a user. First the Odataid of the user 'TimHorton' is

seacrched from Accounts Odataid. Then user object is created with the required privilege change. This object is

then used as the setting parameter value for Set-HPERedfishData cmdlet.











RELATED LINKS

http://www.hpe.com/servers/powershell