Skip to content

Commit

Permalink
Check if $item contains PSParentPath before the OneDrive check
Browse files Browse the repository at this point in the history
  • Loading branch information
joonro committed Jun 13, 2022
1 parent 391cd10 commit b907185
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Get-ChildItemColor.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ $Global:GetChildItemColorVerticalSpace = 1
function Get-FileColor($item) {
$key = 'Default'

$inOneDrive = ($item.PSParentPath.Contains($env:OneDrive) `
-or $item.PSParentPath.Contains($env:OneDriveConsumerOneDrive) `
-or $item.PSParentPath.Contains($env:OneDriveCommercial))
# check if in OneDrive
if ($item.PSobject.Properties.Name -contains "PSParentPath") {
$inOneDrive = ($item.PSParentPath.Contains($env:OneDrive) `
-or $item.PSParentPath.Contains($env:OneDriveConsumerOneDrive) `
-or $item.PSParentPath.Contains($env:OneDriveCommercial))
} else {
$inOneDrive = $false
}

if ([bool]($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -and (-not $inOneDrive)) {
$key = 'Symlink'
Expand Down

0 comments on commit b907185

Please sign in to comment.