有没有办法通过双击 .ps1 文件来使 PowerShell 脚本工作? [英] Is there a way to make a PowerShell script work by double clicking a .ps1 file?

查看:28
本文介绍了有没有办法通过双击 .ps1 文件来使 PowerShell 脚本工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向我的团队分发 PowerShell 脚本.该脚本用于从 Vsphere 客户端获取 IP 地址,建立 mstsc 连接,并将其记录到共享文件中.

I am distributing a PowerShell script to my team. The script is to fetch an IP address from the Vsphere client, make an mstsc connection, and log it in a shared file.

当他们使用脚本时,他们就知道了机器的 IP 地址.之后,他们总是倾向于直接使用 mstsc 而不是运行 PowerShell 脚本.(由于他们使用的是 mstsc,我无法知道他们是否经常使用 VM.)

The moment they used the script they got to know the IP address of machine. After that, they always tend to use mstsc directly instead of running the PowerShell script. (As they are using mstsc I am not able to know whether they are using the VM frequently or not.)

主要是他们告诉我运行 PowerShell 并不简单.

Mainly they are telling me that running PowerShell is not straightforward.

我为他们的懒惰感到恶心.

I am sick by their laziness.

有没有办法通过双击 .ps1 文件来使 PowerShell 脚本工作?

Is there a way to make a PowerShell script work by double clicking a .ps1 file?

推荐答案

用类似这样的东西作为目标"创建一个快捷方式:

Create a shortcut with something like this as the "Target":

powershell.exe -command "& 'C:\A path with spaces\MyScript.ps1' -MyArguments blah"

这篇关于有没有办法通过双击 .ps1 文件来使 PowerShell 脚本工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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