Solved

Powershell pushing value over IP range by remote registry

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Set OWA language and time zone in Exchange for individuals, all users or per database.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now