Powershell中Powershell文件的文件夹路径 [英] Folder Path of Powershell file In Powershell

查看:45
本文介绍了Powershell中Powershell文件的文件夹路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个简单的问题似乎没人问,所以我会问的.

No one seems to ask this simple question, so I will.

我的 PowerShell 脚本文件位于:C:/this-folder/that-folder/another-folder/powershell-file.ps1

My PowerShell script file is located: C:/this-folder/that-folder/another-folder/powershell-file.ps1

如何获取返回的变量:C:/this-folder/that-folder/another-folder/

推荐答案

在你的脚本中试试这个命令:

try this command in your script:

Split-Path -parent $MyInvocation.MyCommand.Definition

这篇关于Powershell中Powershell文件的文件夹路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆