Invoke-LXCARestMethod
This cmdlets invokes a Lenovo XClarity Administrator REST API directly.
Note
You cannot pipe objects to this cmdlet.
Syntax
Invoke-LXCARestMethod -Connection LXCAConnection
-ResourceUrl String
-Method String
[-AdditionalHeaders Hashtable]
[-RequestBody String]
[-OutFile String]
[CommonParameter]
Invoke-LXCARestMethod -Connection LXCAConnection
-ResourceUrl String
-Method String
-UploadFilePath String[]
-UploadFormName String
[-AdditionalHeaders Hashtable]
[-OutFile String]
[CommonParameter]
Parameters
- -Connection LXCAConnection
- Specifies the connection to the Lenovo XClarity Administrator server. If no connection is specified, the result from the last Connect-LXCA cmdlet is used.
- -AdditionalHeaders Hashtable
- Specifies the additional request headers.The following headers are not supported:
- Accept
- Connection
- Conect-Length
- Content-Type
- Date
- Expect
- Host
- If-Modified-Since
- Range
- Referer
- Transfer-Encoding
- User-Agent
- -Method String
- Specifies the HTTP request method. You can specify one of the following methods:
- DELETE
- GET
- PATCH
- POST
- PUT
- -OutFile String
- Specifies the output directory and file name in which to return the response body. If you do not specify a directory, the output file is saved in the current location.
- -RequestBody String
- Specifies the request body.
- -ResourceUrl String
- Specifies the resource URL.
- -UploadFilePath String[]
- Specifies one or more file paths from which a file is to be uploaded.
- -UploadFormName String
- Specifies the field name in the POST method when uploading a file.
- CommonParameters
- This cmdlet supports the following common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer, -PipelineVariable, -OutVariable. For detailed information about each common parameter, see the Microsoft PowerShell Common Parameters webpage.
Results
If you specify the -OutFile parameter, this cmdlet returns an LXCARestResponseOutFile object that includes the HTTP response headers, HTTP status code, and full directory and file name of the output file.
If you do not specify the -OutFile parameter, this cmdlet returns an LXCARestResponse object that contains the HTTP response headers, HTTP status code, and response body.
Examples
- The following example sends a GET /nodes request with an additional header (Item=10).
$cred = Get-Credential
Connect-LXCA -Host 192.0.2.0 -Credential $cred
$url = "/nodes"
$headers = @{'Item'='10';}
$restResult = Invoke-LXCARestMethod -ResourceUrl url -Method GET -AdditionalHeaders $additionalHeader
$restResult.HttpStatusCode
$restResult.Headers
$restResult.Body
Disconnect-LXCA - The following example uploads an update policy file cmm.xml to the management server.
$cred = Get-Credential
Connect-LXCA -Host 192.0.2.0 -Credential $cred
$url = "compliancePolicies?action=import"
$restResult = Invoke-LXCARestMethod -Method POST -ResourceUrl $url -UploadFilePath C:\cmm.xml`
-UploadFormName "uploadedfiles[]"
$restResult.HttpStatusCode
$restResult.Headers
$restResult.Body
Disconnect-LXCA
Give documentation feedback