Jump to content

  • 0

Detecting OneDrive for Business


The script the Microsoft has posted doesn't work.  It may have at one time.


This is what I have used.

[String]$LogfileName = "OneDriveDetection"
[String]$Logfile = "$env:SystemRoot\logs\$LogfileName.log"

Function Write-Log
    Param ([string]$logstring)
    If (Test-Path $Logfile)
        If ((Get-Item $Logfile).Length -gt 2MB)
            Rename-Item $Logfile $Logfile".bak" -Force
    $WriteLine = (Get-Date).ToString() + " " + $logstring
    Add-content $Logfile -value $WriteLine

#$User = gwmi win32_computersystem -Property Username
[String](WMIObject -class Win32_ComputerSystem | Select username)
$UserName = $User.UserName
$UserSplit = [String](WMIObject -class Win32_ComputerSystem | Select username) -Split '\\'
$OneDrive = "$env:SystemDrive\users\" + $UserSplit[1] +"\appdata\local\microsoft\onedrive\onedrive.exe"
# Parameter to Log
Write-Log "Start Script Execution"
Write-Log "Logged on User: $UserName"
Write-Log "Detection-String: $OneDrive"
If(Test-Path $OneDrive)
    Write-Log "Found DetectionFile"
    $OneDriveFile = Get-Item $OneDrive
    Write-Log "Get File Details"
    Write-Log "Version found:$OneDriveFile.VersionInfo.FileVersion"
    Write-Log "Script Exectuion End!"
    Write-Log ""
    Return $true
    Write-Log "Warning: OneDrive.exe not found – need to install App!"


Share this post

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.