Partager via


Schéma de ressource dsc

Synopsis

Retourne le schéma JSON pour les instances d’une ressource.

Syntaxe

dsc resource schema [Options] --resource <RESOURCE>

Description

La schema sous-commande retourne le schéma JSON pour une instance d’une ressource DSC spécifique. DSC utilise ces schémas pour valider l’entrée pour les getsous-commandes , setet et test lors de la validation des instances dans un document de configuration DSC.

Les outils d’intégration peuvent utiliser ces schémas pour la validation ou pour améliorer l’expérience de création de configuration. Le schéma de instance d’une ressource définit la structure valide d’un instance, y compris les propriétés obligatoires et leurs valeurs. Les schémas instance peuvent également inclure une documentation légère pour les propriétés avec les title mots clés et description .

Exemples

Exemple 1 - Obtenir le schéma d’une ressource

Cet exemple retourne le schéma de la OSInfo ressource DSC basée sur les commandes.

dsc resource schema --resource Microsoft/OSInfo
$schema: http://json-schema.org/draft-07/schema#
$id: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/resources/Microsoft/OSInfo/v0.1.0/schema.json
title: OsInfo
description: |
  Returns information about the operating system.

  https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource
markdownDescription: |
  The `Microsoft/OSInfo` resource enables you to assert whether a machine meets criteria related to
  the operating system. The resource is only capable of assertions. It doesn't implement the set
  operation and can't configure the operating system.

  [Online documentation][01]

  [01]: https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource
type: object
required: []
additionalProperties: false
properties:
  $id:
    type: string
    readOnly: true
    title: Data Type ID
    description: |
      Returns the unique ID for the OSInfo instance data type.

      https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource#id
    markdownDescription: |
      Returns the unique ID for the OSInfo instance data type.

      [Online documentation][01]

      [01]: https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource#id
  architecture:
    type: string
    title: Processor architecture
    description: |
      Defines the processor architecture as reported by 'uname -m' on the operating system.

      https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource#architecture
    markdownDescription: |
      Defines the processor architecture as reported by `uname -m` on the operating system.

      [Online documentation][01]

      [01]: https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource#architecture
  bitness:
    type: string
    enum:
    - '32'
    - '64'
    - unknown
    title: Operating system bitness
    description: |
      Defines whether the operating system is a 32-bit or 64-bit operating system.

      https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource#bitness
    markdownDescription: |
      Defines whether the operating system is a 32-bit or 64-bit operating system.

      [Online documentation][01]

      [01]: https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource#bitness
  codename:
    type: string
    title: Linux codename
    description: |
      Defines the codename for the operating system as returned from 'lsb_release --codename'.

      https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource#codename
    markdownDescription: |
      Defines the codename for the operating system as returned from `lsb_release --codename`.

      [Online documentation][01]

      [01]: https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource#codename
  edition:
    type: string
    title: Windows edition
    description: |
      Defines the operating system edition, like 'Windows 11' or 'Windows Server 2016'.

      https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource#edition
    markdownDescription: |
      Defines the operating system edition, like `Windows 11` or `Windows Server 2016`.

      [Online documentation][01]

      [01]: https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource#edition
  family:
    type: string
    enum:
    - Linux
    - macOS
    - Windows
    title: Operating system family
    description: |
      Defines whether the operating system is Linux, macOS, or Windows.

      https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource#family
    markdownDescription: |
      Defines whether the operating system is Linux, macOS, or Windows.

      [Online documentation][01]

      [01]: https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource#family
  version:
    type: string
    title: Operating system version
    description: |
      Defines the version of the operating system as a string.

      https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource#version
    markdownDescription: |
      Defines the version of the operating system as a string.

      [Online documentation][01]

      [01]: https://learn.microsoft.com/powershell/dsc/reference/microsoft/osinfo/resource#version

Options

-r, --resource

Spécifie le nom de type complet de la ressource DSC à partir de laquelle récupérer le schéma instance, comme Microsoft.Windows/Registry.

La syntaxe de nom de type complet est : <owner>[.<group>][.<area>]/<name>, où :

  • owner est l’auteur ou le organization de maintenance de la ressource.
  • Et grouparea sont des composants de nom facultatifs qui activent l’espacement des noms pour une ressource.
  • identifie name le composant que la ressource gère.
Type:      String
Mandatory: true

-f, --format

L’option --format contrôle le format de sortie de la console pour la commande . Si la sortie de la commande est redirigée ou capturée en tant que variable, la sortie est toujours JSON.

Type:         String
Mandatory:    false
DefaultValue: yaml
ValidValues:  [json, pretty-json, yaml]

-h, --help

Affiche l’aide de la commande ou de la sous-commande actuelle. Lorsque vous spécifiez cette option, l’application ignore toutes les options et arguments après celle-ci.

Type:      Boolean
Mandatory: false

Sortie

Cette commande retourne un objet JSON représentant le schéma JSON d’une instance de la ressource DSC spécifiée.