PowerShell 3+
The path of a running scripts is:
$PSCommandPath
Its directory is:
$PSScriptRoot
PowerShell 2
The path of a running scripts is:
$MyInvocation.MyCommand.Path
Its directory is:
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
More Related Contents:
- Need to extract value of attribute from xml from Command promt [closed]
- Merging multiple CSV files into one using PowerShell
- CMD or Powershell command to combine (merge) corresponding lines from two files [duplicate]
- How to call batch script from Powershell?
- How to run powershell command in batch file
- Batch file v PowerShell script
- How do I write the value of a single property of a object?
- PowerShell, formatting values in another culture
- How can I store output from Format-Table for later use
- Powershell Multidimensional Arrays
- How can I use powershell to run through an installer?
- How do I concatenate strings and variables in PowerShell?
- PowerShell and process exit codes
- How to load assemblies in PowerShell?
- How to automate either PowerShell or PowerShell Core for same machine
- How to exit from ForEach-Object in PowerShell
- copy-item With Alternate Credentials
- Powershell Invoke-Sqlcmd capture verbose output
- Convert a batch-file command with complex arguments to PowerShell
- Can I send some text to the STDIN of an active process under Windows?
- Running PowerShell as another user, and launching a script
- Powershell script to see currently logged in users (domain and machine) + status (active, idle, away)
- Remove Top Line of Text File with PowerShell
- Gracefully stopping in Powershell
- Upload BIG files via HTTP
- weird delay of the output of an object when followed by start-sleep (or until script end)
- Using Powershell environmental variables as strings when outputting files
- PowerShell launch script in new instance
- Remove last line from file with Powershell
- How to return specific data type from PowerShell function i.e. DataTable