< Back

Invoke-HPERedfishAction

Tue Jan 14, 2020 2:01 am

NAME Invoke-HPERedfishAction



SYNOPSIS

Executes HTTP POST method on the destination server.





SYNTAX

Invoke-HPERedfishAction [-Odataid] <String> [[-Data] <Object>] [[-Session] <PSObject>]

[-DisableCertificateAuthentication] [<CommonParameters>]





DESCRIPTION

Executes HTTP POST method on the desitination server with the data from Data parameter. Used for invoking an

action like resetting the server.





PARAMETERS

-Odataid <String>

Odataid where you have to POST the data.



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue, ByPropertyName)

Accept wildcard characters? false



-Data <Object>

Data is the payload body for the HTTP POST request passed in the form of a JSON string or name-value hashtable

format.



Required? false

Position? 2

Default value

Accept pipeline input? false

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.



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 Invoke-HPERedfishAction. Odataid points to the location where the POST method is to be

executed.





OUTPUTS

System.Management.Automation.PSCustomObject

Invoke-HPERedfishAction 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:\\>$ret = Invoke-HPERedfishAction -Odataid $mgr..'@odata.id' -Data $null -Session $s



PS C:\\> $ret.error



@Message.ExtendedInfo code message

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

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





This example shows Invoke-HPERedfishData used to invoke a reset on the server. The 'ResetType' property is set to

'ForcedReset' and the output shows that reset was invoked successfully. The details of actions that can be

performed at a particular odataid are mentioned in the value for 'Actions' field.









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



$PS C:\\>$accData = Get-HPERedfishDataRaw -Odataid '/redfish/v1/AccountService/' -Session $session



$accountodataid = $accData.Accounts.'@odata.id'



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

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

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

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

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

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



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

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

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



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

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



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

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

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

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



$PS C:\\> $ret = Invoke-HPERedfishAction -Odataid $accountodataid -Data $user -Session $session



This example creates a user object and adds it to the Account odataid in AccountService.









-------------------------- EXAMPLE 3 --------------------------



PS C:\\>$sys = Get-HPERedfishDataRaw -Odataid /redfish/v1/systems/1/ -Session $s



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

PS C:\\> $settingToPost.Add('ResetType','ForceRestart')

PS C:\\> $ret = Invoke-HPERedfishAction -Odataid $sys.Actions.'#ComputerSystem.Reset'.target -Data $settingToPost

-Session $s

PS C:\\> $ret.error



Messages Name Type

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

{@{MessageID=iLO.0.10.ResetInProgress}} Extended Error Information ExtendedError.0.9.6



This example invokes a reset on the iLO for the server.









-------------------------- EXAMPLE 4 --------------------------



PS C:\\>$sys = Get-HPERedfishDataRaw -Odataid /redfish/v1/systems/1/ -Session $s



PS C:\\> $sys.LogServices



@odata.id

---------

/redfish/v1/Systems/1/LogServices/



PS C:\\> $logSerObj = Get-HPERedfishDataRaw $sys.LogServices.'@odata.id' -Session $s



PS C:\\> $logSerObj.Members



@odata.id

---------

/redfish/v1/Systems/1/LogServices/IML/



PS C:\\> $iml = Get-HPERedfishDataRaw $logSerObj.Members.'@odata.id' -Session $s



PS C:\\> $iml





@odata.context : /redfish/v1/$metadata#Systems/Members/1/LogServices/Members/$entity

@odata.id : /redfish/v1/Systems/1/LogServices/IML/

@odata.type : #LogService.1.0.0.LogService

Actions : @{#LogService.ClearLog=}

Entries : @{@odata.id=/redfish/v1/Systems/1/LogServices/IML/Entries/}

Id : IML

Name : Integrated Management Log

OverWritePolicy : WrapsWhenFull





PS C:\\> $iml.Actions



#LogService.ClearLog

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

@{target=/redfish/v1/Systems/1/LogServices/IML/Actions/LogService.ClearLog/}



PS C:\\> Invoke-HPERedfishAction -Odataid $iml.Actions.'#LogService.ClearLog'.target -Data $action -Session $session



{"Messages":[{"MessageID":"iLO.0.10.EventLogCleared"}],"Name":"Extended Error

Information","Type":"ExtendedError.0.9.6"}





This example clears the IML logs by creating a JSON object with action to clear the Integraged Management Logs.









-------------------------- EXAMPLE 5 --------------------------



PS C:\\>$mgr = Get-HPERedfishDataRaw -Odataid /redfish/v1/managers/1/ -Session $s



PS C:\\> $mgr.LogServices



@odata.id

---------

/redfish/v1/Managers/1/LogServices/



PS C:\\> $logSerObj = Get-HPERedfishDataRaw $mgr.LogServices.'@odata.id' -Session $s



PS C:\\> $logSerObj.Members



@odata.id

---------

/redfish/v1/Managers/1/LogServices/IEL/



PS C:\\> $iml = Get-HPERedfishDataRaw $logSerObj.Members.'@odata.id' -Session $s



PS C:\\> $iml





@odata.context : /redfish/v1/$metadata#Managers/Members/1/LogServices/Members/$entity

@odata.id : /redfish/v1/Managers/1/LogServices/IEL/

@odata.type : #LogService.1.0.0.LogService

Actions : @{#LogService.ClearLog=}

Entries : @{@odata.id=/redfish/v1/Managers/1/LogServices/IEL/Entries/}

Id : IEL

Name : iLO Event Log

OverWritePolicy : WrapsWhenFull





PS C:\\> $iml.Actions



#LogService.ClearLog

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

@{target=/redfish/v1/Systems/1/LogServices/IML/Actions/LogService.ClearLog/}



PS C:\\> $ret = Invoke-HPERedfishAction -Odataid $iml.Actions.'#LogService.ClearLog'.target -Data $action -Session

$s



PS C:\\> $ret.error



{"Messages":[{"MessageID":"iLO.0.10.EventLogCleared"}],"Name":"Extended Error

Information","Type":"ExtendedError.0.9.6"}





This example clears the IML logs by creating a JSON object with action to clear the IML.











RELATED LINKS

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