Powershell 3.0 and later.
If your script needs to add additional resources, such as server name, image name, etc. in the text, you need to consider the flexibility of the script.
Don't use absolute paths to assign your resource path. In Powershell 3.0, you can use $PSScriptRoot to replace your script path (2.0 is not supported)
Copy the codeThe code is as follows:
$picture = "$PSScriptRoot\Resources\"
Test-Path -Path $picture
$data = "$PSScriptRoot\Resources\"
Get-Content -Path $data
$PSScriptRoot can always get the directory name where your script is running. Of course you may find that it is empty when executing, and at this time you just need to save it to the script to execute.