From b907185fc12fd35ae2384b2f1cc13e65126faac1 Mon Sep 17 00:00:00 2001 From: Joon Ro Date: Mon, 13 Jun 2022 19:37:58 +0900 Subject: [PATCH] Check if $item contains PSParentPath before the OneDrive check --- src/Get-ChildItemColor.psm1 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Get-ChildItemColor.psm1 b/src/Get-ChildItemColor.psm1 index 30cde14..4e8a8fd 100644 --- a/src/Get-ChildItemColor.psm1 +++ b/src/Get-ChildItemColor.psm1 @@ -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'