欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Windows Powershell 通過(guò)函數(shù)擴(kuò)展別名

 更新時(shí)間:2014年09月02日 16:35:28   投稿:hebedich  
這篇文章主要介紹了Windows Powershell 通過(guò)函數(shù)擴(kuò)展別名,需要的朋友可以參考下

在Powershell中設(shè)置別名的確方便快捷,但是在設(shè)置別名的過(guò)程中并設(shè)置參數(shù)的相關(guān)信息。盡管別名會(huì)自動(dòng)識(shí)別參數(shù),但是如何把經(jīng)常使用的參數(shù)默認(rèn)設(shè)定在別名里面呢?例如Test-Connection -Count 2 -ComputerName,讓-”-Count 2″ 固化在別名中。

這時(shí)簡(jiǎn)單的別名無(wú)法完成上述需求,可以通過(guò)函數(shù)來(lái)完成它,并且一旦把函數(shù)拉過(guò)來(lái),定義別名會(huì)變得更加靈活。

PS C:\PS> function test-conn { Test-Connection -Count 2 -ComputerName $args}
PS C:\PS> Set-Alias tc test-conn
PS C:\PS> tc localhost

Source    Destination   IPV4Address   IPV6Address               Bytes  Time(ms)
------    -----------   -----------   -----------               -----  --------
test-me-01  localhost    127.0.0.1    ::1                   32    0
test-me-01  localhost    127.0.0.1    ::1                   32    0

有了函數(shù)牽線,別名可以完成更高級(jí)更強(qiáng)大的功能,其中$args為參數(shù)的占位符,經(jīng)測(cè)試,發(fā)現(xiàn)這個(gè)占位符必須以$args命名,否則不能識(shí)別,會(huì)拋出異常:
Cannot validate argument on parameter ‘ComputerName'. The argument is null or empty. Supply an arg
nt that is not null or empty and then try the command again.

相關(guān)文章

  • Windows Powershell條件表達(dá)式之條件操作符

    Windows Powershell條件表達(dá)式之條件操作符

    條件表達(dá)式返回的結(jié)果是$true和$false,在條件表達(dá)式中可以包含屬性引用和方法調(diào)用
    2014-10-10
  • Windows Azure VM上配置FTP服務(wù)器

    Windows Azure VM上配置FTP服務(wù)器

    這篇文章主要介紹了Windows Azure VM上配置FTP服務(wù)器,需要的朋友可以參考下
    2014-09-09
  • PowerShell查看Windows功能選項(xiàng)的方法

    PowerShell查看Windows功能選項(xiàng)的方法

    這篇文章主要介紹了PowerShell查看Windows功能選項(xiàng),也就就是在PowerShell中獲取Windows功能里的選項(xiàng)設(shè)置,需要的朋友可以參考下
    2014-11-11
  • PowerShell是什么?

    PowerShell是什么?

    這篇文章主要介紹了PowerShell是什么?本文解讀了PowerShell的一些術(shù)語(yǔ),對(duì)PowerShell做了一個(gè)完全介紹,需要的朋友可以參考下
    2014-08-08
  • PowerShell查詢和刪除打印任務(wù)操作代碼實(shí)例

    PowerShell查詢和刪除打印任務(wù)操作代碼實(shí)例

    這篇文章主要介紹了PowerShell查詢和刪除打印任務(wù)操作代碼實(shí)例,本文直接給出代碼實(shí)例,需要的朋友可以參考下
    2015-03-03
  • PowerShell 讀取性能計(jì)數(shù)器二進(jìn)制文件(.blg)記錄并匯總計(jì)算

    PowerShell 讀取性能計(jì)數(shù)器二進(jìn)制文件(.blg)記錄并匯總計(jì)算

    由于監(jiān)控及報(bào)告需要,要統(tǒng)計(jì)性能計(jì)數(shù)器每天數(shù)值情況,確認(rèn)數(shù)據(jù)庫(kù)服務(wù)器的運(yùn)行狀況。若打開(kāi)計(jì)數(shù)器填寫(xiě),比較麻煩,現(xiàn)在統(tǒng)計(jì)用 powershell 來(lái)讀取計(jì)數(shù)器的值
    2016-11-11
  • PowerShell入門教程之Cmd命令與PowerShell命令相互調(diào)用的方法

    PowerShell入門教程之Cmd命令與PowerShell命令相互調(diào)用的方法

    這篇文章主要介紹了PowerShell入門教程之Cmd命令與PowerShell命令相互調(diào)用的方法,本文講解了在Cmd命令中調(diào)用PowerShell命令、在PowerShell命令中調(diào)用Cmd命令的方法,需要的朋友可以參考下
    2014-10-10
  • PowerShell管理Win Server 2008 R2

    PowerShell管理Win Server 2008 R2

    在Windows Serve 2008 R2中,一個(gè)重要改進(jìn)就是PowerShell版本升級(jí)為2.0。Win 2008 R2包括一系列新的服務(wù)器管理界面,這些均建立在PowerShell 2.0之上。它新增了240個(gè)cmdlets命令集,新的PowerShell圖形用戶界面也增添了開(kāi)發(fā)功能,從而用戶能更簡(jiǎn)單創(chuàng)建自己的命令行。
    2015-09-09
  • PowerShell小技巧之觀察UNC路徑

    PowerShell小技巧之觀察UNC路徑

    UNC(Universal Naming Convention)通用命名規(guī)則,也稱通用命名規(guī)范、通用命名約定。UNC路徑就是類似\\softer這樣的形式的網(wǎng)絡(luò)路徑。
    2014-09-09
  • Powershell 查詢 Windows 日志的方法

    Powershell 查詢 Windows 日志的方法

    這篇文章主要介紹了Powershell 查詢 Windows 日志的方法,需要的朋友可以參考下
    2015-10-10

最新評(píng)論