Powershell: resolve path that might not exist?

前端 未结 13 2486
再見小時候
再見小時候 2020-12-02 13:05

I\'m trying to process a list of files that may or may not be up to date and may or may not yet exist. In doing so, I need to resolve the full path of an item, even though

13条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 13:31

    You can just set the -errorAction to "SilentlyContinue" and use Resolve-Path

    5 >  (Resolve-Path .\AllFilerData.xml -ea 0).Path
    C:\Users\Andy.Schneider\Documents\WindowsPowerShell\Scripts\AllFilerData.xml
    
    6 >  (Resolve-Path .\DoesNotExist -ea 0).Path
    
    7 >
    

提交回复
热议问题