Good afternoon. I am trying to set up automatic uploading of downloaded files to a user’s onedrive directory, at logout. When running my script at logout the onedrive processes are already completed, I edit the attributes of the files so that they are subsequently processed by the onedrive processes to free up space, I also manually run onedrive from the default location, and interactively when running this script I can see that at logout onedrive starts and waits for account logon, so is there a dependency on some other service? I tried running the services associated with microsoft passport, but that didn’t solve the problem. Any idea why the current user account in the ondrive client fails to log in at this stage?
$logFile = "C:IntelLogfile.log"
Write-Output "$time - start script" | Out-File -FilePath $logFile -Append
Get-Process | select name, id, path | Out-File -FilePath $logFile -Append
Start-Process -FilePath "C:WINDOWSExplorer.EXE"
Start-Process -FilePath "C:Program FilesMicrosoft OneDriveOneDrive.exe"
Start-Sleep -Seconds 5
$FileCoAuth_Process = Get-Process -Name FileCoAuth -ErrorAction SilentlyContinue
if ($FileCoAuth_Process) {
Write-Output "$time - FileCoAuth - running" | Out-File -FilePath $logFile -Append
Start-Sleep -Seconds 5
} else {
Write-Output "$FileCoAuth_Path - not running" | Out-File -FilePath $logFile -Append
}
$onedrivePath = (Get-ItemProperty -Path "HKCU:SoftwareMicrosoftOneDriveAccountsBusiness1" -Name "UserFolder").UserFolder
$files = Get-ChildItem -Path $onedrivePath -Recurse
foreach ($file in $files) {
if ($file.Extension -ne ".lnk") {
Write-Host $file.FullName
attrib.exe +U $file.FullName
}
}
Start-Sleep -Seconds 60
Get-Process | select name, id, path | Out-File -FilePath $logFile -Append
I tried running the services associated with microsoft passport, but that didn’t solve the problem.
Stanislav Ilin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.