powershell - Importing registry (.reg) files fails -
i'm having trouble importing .reg files on windows server 2012. script works on server 2008, works when typed @ powershell prompt, , works when run "double-click" on server 2012 instance.
the script unzips file containing .reg files, imports them registry.
write-output "unzipping aux package" unzip-file -file "$download_dir\$s3_aux_package" -destination $destinationfolder write-output "done unzipping aux package" # import registry files in aux archive package $registryfiles = get-childitem $destinationfolder | {$_.extension -eq ".reg"} $registryfiles = $registryfiles | % {$_.name} foreach ($regfile in $registryfiles) { move "$destinationfolder\$regfile" "$download_dir" $cmd = "regedit /s `"$download_dir\$regfile`" " write-output "$cmd" invoke-expression $cmd }
i can see the correct parameters , file names appear write-output entries:
unzipping aux package 09:30:08: done unzipping aux package 09:30:09: regedit /s "c:\\downloads\controlset001-110-64.reg" 09:30:11: regedit /s "c:\\downloads\currentcontrolset110-64.reg" 09:30:11: regedit /s "c:\\downloads\hkcu110-64.reg" 09:30:11: regedit /s "c:\\downloads\hklm110-64.reg"
but seems importing first 2 .reg files - both controlset files. other 2 "hkcu" , "hklm" don't import @ all.
these paths these reg files trying write to:
controlset001-110-64.reg - hkey_local_machine\system\controlset001\services\adminservice11.0
currentcontrolset110-64.reg - hkey_local_machine\system\currentcontrolset\services\adminservice11.0
hkcu110-64.reg - hkey_current_user\software\psc
hklm110-64.reg - hkey_local_machine\software\psc
in script, i'm able import reg files write hkey_local_machine\software\wow6432node\
weird since i'm unable write it's parent node software
.
i same result regedit /s
or reg import
.
how can investigate issue? pointers? can debug individual powershell lines - maybe verbose output? powershell have equivalent importing registry files? please help!
why making things complicated? get-childitem
cmdlet returns fileinfo
objects, have property fullname
has full path item, in case .reg
files.
this should work:
write-output "unzipping aux package" unzip-file -file "$download_dir\$s3_aux_package" -destination $destinationfolder write-output "done unzipping aux package" get-childitem $destinationfolder | ? { $_.extension -eq '.reg' } | % { & reg import $_.fullname }
note need run "as administrator" able write hklm.
Comments
Post a Comment