PowerCLI

  • 1.  Enable/Disable SSH for NSX manager using API calls

    Posted Jan 30, 2025 02:30 PM

    So i know very little about the api side of the house and trying to learn more.  Any resources to learn how to do this better would be greatly appreciated.

    I can get the current configuration of SSH. but I don't know how to format the put statement to turn off the settings.

    Invoke-restmethod -Uri "https://$($NSXMgr)/api/v1/node/services/ssh" -Method GET -Credential $mycreds -SkipCertificateCheck:$skipcertcheck -Authentication:$AuthMethod

    _schema                  _self                                service_name service_properties
    -------                  -----                                ------------ ------------------
    NodeSshServiceProperties @{href=/node/services/ssh; rel=self} ssh          @{root_login=True; start_on_boot=True}



    Failed PUT

    Invoke-restmethod -Uri "https://$($NSXMgr)/api/v1/node/services/ssh" -Method put -Credential $mycreds -SkipCertificateCheck:$skipcertcheck -Authentication:$AuthMethod -ContentType 'application/json' -body ('{"root_login":"False"')
    Invoke-RestMethod:
    {
      "error_code": 255,
      "error_message": "Request body not valid - Badly formatted body",
      "module_name": "common-services"
    }



  • 2.  RE: Enable/Disable SSH for NSX manager using API calls

    Posted Jan 31, 2025 03:07 AM

    The required body structure is documented in Update ssh service properties
    The page contains an example request body.




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


    Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference


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