cmd中如何查看Windows PowerShell中自定义的变量
cmd中可以查看Windows PowerShell中自动化变量:C:\Users\test>PowerShell(Get-Variable ShellId).value ShellId是自动化变量
Microsoft.PowerShell
cmd中如何才能查看Windows PowerShell中自定义的变量?
在PowerShell 中设置了自定义变量:
PS C:\Users\test> $tesst=100
cmd中查看Windows PowerShell中自定义变量:
C:\Users\test>PowerShell(Get-Variable tesst).value
Get-Variable : 找不到名为“tesst”的变量。
所在位置 行:1 字符: 14
+ (Get-Variable <<<<tesst).value
+ CategoryInfo : ObjectNotFound: (tesst:String) , I
temNotFoundException
+ FullyQualifiedErrorId : VariableNotFound,Microsoft.PowerShell.Commands.G
etVariableCommand
Get是不是要改成 Set
我也小白。 $tesst=100;(Get-Variable tesst).value 指南针 发表于 2019-12-5 17:43
$tesst=100;(Get-Variable tesst).value
谢谢,成功了
问一下,在PowerShell中,echo test|set p能把test赋值给变量p
在cmd中输入:
PowerShell echo test|set p
不能成功把test赋值给变量p
yjqd 发表于 2019-12-6 10:49
谢谢,成功了
问一下,在PowerShell中,echo test|set p能把test赋值给变量p
PowerShell "echo test|set p;(Get-Variable p).value" 指南针 发表于 2019-12-6 11:16
PowerShell "echo test|set p;(Get-Variable p).value"
PowerShell "echo test|set p;(Get-Variable p).value"
谢谢,成功了
我把命令写成下面的样子,结果也是test,好像也成功了,不知对不对
powershell echo test^|set p;(Get-Variable p).value yjqd 发表于 2019-12-6 11:41
PowerShell "echo test|set p;(Get-Variable p).value"
谢谢,成功了
都对,实际效果一样 指南针 发表于 2019-12-6 12:42
都对,实际效果一样
测试了下,在脚本中运行还是用引号的命令好些:
for /f %%a in ('PowerShell "echo test|set p;(Get-Variable p).value"') do (set d=%%a)
echo %d%
powershell echo test^|set p;(Get-Variable p).value在脚本中很麻烦,不好写命令
页:
[1]