$Using variable with Invoke-Command cmdlet
来源:互联网 发布:hive sql与sql区别 编辑:程序博客网 时间:2024/05/16 02:59
以前在PowerShell中我们使用远程命令Invoke-Command传递本地变量的时候往往都要在语句块里使用如下,Param() 添加本地变量参数传递。
Invoke-Command -ScriptBlock{Param($ComputerName)Get-Process -ComputerName $ComputerName -Name 'Notepad'}
但是在PowerShell 3.0中,我们就不需要这样了,它新增了一个新的远程变量就是$Using,它与Param不同的是,它会自动做变量匹配,而用Param方式则不会做自动匹配,它所做的是一个变量传递的过程。
它的使用语句如下:
$Using:<VariableName>
让我们看看如何使用,你只需要像以往一样在使用参数时,在固定参数位置以$Using:ComputerName 替换即可。
Invoke-Command -ScriptBlock{#Param($ComputerName)Get-Process -ComputerName $Using:ComputerName -Name 'Notepad'}
- $Using variable with Invoke-Command cmdlet
- Functions with Variable Argumet lists in C using va_list
- invoke-command 应用
- Invoke-Command in PowerShell
- Using Vim's paste mode with the system paste command
- UNIX / Linux: Set your PATH Variable Using set or export Command
- Delphi2005学习笔记2——Using Platform Invoke with Delphi 2005
- PowerShell入门 - 2 (Using the New-Item Cmdlet)
- rails yaml with expression or variable (Using ERB in YAML Configuration File)
- invoke fabic with python
- Invoke methods using System.Reflection
- Using the patch command
- Using the ps command
- Using Sencha Command
- 无法将“Invoke-SqlCmd”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。
- (2) PowerShell Web Access: Configuring PowerShell Web Access Getway by using cmdlet
- Invoke a workflow using Siebel server script
- Java Invoke C and C++ Using JNI
- <<C语言深度剖析>>学习笔记之一:C语言中32个关键字
- 我了个去,在建行网站里面发现一个小问题
- 九度OJ 1055 数组逆置
- 490 - Rotating Sentences
- ListView 的Item 点击后改变背景的bug问题
- $Using variable with Invoke-Command cmdlet
- android中判断service是否正在运行
- public static void main(String[] args)
- 1.1_30天自制操作系统笔记_第一天_引导扇区
- 对View组件布局和绘制过程, 以及Drawable绘制的理解
- listView Item 焦点问题
- android viewpager左右滑动的Demo
- Poj 2528 Mayor's posters
- 开源项目-空间数据搜索引擎客户端(GenetworkClient)