读Getting Started With Windows PowerShell笔记
生活随笔
收集整理的這篇文章主要介紹了
读Getting Started With Windows PowerShell笔记
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
使用中Powershell的操作跟Linux中的終端操作很多地方是一致的,當(dāng)然,還是有著Windows自己的特色,比如,不分大小寫。之前命令行中的命令大部分在這里也可以用,而且用法一樣。 選中后點(diǎn)右鍵,即復(fù)制到剪切板。 不分大小寫,以下的幾個(gè)都是一樣的命令:Get-Aliasget-aliasgeT-ALIaS輸命令時(shí)可以用Tab鍵補(bǔ)全。 可以加管道控制符,以及加more分屏輸出:PS C:\Windows\system32> get-alias | moreCommandType Name ModuleName----------- ---- ----------Alias % -> ForEach-ObjectAlias ? -> Where-ObjectAlias ac -> Add-ContentAlias asnp -> Add-PSSnapinAlias cat -> Get-ContentAlias cd -> Set-LocationAlias chdir -> Set-LocationAlias clc -> Clear-ContentAlias clear -> Clear-HostAlias clhy -> Clear-HistoryAlias cli -> Clear-ItemAlias clp -> Clear-ItemPropertyAlias cls -> Clear-HostAlias clv -> Clear-VariableAlias cnsn -> Connect-PSSessionAlias compare -> Compare-ObjectAlias copy -> Copy-ItemAlias cp -> Copy-ItemAlias cpi -> Copy-ItemAlias cpp -> Copy-ItemPropertyAlias cvpa -> Convert-PathAlias dbp -> Disable-PSBreakpointAlias del -> Remove-ItemAlias diff -> Compare-ObjectAlias dir -> Get-ChildItemAlias dnsn -> Disconnect-PSSessionAlias ebp -> Enable-PSBreakpointAlias echo -> Write-OutputAlias epal -> Export-AliasAlias epcsv -> Export-CsvAlias epsn -> Export-PSSessionAlias erase -> Remove-ItemAlias etsn -> Enter-PSSessionAlias exsn -> Exit-PSSessionAlias fc -> Format-CustomAlias fl -> Format-ListAlias foreach -> ForEach-ObjectAlias ft -> Format-TableAlias fw -> Format-WideAlias gal -> Get-AliasAlias gbp -> Get-PSBreakpointAlias gc -> Get-ContentAlias gci -> Get-ChildItemAlias gcm -> Get-CommandAlias gcs -> Get-PSCallStackAlias gdr -> Get-PSDrive-- More --同樣的是回車往下一行,空格往下一屏。Ctrl+c,中止執(zhí)行。 Alias也是給這些cmdlet起個(gè)別名,或者,叫昵稱?比如下面的三個(gè),都是完全一樣的結(jié)果,倒是更方便了。PS C:\Windows\system32> d:PS D:\> dir目錄: D:\Mode LastWriteTime Length Name---- ------------- ------ ----da--- 2007/4/17 10:43 Dynamips@EDURainbowd---- 2012/12/1 10:22 My Documentsd---- 2012/11/7 10:38 NeoSpeechd---- 2012/11/10 9:17 Program Filesd---- 2012/11/29 21:58 Program Files (x86)PS D:\> ls目錄: D:\Mode LastWriteTime Length Name---- ------------- ------ ----da--- 2007/4/17 10:43 Dynamips@EDURainbowd---- 2012/12/1 10:22 My Documentsd---- 2012/11/7 10:38 NeoSpeechd---- 2012/11/10 9:17 Program Filesd---- 2012/11/29 21:58 Program Files (x86)PS D:\> get-childitem目錄: D:\Mode LastWriteTime Length Name---- ------------- ------ ----da--- 2007/4/17 10:43 Dynamips@EDURainbowd---- 2012/12/1 10:22 My Documentsd---- 2012/11/7 10:38 NeoSpeechd---- 2012/11/10 9:17 Program Filesd---- 2012/11/29 21:58 Program Files (x86)也可以加其他參數(shù),參數(shù)可以只輸前幾個(gè)字母,只要沒(méi)有其他的參數(shù)的跟這些字母重復(fù),造成不知道是哪個(gè):PS C:\Users\Denny> get-childitem -recurse | more目錄: C:\Users\DennyMode LastWriteTime Length Name---- ------------- ------ ----d---- 2012/11/8 15:52 .sdtguid-r-- 2012/11/5 21:35 Contactsd-r-- 2012/12/5 9:11 Desktopd-r-- 2012/11/15 16:51 Documentsd-r-- 2012/12/4 21:30 Downloadsd-r-- 2012/11/5 21:35 Favoritesd-r-- 2012/11/5 21:35 Linksd-r-- 2012/11/5 21:35 Musicd-r-- 2012/11/14 8:52 Picturesd-r-- 2012/11/5 21:35 Saved Gamesd-r-- 2012/11/6 9:30 Searchesd-r-- 2012/11/5 21:35 Videos-a--- 2012/11/23 9:16 11216 dlclient.history-a--- 2012/11/23 9:16 167 dlclient.localstate-a--- 2012/11/23 9:16 732 dlgmanager.config-a--- 2012/11/8 15:52 100 sapinstAuth.txt目錄: C:\Users\Denny\.sdtguiMode LastWriteTime Length Name---- ------------- ------ ----d---- 2012/11/8 15:52 downloadd---- 2012/11/8 15:52 historyd---- 2012/11/8 15:52 htdocd---- 2012/11/8 15:52 log-a--- 2012/11/8 15:52 1187 .sdt_keystore_nw2007目錄: C:\Users\Denny\.sdtgui\logMode LastWriteTime Length Name---- ------------- ------ -----a--- 2012/11/8 15:52 480 FileService.log-a--- 2012/11/8 15:52 42 frog.log-a--- 2012/11/8 15:52 484 NotesService.log-a--- 2012/11/8 15:52 836 SAPinstService.log-a--- 2012/11/8 15:52 3829 sdtgui.log-a--- 2012/11/8 15:52 0 sdtgui.out-a--- 2012/11/8 15:52 0 sdtgui.trc-- More -- 列出下面所有子文件夾的文件。 輸出命令信息:PS C:\Users\Denny> get-command | moreCommandType Name ModuleName----------- ---- ----------Alias Add-ProvisionedAppxPackage DismAlias Apply-WindowsUnattend DismAlias Get-ProvisionedAppxPackage DismAlias Initialize-Volume StorageAlias Remove-ProvisionedAppxPackage DismFunction A:Function Add-BCDataCacheExtension BranchCacheFunction Add-BitLockerKeyProtector BitLockerFunction Add-DnsClientNrptRule DnsClientFunction Add-DtcClusterTMMapping MsDtcFunction Add-InitiatorIdToMaskingSet StorageFunction Add-NetIPHttpsCertBinding NetworkTransitionFunction Add-NetLbfoTeamMember NetLbfoFunction Add-NetLbfoTeamNic NetLbfoFunction Add-NetSwitchTeamMember NetSwitchTeamFunction Add-OdbcDsn WdacFunction Add-PartitionAccessPath StorageFunction Add-PhysicalDisk StorageFunction Add-Printer PrintManagementFunction Add-PrinterDriver PrintManagementFunction Add-PrinterPort PrintManagement以格式控制列出:PS C:\Users\Denny> Get-Command | Format-List | moreDisplayName : Add-ProvisionedAppxPackageCommandType : AliasDefinition :ReferencedCommand :ResolvedCommand :DisplayName : Apply-WindowsUnattendCommandType : AliasDefinition :ReferencedCommand :ResolvedCommand :DisplayName : Get-ProvisionedAppxPackageCommandType : AliasDefinition :ReferencedCommand :ResolvedCommand :DisplayName : Initialize-VolumeCommandType : AliasDefinition :ReferencedCommand :ResolvedCommand :DisplayName : Remove-ProvisionedAppxPackageCommandType : AliasDefinition :ReferencedCommand :ResolvedCommand :幫助信息:PS C:\Users\Denny> get-help format-list名稱Format-List語(yǔ)法Format-List [[-Property] <Object[]>] [-GroupBy <Object>] [-View <string>] [-ShowError] [-DisplayError] [-Force] [-Expand <string> {CoreOnly | EnumOnly | Both}] [-InputObject <psobject>] [<CommonParameters>]別名fl備注Get-Help 在此計(jì)算機(jī)上找不到該 cmdlet 的幫助文件。它僅顯示部分幫助。-- 若要下載并安裝包含此 cmdlet 的模塊的幫助文件,請(qǐng)使用 Update-Help。-- 若要聯(lián)機(jī)查看此 cmdlet 的幫助主題,請(qǐng)鍵入: "Get-Help Format-List -Online" 或轉(zhuǎn)到 http://go.microsoft.com/fwlink/?LinkID=113302。其中下面的那個(gè)鏈接則是直接到format-list的幫助信息的。 安裝本地幫助:PS C:\Users\Denny> update-help 提示需要以管理員身份運(yùn)行才能更新這些幫助信息: 還有報(bào)錯(cuò),不過(guò)只是一小部分,暫時(shí)用不上: 終于出來(lái)了:PS C:\Windows\system32> get-help format-list名稱Format-List摘要Formats the output as a list of properties in which each property appears on a new line.語(yǔ)法Format-List [[-Property] <Object[]>] [-DisplayError [<SwitchParameter>]] [-Expand <String>] [-Force [<SwitchParameter>]] [-GroupBy <Object>] [-InputObject <PSObject>] [-ShowError [<SwitchParameter>]] [-View <String>] [<CommonParameters>]說(shuō)明The Format-List cmdlet formats the output of a command as a list of properties in which each property is displayedon a separate line. You can use Format-List to format and display all or selected properties of an object as a list(format-list *).Because more space is available for each item in a list than in a table, Windows PowerShell displays more properties of the object in the list, and the property values are less likely to be truncated.相關(guān)鏈接Online Version: http://go.microsoft.com/fwlink/?LinkID=113302備注若要查看示例,請(qǐng)鍵入: "get-help Format-List -examples".有關(guān)詳細(xì)信息,請(qǐng)鍵入: "get-help Format-List -detailed".若要獲取技術(shù)信息,請(qǐng)鍵入: "get-help Format-List -full".有關(guān)在線幫助,請(qǐng)鍵入: "get-help Format-List -online"加參數(shù)的命令,得到使用的例子:PS C:\Users\Denny> Get-Help Format-List -Examples名稱Format-List摘要Formats the output as a list of properties in which each property appears on a new line.-------------------------- EXAMPLE 1 --------------------------PS C:\> get-service | format-listThis command formats information about services on the computer as a list. By default, the services are formatted as a table. The Get-Service cmdlet gets objects representing the services on the computer. The pipeline operator (|)passes the results through the pipeline to Format-List. Then, the Format-List command formats the service information in a list and sends it to the default output cmdlet for display.-------------------------- EXAMPLE 2 --------------------------PS C:\> $a = get-childitem $pshome\*.ps1xmlPS C:\>format-list -InputObject $aThese commands display information about the PS1XML files in the Windows PowerShell directory as a list.The first command gets the objects representing the files and stores them in the $a variable.The second command uses Format-List to format information about objects stored in $a. This command uses the InputObject parameter to pass the variable to Format-List, which then sends the formatted output to the default output cmdlet for display.-------------------------- EXAMPLE 3 --------------------------PS C:\> get-process | format-list -property name, basepriority, priorityclassThis command displays the name, base priority, and priority class of each process on the computer. It uses the Get-Process cmdlet to get an object representing each process. The pipeline operator (|) passes the process objects through the pipeline to Format-List. Format-List formats the processes as a list of the specified properties. The "Property" parameter name is optional, so you can omit it.-------------------------- EXAMPLE 4 --------------------------PS C:\> get-process winlogon | format-list -property *This command displays all of the properties of the Winlogon process. It uses the Get-Process cmdlet to get an object representing the Winlogon process. The pipeline operator (|) passes the Winlogon process object through the pipeline to Format-List. The command uses the Property parameter to specify the properties and the * to indicate all properties. Because the name of the Property parameter is optional, you can omit it and type the command as: "format-list *". Format-List automatically sends the results to the default output cmdlet for display.
轉(zhuǎn)載于:https://blog.51cto.com/lightguide/1078859
總結(jié)
以上是生活随笔為你收集整理的读Getting Started With Windows PowerShell笔记的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 【OpenCV学习】OpenMP并行化实
- 下一篇: windows server 2012