실제로 \\filesrver\share
으로가는 가상 R:
드라이브가 있다고 가정 해 봅시다.Powershell에서 전체 원격 경로를 얻는 방법은 무엇입니까?
net 공유를 확장하여 파일의 전체 원격 경로를 얻으려면 어떻게해야합니까?
(R:\Scripts\s.ps1
->\\fileserver\share\Scripts\s.ps1
)
실제로 \\filesrver\share
으로가는 가상 R:
드라이브가 있다고 가정 해 봅시다.Powershell에서 전체 원격 경로를 얻는 방법은 무엇입니까?
net 공유를 확장하여 파일의 전체 원격 경로를 얻으려면 어떻게해야합니까?
(R:\Scripts\s.ps1
->\\fileserver\share\Scripts\s.ps1
)
이 시도 :
get-item R:\Scripts\s.ps1 |
select @{n="path";e={ "$(get-psdrive $($_.psdrive) |
select -expa displayroot)$(split-path $_ -noqualifier)" }}
내 솔루션, 또한 로컬 경로 작동합니다 (물론이를 변경하지 않습니다) :
function Get-FullRemotePath($path) {
# Attempts to expand net shares
if (!(Test-Path $path)) { return $path }
$fileObj = Get-Item $path
$remotePath = (Get-PsDrive $fileObj.PSDrive).DisplayRoot
if ($remotePath) {
$path = $remotePath+(split-path $fileobj -noqualifier)
}
return $path
}
한 라이너가 아닙니다.