I have a script requirement to read users printers that are auto created at login and copy the string value name to a different string as value data.
example source string value name: Client/TestPC#/ZDesigner ZT410-300dpi ZPL
The script needs to find the 1st match searching for text and add it to PRINTER1 value, if more than one match it needs to add next to PRINTER2 value and so on.
My initial attempt below but having difficulty finding the values.
$regkeypath= "hkcu:\Software\Microsoft\Windows NT\CurrentVersion\Devices"
$value1 = (Get-ItemProperty $regkeypath) -like $ZDesigner
If ($value1 -eq $ZDesigner) {
Set-ItemProperty -path "HKCU:\Software\Test" -Name PRINTER1 -Value '$Value1' -Type string}
Else {Write-Host "The value does not exist"}