摘要
返回资源实例的 JSON 架构。
语法
dsc resource schema [Options] --resource <RESOURCE>
说明
子 schema 命令返回特定 DSC 资源的实例的 JSON 架构。 DSC 使用这些架构来验证 、 set和 test 子命令的get输入,以及验证 DSC 配置文档中的实例时。
集成工具可以使用这些架构进行验证或增强配置创作体验。 资源的实例架构定义实例的有效结构,包括哪些属性是必需的以及其值应该是什么。 实例架构还可能包含具有 title 和 description 关键字的属性的轻型文档。
示例
示例 1 - 获取资源的架构
此示例返回基于命令的 OSInfo DSC 资源的架构。
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://dori-uw-1.kuma-moon.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://dori-uw-1.kuma-moon.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://dori-uw-1.kuma-moon.com/powershell/dsc/reference/microsoft/osinfo/resource#id
markdownDescription: |
Returns the unique ID for the OSInfo instance data type.
[Online documentation][01]
[01]: https://dori-uw-1.kuma-moon.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://dori-uw-1.kuma-moon.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://dori-uw-1.kuma-moon.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://dori-uw-1.kuma-moon.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://dori-uw-1.kuma-moon.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://dori-uw-1.kuma-moon.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://dori-uw-1.kuma-moon.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://dori-uw-1.kuma-moon.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://dori-uw-1.kuma-moon.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://dori-uw-1.kuma-moon.com/powershell/dsc/reference/microsoft/osinfo/resource#family
markdownDescription: |
Defines whether the operating system is Linux, macOS, or Windows.
[Online documentation][01]
[01]: https://dori-uw-1.kuma-moon.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://dori-uw-1.kuma-moon.com/powershell/dsc/reference/microsoft/osinfo/resource#version
markdownDescription: |
Defines the version of the operating system as a string.
[Online documentation][01]
[01]: https://dori-uw-1.kuma-moon.com/powershell/dsc/reference/microsoft/osinfo/resource#version
选项
-r、 --resource
指定要从中检索实例架构的 DSC 资源的完全限定类型名称,例如 Microsoft.Windows/Registry。
完全限定的类型名称语法为: <owner>[.<group>][.<area>]/<name>,其中:
- 是
owner资源的维护作者或组织。 -
group和area是可选名称组件,用于为资源启用命名空间。 - 标识
name资源管理的组件。
Type: String
Mandatory: true
-f, --format
选项 --format 控制命令的控制台输出格式。 如果将命令输出重定向或捕获为变量,则输出始终为 JSON。
Type: String
Mandatory: false
DefaultValue: yaml
ValidValues: [json, pretty-json, yaml]
-h、--help
显示当前命令或子命令的帮助。 指定此选项时,应用程序将忽略此选项之后的所有选项和参数。
Type: Boolean
Mandatory: false
输出
此命令返回一个 JSON 对象,该对象表示指定 DSC 资源的实例的 JSON 架构。