Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Access HKCU using system account with Powershell

$
0
0

Hi Everyone,

I'm very new to Powershell. I'm trying to write a script that exports all Onenotebook URL's users have to a text file. Change part of the path save it then import it back to the registry. I'm having couple problems with this. 

1- We use SCCM in our environment which uses "NT Authority\System" account when the scripts run. When I try to use that account (Using Psexec) Powershell gives me an error "Can't find the path" because it is looking under HKCU for the system account which doesn't have the onenote installed.

2- When I export the values (URL's) from the registry, Although I get the links, I also get the name "Values".  Is there a way to just get the links and nothing else?

Value                                                                 
-----                                                                 
https://testtestetesteste.test.net/5834jlsdf34882d3d/^.Documents/
https://testtestetesteste.test.net/5834jlsdf34882d3d/^.Documents/           
https://testtestetesteste.test.net/5834jlsdf34882d3d/^.Documents/           
https://testtestetesteste.test.net/5834jlsdf34882d3d/^.Documents/  
https://testtestetesteste.test.net/5834jlsdf34882d3d/^.Documents/    
https://testtestetesteste.test.net/5834jlsdf34882d3d/^.Documents/ 
https://testtestetesteste.test.net/5834jlsdf34882d3d/^.Documents

The code I use to get this is : 

Push-Location
Set-Location 'HKCU:\Software\Microsoft\Office\14.0\Onenote\opennotebooks' 

Get-Item . | Select-Object -ExpandProperty Property | ForEach-Object {

New-Object PSobject -Property @{"property"=$_;"Value" = (Get-ItemProperty -Path . -Name $_).$_}} | Format-Table Value -AutoSize | Out-File $OneNoteBooks

Pop-Location

Thank you everyone in advance for their answers. 

-Fatih 


BesiktASK


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>