Muni Bus

パソコンの操作方法や設定方法を忘れないようにメモしています。ブログを一回引っ越ししているので、所々表示がかなり乱れています・・・

【PowerShell】ファイルのパスを絶対パス(相対パス)を得る

PS C:\> Set-Location C:\Windows\System32
PS C:\Windows\System32> (Get-ChildItem drivers\etc).Name
hosts
lmhosts.sam
networks
protocol
services
PS C:\Windows\System32> (Get-ChildItem drivers\etc).FullName
C:\Windows\System32\drivers\etc\hosts
C:\Windows\System32\drivers\etc\lmhosts.sam
C:\Windows\System32\drivers\etc\networks
C:\Windows\System32\drivers\etc\protocol
C:\Windows\System32\drivers\etc\services

PS C:\> Set-Location Windows
PS C:\Windows> (Get-ChildItem system32\drivers\etc).Name
hosts
lmhosts.sam
networks
protocol
services
PS C:\Windows> (Get-ChildItem system32\drivers\etc).FullName
C:\Windows\system32\drivers\etc\hosts
C:\Windows\system32\drivers\etc\lmhosts.sam
C:\Windows\system32\drivers\etc\networks
C:\Windows\system32\drivers\etc\protocol
C:\Windows\system32\drivers\etc\services
PS C:\Windows> (Get-ChildItem system32\drivers\etc).FullName | Resolve-Path -Relative
.\system32\drivers\etc\hosts
.\system32\drivers\etc\lmhosts.sam
.\system32\drivers\etc\networks
.\system32\drivers\etc\protocol
.\system32\drivers\etc\services