-2

I need to read the registry of a computer for a specific string in a network drive mapping, if it's found I need to pipe the computername.txt to a specific location on the network.

I modified a script I found to look at the registry key for the current user and modify the key based on this string, but it's become a much larger project with several thousand computers and I need to be able to pass the info to the teams that support computers that I don't.

Sure, here's the script edited to remove organization specifics

Get-ItemProperty -Path HKCU:\Network\Z RemotePath | %{set-itemproperty -Path $.PSPath RemotePath -Value ( $.RemotePath -Replace "oldtext", "newtext" )}

I need to trigger the creation of a text file using the computer name if the old text is found and copy it to a network location.

Ray D
  • 3
  • 3
  • 1
    Can you post a sample of your script. What exactly are you stuck on? Sounds like you have it working for a few computers but need to run it on a lot more? – Dane Boulton Jun 09 '15 at 19:50
  • 1
    please provide more details, for example the registry location you want to check. Posting the script you have so far is also a good idea. – Marged Jun 09 '15 at 19:50

1 Answers1

0

So you want to read the registry of a remote pc, then create a text file if a certain string is found? Something like this should help:

$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computer1)
$RegKey= $Reg.OpenSubKey("HKCU:\Network\Z")
$RemotePath = $RegKey.GetValue("RemotePath")
if ($RemotePath -eq "oldtext"){
     new-item <path goes here> computer.txt
}

You'll need to update the paths and keys etc in the script above. More information: Get remote registry value

Community
  • 1
  • 1
user3046742
  • 235
  • 1
  • 11