Home > Enterprise >  Save variables with Azure CLI REST
Save variables with Azure CLI REST

Time:09-05

I'm currently using following 'Script' to obtain Base64EncodedPackage in Powershell 7 (can switch to command prompt also if needed)

$subscriptionId = "0000-0000-0000-0000"
$vm = "MyVmName"
$vmrg = "MyRgName"
$resourceId = "/subscriptions/$subscriptionId/resourceGroups/$vmrg/providers/Microsoft.Compute/virtualMachines/$vm"


#Log in to CLI
az login     

#Log in to wanted subscription
az account set --subscription $subscriptionId  

#Show Base64EncodedPackages
$package = az rest --method get --uri https://management.azure.com/subscriptions/$subscriptionId/providers/Microsoft.Security/mdeOnboardings?api-version=2021-10-01-preview

$package then will output following

 {
      "value": [
        {
          "id": "/subscriptions/0000-0000-0000-0000/providers/Microsoft.Security/mdeOnboardings/default",
          "location": "westeurope",
          "name": "default",
          "properties": {
            "onboardingPackageLinux": "Package code",
            "onboardingPackageWindows": "Package code that we want to save for further use"
          },
          "type": "Microsoft.Security/mdeOnboardings"
        }
      ]
    }

And the thing that I would want to somehow save is onboardingPackageWindows so I can use it later on without copying manually the package code. I have tried almost everything that I known google examples but still have issues.

CodePudding user response:

Resolved

I used ConvertFrom-Json to get wanted data.

  • Related