en-US/about_cRegistryUpdater.help.txt
TOPIC
about_cRegistryUpdater DESCRIPTION The cRegistryUpdater DSC resource can be used to create or delete registry keys by means of importing a .reg file. ADDING NEW KEYS / UPDATING VALUES If you need to add new registry keys or update values of existing ones then use a configuration with the $Ensure property set to [Ensure]::Present and the $RegFilePath containing a valid path to a .reg file. The resource updates registry by means of importing the specified .reg file. Example: cRegistryUpdater printerRegistry { RegFilePath = "\\share\present.reg" Ensure = "Present" } DELETING KEYS cRegistryUpdater offers you two options if you want to delete selected registry keys: 1. Use a standard .reg file with $Ensure = [Ensure]::Absent The resource reads all registry keys ([HKEY*]) from the .reg file and attempts to delete each individual key from Windows registry. cRegistryUpdater printerRegistry { RegFilePath = "\\share\present.reg" Ensure = "Absent" } 2. Use a modified .reg file with $Ensure = [Ensure]::Present You can modify a standard .reg file in that way you add a minus ("-") operator at the beginning of each key name. Example: Provide the modified .reg file with a minus sign added to the beginnig of each key you want to delete. Let's name it "absent.reg". Original value: [HKEY_LOCAL_MACHINE\Software\MyKey] New value: [-HKEY_LOCAL_MACHINE\Software\MyKey] cRegistryUpdater printerRegistry { RegFilePath = "\\share\absent.reg" Ensure = "Present" } LOGIC OF Test-TargetResource METHOD The Test-TargetResource method of cRegistryUpdater implements the following logic: A) $Ensure = [Ensure]::Present The method returns FALSE if any of the keys contained in the .reg file meets one of the following conditions: 1. The key name in the file contains a minus sign (e.g.: [-HKEY_LOCAL_MACHINE\...) but it already exists in registry. 2. The key name in the file does not start with a minus sign (e.g.: [HKEY_LOCAL_MACHINE\...) but it does not exist in registry. Otherwise, it returns TRUE. B) $Ensure = [Ensure]::Absent The method returns TRUE only if none of the keys contained in the .reg file exists in registry. Otherwise, it returns FALSE. INTEGRATION OF cRegistryUpdater FUNCTIONALITY WITHIN cPrintDriverUpdater Besides standalone declarations of cRegistryUpdater resources in configuration files (as described above), you can update registry through cPrintDriverUpdater resource as well. There are two ways how to pass the registry file: 1. Use the RegFilePath property of cPrintDriverUpdater, e. g.: cPrintDriverUpdater printDriver01 { Ensure = "Present" DriversRoot = "\\share\PrintDrivers" RegFilePath = "\\share\PrintDrivers\present.reg" } The registry file is applied after installing drivers by default. You can change the order of these steps by setting the optional property ApplyRegChangesBeforeDriverUpdate = $true. The logic of [Ensure]::Present/Absent works as described above (cPrintDriverUpdater initiates cRegistryUpdater with the value of its Ensure property). 2. Use the regFilePath attribute of the driver element in the print driver database (XML file), e.g.: <PrintDrivers> <driver name="Canon Inkjet 0253 Class Driver" infPath="prncacla.inf_amd64_b62d982f43099a77\prncacla.inf" regFilePath="\\share\PrintDrivers\present.reg" /> </PrintDrivers> The registry file is imported right after installing the corresponding driver. The registry file is imported only when Ensure = "Present". If Ensure = "Absent" then all PnP drivers are deleted without parsing the print driver database and importing registry files specified in driver elements. |