diff --git a/SOTF_FixCompanions.ps1 b/SOTF_FixCompanions.ps1 index 1871416..7e7383b 100644 --- a/SOTF_FixCompanions.ps1 +++ b/SOTF_FixCompanions.ps1 @@ -1,6 +1,7 @@ # CHACHA 2023 # V1.0 # CC BY-NC-SA +$ErrorActionPreference = "Stop" $MaxUniqueID=380000 @@ -8,10 +9,10 @@ $AppDataPath = [Environment]::GetFolderPath('ApplicationData') | split-path $SavesPath = [IO.Path]::Combine($AppDataPath,"LocalLow","Endnight","SonsOfTheForest","Saves") -$SaveDirPartial = Get-ChildItem -Path $SavesPath | Sort-Object -Property LastWriteTime -Descending | Select Name -First 1 -ExpandProperty Name +$SaveDirPartial = Get-ChildItem -Path $SavesPath | ?{ $_.PSIsContainer } | Sort-Object -Property LastWriteTime -Descending | Select Name -First 1 -ExpandProperty Name $SaveDirPartial = [IO.Path]::Combine($SavesPath,$SaveDirPartial,"Multiplayer") -$SaveDir = Get-ChildItem -Path $SaveDirPartial | Sort-Object -Property LastWriteTime -Descending | Select Name -First 1 -ExpandProperty Name +$SaveDir = Get-ChildItem -Path $SaveDirPartial| ?{ $_.PSIsContainer } | Sort-Object -Property LastWriteTime -Descending | Select Name -First 1 -ExpandProperty Name $SaveDir = [IO.Path]::Combine($SaveDirPartial,$SaveDir) ############################