?
Solved

Powershell pushing value over IP range by remote registry

Posted on 2011-03-01
4
Medium Priority
?
609 Views
Last Modified: 2012-05-11
Is there a way to push a certain registry value out over an ip range by using power shell?  I saw this the code below but thats by an individual computer.  Could you just use CMP=10.1.10.50-10.1.10.100 ?
SET "Cmp=RemoteComputerName"
SET "Key=HKLM\SYSTEM\ControlSet001\Services\LanmanServer\Parameters
SET "Item=srvcomment"
SET "Data=This will be the new Description of the COmputer!"

REG ADD "\\%cmp%\%Key%" /v %Item% /t REG_SZ /d "%Data%" /f

Open in new window

0
Comment
Question by:cmb991
  • 3
4 Comments
 
LVL 27

Accepted Solution

by:
KenMcF earned 2000 total points
ID: 35009304
You can use REG ADD from within a powershell script like this.

I have not tested so test before running on all computers.


$Item = "srvcomment"
$Data = "This will be the new Description of the COmputer!"
$Key = "HKLM\SYSTEM\ControlSet001\Services\LanmanServer\Parameters"
$Q = [CHAR]34
10..100 | %{
Invoke-Expression "REG ADD \\10.1.1.$($_)\$key /v $Item /t REG_SZ /d $q$Data$q /f"
}

Open in new window

0
 
LVL 1

Author Comment

by:cmb991
ID: 35009439
So would this work if execute or do you see something wrong?  It would set the value on a remote machine, then reset the remote machines network adapter:

$Item = "LOM"
$Data = "1"
$Key = "HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318}\0011\"

REG ADD \\10.1.10.$($_)\$key /v $Item /t REG_SZ /d $q$Data$q /f

$adaptor = Get-WmiObject -Class Win32_NetworkAdapter | Where-Object {$_.Name -like "*Wireless*"}
$adaptor.Disable()
$adaptor.Enable()

Open in new window

0
 
LVL 27

Assisted Solution

by:KenMcF
KenMcF earned 2000 total points
ID: 35009709
You will need to use invoke-expression to run REG ADD

Invoke-Expression REG ADD \\10.1.10.$($_)\$key /v $Item /t REG_SZ /d $q$Data$q /f  


I am not sure about disabling the network adapter, I am not able to test right now.  
0
 
LVL 27

Assisted Solution

by:KenMcF
KenMcF earned 2000 total points
ID: 35009716
This should have quotes

Invoke-Expression "REG ADD \\10.1.10.$($_)\$key /v $Item /t REG_SZ /d $q$Data$q /f"  

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Screencast - Getting to Know the Pipeline

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question