Hi,
I have made a powershell script, which does some add/delete things locally on a client with MS onedrive problems. Please see the script attached.
I succesfull tested the script on my own client and that fine, but now i found out that the local sync location path is different and uses different locations and pathnames on all company clients and therefore i need to add some code to my script which does the following:
1) Read the following stringdata regkey
Path: HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Common\Internet\LocalSyncClientDiskLocation
Type: REG_MULTI_SZ
Data: C:\Users\dfbdp\OneDrive - Danske Fragtmænd A-S
2) Insert this datavalue (path of folder) into the "Move-Item "C:\Users\$env:username\OneDrive - Danske Fragtmænd A-S""C:\Users\$env:username\Desktop\Onedrive_Backup"... in the script so the script reads the pathlocation from the regdatabase and then insert this into the path and moves these files into the "Onedrive_backup" folder etc.
I have tried to solve this problem my selv with the Get-RegistryKey etc but have not been able to make it work.
I am not that skilled in this, so can anyone help me?
Best regards
BDP
***************** Here is my current working powershell script ************
"+----------------------------------------------------+"
"¦ DF Onedrive reparation er igang. Vent venligst! ¦"
"+----------------------------------------------------+"
remove-itemproperty -path HKCU:\Software\Classes\.html -name SmpProperty
Start-Sleep -s 1
Stop-Process -processname groove
Stop-Process -processname msosync
Stop-Process -processname msouc
Stop-Process -processname csisyncclinet
Stop-Process -processname winword
Stop-Process -processname excel
Stop-Process -processname powerpnt
Stop-Process -processname outlook
"+----------------------------------------------------+"
"¦ Alle processer er stoppet! ¦"
"+----------------------------------------------------+"
Start-Sleep -s 1
New-Item -ItemType directory -Path C:\Users\$env:username\Desktop\Onedrive_Backup
Start-Sleep -s 1
Move-Item "C:\Users\$env:username\OneDrive - Danske Fragtmænd A-S""C:\Users\$env:username\Desktop\Onedrive_Backup"
Move-Item "C:\Users\$env:username\OneDrive for Business-arkiver" "C:\Users\$env:username\Desktop\Onedrive_Backup"
Start-Sleep -s 1
Remove-Item “C:\Users\$env:username\AppData\Local\Microsoft\Office\Spw” -Force -Recurse -ErrorAction SilentlyContinue
Remove-Item “C:\Users\$env:username\AppData\Local\Microsoft\Office\15.0\OfficeFileCache” -Force -Recurse -ErrorAction SilentlyContinue
Start-Sleep -s 1
"+----------------------------------------------------+"
"¦ Starter Synkronisering op igen! ¦"
"+----------------------------------------------------+"
Start-Process groove
Start-Sleep -s 1
"+----------------------------------------------------+"
"¦ Skriver i logfilen på serveren! ¦"
"+----------------------------------------------------+"
Start-Sleep -s 2
\\support01\wwwroot\Programmer\onedrivefixlog\Log.bat
↧
Help with reading a stringvalue (data) in regedit and using this in a script
↧