PSScriptRoot

suggest change
Get-ChildItem -Path $PSScriptRoot

This example retrieves the list of child items (directories and files) from the folder where the script file resides.

$PSScriptRoot is $null outside a script file, including at the interactive prompt. Inside a script, it is the fully qualified filesystem path of the directory that contains the script file.

In Windows PowerShell 2.0, this variable is valid only in script modules (.psm1). Beginning in Windows PowerShell 3.0, and in PowerShell 6 and later, it is valid in all scripts.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents