# GET-USERERRORLOGS
# Binary Tree Inc
# Sept 2019
# Disclaimer: This example script is shared freely without warranty or support. It is only intended to provide guidance by example to project administrators.
# Don't forget to connect to Power365 or add it to your script
# Get a user's sync job logs by job type "error" then display in searchable grid and export to csv
# This script does the following:
# 1. Prompt for a user’s primary smtp address
# 2. Get all the user’s ODB Sync jobs or change the filter to a different job type like Mail.
# 3. Get all the associated log from those jobs
# 4. Filter out all errors except those matching the search strings.
# 5. Then display only the errors related to missed items
# 6. The data will be displayed in a searchable grid view and exported to a local CSV file.
Cls
Write-Host
write-host 'Enter the users primary smtp address (i.e. user@contoso.com): '
$UserName = Read-Host
if ($UserName) {
Write-Host "Retrieving OneDrive Sync Logs for $UserName"
$user = get-btuser $UserName
# Get errors based on message filters
$Results = get-btsync -user $user -filter "SyncDataType -eq 'OneDriveForBusiness'" | get-btlog -level error | where-object {($_.Message -like "Unable to sync*") -or ($_.Message -like "Could not copy file*")}
# Get errors from the last sync log
# $Results = get-btsync -user $user -filter "SyncDataType -eq 'OneDriveForBusiness'" | Select-Object -First 1 | get-btlog
# Get warnings for all ODB sync job logs
# $Results = get-btsync -user $user -filter "SyncDataType -eq 'OneDriveForBusiness'" | get-btlog -level warn
# Output results to grid view
$Results | Out-GridView -Title ($user.wavename + "-" + $user.PrimarySmtpAddress)
# Output results to csv file
$CSVName = $user.PrimarySmtpAddress + ".csv"
$CSVPath = ".\" + $CSVName
$Results | Export-Csv -Path $CSVPath -NoTypeInformation
} else {
Write-Warning -Message "No name was entered."
}
© ALL RIGHTS RESERVED. Feedback 이용 약관 개인정보 보호정책 Cookie Preference Center