Solved

Powershell pushing value over IP range by remote registry

Posted on 2011-03-01
4
581 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 500 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 500 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 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This article will help you understand what HashTables are and how to use them in PowerShell.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

830 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