ChildItem
in PowerShellIn PowerShell, you can use the FullName
property of the System.IO.FileInfo
or System.IO.DirectoryInfo
class to get the full path of a ChildItem
. This property returns the full path of a file or directory as a string.
To use the FullName
property, you will first need to create an instance of the FileInfo
or DirectoryInfo
class for the ChildItem
you want to get the full path of. This can be done using the Get-Item
cmdlet, which takes the path of the ChildItem
as an input and returns a FileInfo
or DirectoryInfo
object.
Once you have a FileInfo
or DirectoryInfo
object for the ChildItem
, you can use the FullName
property to get the full path of the item.
For example, the following PowerShell code gets the full path of a file named "myFile.txt"
in the "C:\myFiles"
directory:
$fileInfo = Get-Item "C:\myFiles\myFile.txt"
$fullPath = $fileInfo.FullName
This code uses the Get-Item
cmdlet to create a FileInfo
object for the "myFile.txt"
file, and then uses the FullName
property to get the full path of the file and store it in the $fullPath
variable.
It is important to note that the FullName
property only returns the full path of the item. It does not include the name of the item itself.
To get the full path and the name of the item, you can use the FullPath
property instead. This property returns the full path and the name of the item as a single string.
For example, the following PowerShell code gets the full path and name of a directory named "myDir"
in the "C:\myFiles"
directory:
$dirInfo = Get-Item "C:\myFiles\myDir"
$fullPath = $dirInfo.FullPath
In PowerShell, you can use the FullName
property of the System.IO.FileInfo
or System.IO.DirectoryInfo
class to get the full path of a ChildItem
. This property returns the full path of a file or directory as a string.
Related tutorials curated for you
How to get processes in PowerShell
What is a Scriptblock in PowerShell?
Everything about certificates in PowerShell
How to get the current directory in PowerShell
Do Until in PowerShell
While loops in PowerShell
How to unzip a file in Powershell
How to install PowerShell on Mac
PowerShell do-while loop
How to stop Windows PowerSHell from randomly popping up
Boolean literals in PowerShell
How to use -Contains in PowerShell