如果 $fileName 存在,则 cmdlet 等效于[System.IO.Path]::GetFullPath($fileName);
is (Get-Item $fileName).FullName
。但是,如果路径不存在,则会引发异常。他们是我缺少的另一个 cmdlet 吗?
Join-Path
是不可接受的,因为它在传递绝对路径时不起作用:
C:\Users\zippy\Documents\deleteme> join-path $pwd 'c:\config.sys'
C:\Users\zippy\Documents\deleteme\c:\config.sys
C:\Users\zippy\Documents\deleteme>