R
R
Rampage14102021-07-05 09:59:36
PowerShell
Rampage1410, 2021-07-05 09:59:36

How to cyclically write strings to the registry?

There is a text file with IDshnikami devices: the
HID \ VID_046D & PID_C050 & REV_2720 the
HID \ VID_1A2C & PID_2124 & REV_0110 & MI_01 & Col01 the
PCI \ VEN_8086 & DEV_A294 & SUBSYS_86941043 & REV_F0 the
ACPI \ VEN_PNP & DEV_0C02 the
ACPI \ VEN_PNP & DEV_0100 the
HID \ VID_046D & PID_C077 & REV_7200 the
PCI \ VEN_1022 & DEV_1444 & SUBSYS_00000000 & REV_00 the
HID \ VID_1C4F & PID_0026 & REV_0110 & MI_01 & Col01 the
HID \ VID_046D & PID_C52B & REV_2407 & MI_02 & Col01 the
ACPI \ VEN_PNP & DEV_0C0B the
HID \ VID_17EF & PID_6018 & REV_0110 & MI_01 & Col01 the
ACPI \ VEN_ACPI & DEV_000C the
ACPI \ VEN_AMDI & DEV_F030 the
ACPI \ VEN_PNP & DEV_0B00 the
PCI \VEN_1022&DEV_43D5&SUBSYS_11421B21&REV_01
HID\VID_046D&PID_C52B&REV_2407&MI_00
HID\VID_0BB4&PID_0309&REV_0200
UMB \ VEN_013f & DEV_MFC-7360N
ACPI \ VEN_PNP & DEV_0103
PCI \ VEN_1022 & DEV_43C7 & SUBSYS_33061B21 & REV_01
HID \ VID_0BB4 & PID_09FE & REV_0200
{5d624f94-8850-40c3-a3fa-a4fd2080baf3} \ vwifimp_wfd
HID \ VID_145F & PID_01D3 & REV_0311 & MI_01 & Col01
PCI \ VEN_8086 & DEV_A2AF & SUBSYS_86941043 & REV_00
ACPI \ VEN_PNP & DEV_0000
PRINTENUM \ {133619e4-143b-463a-b809-b1f51d05f973}
UMB \VEN_013f&DEV_MFC-9342CDW
PCI\VEN_1022&DEV_1441&SUBSYS_00000000&REV_00
You need to loop the command: New-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\DeviceInstall\Restrictions\AllowDeviceIDs -Name Name -PropertyType String -Value name
to read each line to the end of the file and set the Name and Value attributes to the value of the string.
Please tell me how to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Bezrukov, 2021-07-05
@Rampage1410

something like this - each DeviceID is added as a separate entry (name = sequence number, value = DeviceID):

$SourcePath = "PathToYourFile"
If (Get-Item HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeviceInstall\Restrictions\AllowDeviceIDs)
{
    $SourceID = Get-Content $SourcePath
    $idx = 1
    foreach($DeviceID in $SourceID)
    {
        New-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeviceInstall\Restrictions\AllowDeviceIDs -Name $idx -PropertyType String -Value $DeviceID | Out-Null
        $idx++
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question