Skip to main content

Invoke-LXCORestMethod

This cmdlets invokes a Lenovo XClarity Orchestrator REST API directly.

Note
You cannot pipe objects to this cmdlet.

Syntax

Invoke-LXCORestMethod  -Connection LXCOConnection
-Method WebRequestMethod
-ResourceUrl String
[-RequestBody String]
[-OutFile String]
[CommonParameter]

Invoke-LXCORestMethod -Connection LXCOConnection
-Method WebRequestMethod
-ResourceUrl String
-InFile String
-InFileFormName String
[-OutFile String]
[CommonParameter]

Parameters

-Connection LXCAConnection
Specifies the connection to the Lenovo XClarity Orchestrator server. If no connection is specified, the result from the last Connect-LXCO cmdlet is used.
-Method WebRequestMethod
Specifies the HTTP request method. You can specify one of the following methods.
  • DELETE
  • GET
  • PATCH
  • POST
  • PUT
-ResourceUrl String
Specifies the resource URL.
-InFile String
Specifies one or more file paths from which a file is to be uploaded.
-InFileFormName String
Specifies the field name in the POST method when uploading a file.
-OutFile String
Specifies the output directory and file name in which to return the response body.

If you do not specify a directory or file name, the response body is not saved in an output file.

If you do not specify a file name (in other words, if the destination ends in a back slash "\"), the default file name is lxcoRestMethod_MMddyyyy-HHmmss.out.

If the directory does not exist, it is automatically created.

-RequestBody String
Specifies the request body.
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

Examples

  • The following example adds a resource manager by sending the POST /api/v1/connector/managers request.
    $cred = Get-Credential
    Connect-LXCO -HostUri 192.0.2.0 -Credential $cred -SkipCertificateCheck
    $requestBody = @{
    managers = @(
    @{
    authentication = @{
    password = "CME44len"
    type = "basic"
    username = "USERID"
    }
    connection = @{
    hostname = "192.0.2.44"
    port = 443
    }
    options = @{
    enableDriveAnalyticsData = $true
    }
    type = "XClarity Administrator"
    }
    )
    } | ConvertTo-Json -Depth 4 -Compress

    $url = "/api/v1/connector/managers"
    $postResult = Invoke-LXCORestMethod -Method Post `
    -ResourceUrl $url `
    -RequestBody $requestBody `
    -OutFile $PSScriptRoot/../test/
    $postResult | Format-List

    $obj = ConvertFrom-Json -InputObject $postResult.ResponseBody
    $obj | Format-List

    Disconnect-LXCO