powershell - 将参数传递给 powershell 调用表达式命令
问题描述
我的问题与此类似:
How to pass arguments to an Invoke-Expression, in Powershell?
我有以下命令:
powershell iex ((New-Object Net.WebClient -Property @{Proxy = [Net.GlobalProxySelection]::GetEmptyWebProxy()}).DownloadString('https://github/test.ps1'))
如果可能的话,我想以某种方式将以下参数传递给这个命令,所以只需扩展我的命令。
"${node.site}" "${node.zone}"
如果一根线不可能,也可以放两根线。
解决方案
您可以通过帮助搜索PowerShell.exe
--> 'PowerShell.exe /?' 从 PowerShell/cmd 控制台。
下面是您要求的一个可能示例。
PowerShell -Command " & {param(`$r) Write-Output `$r }" 'sometext'
也许对你
powershell -command " & {param(`$Url) iex ((New-Object Net.WebClient -Property @{Proxy = [Net.GlobalProxySelection]::GetEmptyWebProxy()}).DownloadString(`$Url))}" 'https://github/test.ps1'
推荐阅读
- python - 这条路径是什么意思 /**/*.jpg?
- apache-spark - 在 Kubernetes 上运行 Spark 示例失败
- flutter - 在颤振中使用有状态小部件的替代方法
- arkit - iPad Pro Lidar - 导出几何和纹理
- html - 在 html 中包含几个文本格式命令
- unicode - 所有 ZWJ 序列都有效吗?
- react-native - 为什么用razorpay确认upi支付后react Native App崩溃?
- java - 错误-> java.lang.ArrayIndexOutOfBoundsException:8
- c# - 如何在 DDD 中管理一些域“静态数据”
- artificial-intelligence - 如何在与其他特征相关的元数据列表上设计本体概念