What is $PSScriptRoot in PowerShell?
$PSScriptRoot is an Automatic Variable, which are built-in variables that comprise records about the PowerShell surroundings itself. $PSScriptRoot includes the listing direction of the script being done currently.
Originally $PSScriptRoot used to be solely relevant to script modules, however commencing with PowerShell 3.0, it works for all PowerShell script files. From the console, if I kind $PSScriptRoot and press ENTER, it returns nothing.
Suggest An Answer
$PSScriptRoot is an Automatic Variable, which are built-in variables that contain information about the PowerShell environment itself. $PSScriptRoot contains the directory path of the script being executed currently.