|
| 1 | +--- |
| 2 | +description: Command line reference for the 'dsc resource delete' command |
| 3 | +ms.date: 05/08/2024 |
| 4 | +ms.topic: reference |
| 5 | +title: dsc resource delete |
| 6 | +--- |
| 7 | + |
| 8 | +# dsc resource delete |
| 9 | + |
| 10 | +## Synopsis |
| 11 | + |
| 12 | +Invokes the delete operation of a resource. |
| 13 | + |
| 14 | +## Syntax |
| 15 | + |
| 16 | +### Without instance properties |
| 17 | + |
| 18 | +```sh |
| 19 | +dsc resource delete [Options] --resource <RESOURCE> |
| 20 | +``` |
| 21 | + |
| 22 | +### Instance properties from stdin |
| 23 | + |
| 24 | +```sh |
| 25 | +<instance-properties> | dsc resource delete [Options] --resource <RESOURCE> |
| 26 | +``` |
| 27 | + |
| 28 | +### Instance properties from input option |
| 29 | + |
| 30 | +```sh |
| 31 | +dsc resource delete --input '<instance-properties>' --resource <RESOURCE> |
| 32 | +``` |
| 33 | + |
| 34 | +### Instance properties from file |
| 35 | + |
| 36 | +```sh |
| 37 | +dsc resource delete --path <instance-properties-filepath> --resource <RESOURCE> |
| 38 | +``` |
| 39 | + |
| 40 | +## Description |
| 41 | + |
| 42 | +The `delete` subcommand removes a resource instance. |
| 43 | + |
| 44 | +Any properties the resource requires for discerning which instance to delete must be passed to this |
| 45 | +command as a JSON or YAML object. The object can be passed to this command from stdin or with the |
| 46 | +`--input` option. You can also use the `--path` option to read the object from a JSON or YAML file. |
| 47 | + |
| 48 | +This command returns no output when successful. If it encounters an error, it surfaces the error to |
| 49 | +the caller on stderr. |
| 50 | + |
| 51 | +## Examples |
| 52 | + |
| 53 | +### Example 1 - delete resource instance with input option |
| 54 | + |
| 55 | +If a resource requires one or more property values to return the actual state of the instance, the |
| 56 | +instance properties can be passed with the **input** option as either JSON or YAML. |
| 57 | + |
| 58 | +```sh |
| 59 | +dsc resource delete --resource Microsoft.Windows/Registry --input '{ |
| 60 | + "keyPath": "HKCU\\DSC\\Example" |
| 61 | +}' |
| 62 | +``` |
| 63 | + |
| 64 | +### Example 2 - delete resource instance with input from stdin |
| 65 | + |
| 66 | +If a resource requires one or more property values to return the actual state of the instance, the |
| 67 | +instance properties can be passed over stdin as either JSON or YAML. |
| 68 | + |
| 69 | +```sh |
| 70 | +'{ |
| 71 | + "keyPath": "HKCU\\DSC\\Example" |
| 72 | +}' | dsc resource delete --resource Microsoft.Windows/Registry |
| 73 | +``` |
| 74 | + |
| 75 | +### Example 3 - delete resource instance with input from a YAML file |
| 76 | + |
| 77 | +If a resource requires one or more property values to return the actual state of the instance, the |
| 78 | +instance properties can be retrieved from a saved JSON or YAML file. |
| 79 | + |
| 80 | +```sh |
| 81 | +cat ./example.delete.yaml |
| 82 | +``` |
| 83 | + |
| 84 | +```yaml |
| 85 | +keyPath: HKCU\\DSC\\Example |
| 86 | +``` |
| 87 | +
|
| 88 | +```sh |
| 89 | +dsc resource delete --resource Microsoft.Windows/Registry --path ./example.delete.yaml |
| 90 | +``` |
| 91 | + |
| 92 | +## Options |
| 93 | + |
| 94 | +### -r, --resource |
| 95 | + |
| 96 | +Specifies the fully qualified type name of the DSC Resource to use, like |
| 97 | +`Microsoft.Windows/Registry`. |
| 98 | + |
| 99 | +The fully qualified type name syntax is: `<owner>[.<group>][.<area>]/<name>`, where: |
| 100 | + |
| 101 | +- The `owner` is the maintaining author or organization for the resource. |
| 102 | +- The `group` and `area` are optional name components that enable namespacing for a resource. |
| 103 | +- The `name` identifies the component the resource manages. |
| 104 | + |
| 105 | +```yaml |
| 106 | +Type: String |
| 107 | +Mandatory: true |
| 108 | +``` |
| 109 | +
|
| 110 | +### -i, --input |
| 111 | +
|
| 112 | +Specifies a JSON or YAML object with the properties needed for retrieving an instance of the DSC |
| 113 | +Resource. DSC validates the object against the resource's instance schema. If the validation fails, |
| 114 | +DSC raises an error. |
| 115 | +
|
| 116 | +This option can't be used with instance properties over stdin or the `--path` option. Choose |
| 117 | +whether to pass the instance properties to the command over stdin, from a file with the `--path` |
| 118 | +option, or with the `--input` option. |
| 119 | + |
| 120 | +DSC ignores this option when the `--all` option is specified. |
| 121 | + |
| 122 | +```yaml |
| 123 | +Type: String |
| 124 | +Mandatory: false |
| 125 | +``` |
| 126 | + |
| 127 | +### -p, --path |
| 128 | + |
| 129 | +Defines the path to a text file to read as input for the command instead of piping input from stdin |
| 130 | +or passing it as a string with the `--input` option. The specified file must contain JSON or YAML |
| 131 | +that represents valid properties for the resource. DSC validates the object against the resource's |
| 132 | +instance schema. If the validation fails, or if the specified file doesn't exist, DSC raises an |
| 133 | +error. |
| 134 | + |
| 135 | +This option is mutually exclusive with the `--input` option. When you use this option, DSC |
| 136 | +ignores any input from stdin. |
| 137 | + |
| 138 | +DSC ignores this option when the `--all` option is specified. |
| 139 | + |
| 140 | +```yaml |
| 141 | +Type: String |
| 142 | +Mandatory: false |
| 143 | +``` |
| 144 | + |
| 145 | +### -h, --help |
| 146 | + |
| 147 | +Displays the help for the current command or subcommand. When you specify this option, the |
| 148 | +application ignores all options and arguments after this one. |
| 149 | + |
| 150 | +```yaml |
| 151 | +Type: Boolean |
| 152 | +Mandatory: false |
| 153 | +``` |
| 154 | + |
| 155 | +## Output |
| 156 | + |
| 157 | +This command returns no output when successful. When the resource errors, DSC surfaces the error on |
| 158 | +stderr. |
0 commit comments