2

I am trying to export HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI as well as HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI regfile with PowerShell 2.0 to another drive.

I have read this StackOverflow post but I only get error message with that code. This may be because I am using v2.0. I cannot use a higher version.

Does anyone have any idea on why it doesn't work or possible how to copy both of them to another drive using PowerShell v2.0?

Code

reg copy HKCU\Software\ODBC\ODBC.INI H:\temp /s /f

Error

reg.exe : ERROR: Invalid key name.
At line:1 char:4
+ reg <<<<  copy HKCU\Software\ODBC\ODBC.INI H:\temp /s /f
    + CategoryInfo          : NotSpecified: (ERROR: Invalid key name.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

Type "REG COPY /?" for usage.
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Freppy
  • 25
  • 2
  • I would like a script to export/copy them to a folder called temp in network drive H: so when the user gets a new computer the user can just go into his own H: drive and open them on the new computer. – Freppy Jul 27 '17 at 11:20

1 Answers1

3

reg copy is for copying data from one registry key to another registry key, not for exporting registry keys to a file. That's what reg export is for.

reg export HKCU\Software\ODBC\ODBC.INI H:\temp\odbc_ini.reg /y

reg.exe is an external command, so the error has nothing to do with the PowerShell version.

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328