0

I am running the following command to reset the password for a Windows VM and get the results in JSON format:

gcloud compute reset-windows-password \
  VM_NAME \
  --project=PROJECT_ID \
  --quiet \
  --zone=ZONE \
  --format=json \
  --verbosity=none

The following is printed to stdout:

Resetting and retrieving password for [USERNAME] on [VM_NAME]
Updated [https://www.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instances/VM_NAME].
{
  "ip_address": "1.2.3.4",
  "password": "XYZ",
  "username": "USERNAME"
}

This is more than the expected JSON, making it difficult to process the output.

What flag am I missing to suppress the first two lines?

5
  • On which OS are you running gcloud? Commented Dec 24, 2024 at 19:16
  • @DazWilkin I am on Linux Commented Dec 25, 2024 at 20:17
  • There is no gcloud flag to do this. I'm curious.The deleted answer on this page is the advice that I would give, namely to try sending stderr to /dev/null (2>/dev/null) Commented Dec 26, 2024 at 4:54
  • Unfortunately, I already tried that - it appears that both the informational notice as well as the JSON are output to the same stream (don't remember whether both were sent to stdout or both to stderr). Commented Dec 27, 2024 at 20:08
  • 1
    Yes, then, I think this is a bug in gcloud and you should consider filing it as an issue on issuetracker.google.com. As you expect, the JSON output should be to stdout and the extraneous (non-JSON) output to stderr Commented Dec 28, 2024 at 1:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.