@cyysu
2017-10-23T12:25:03.000000Z
字数 3121
阅读 909
- 时间:2017年10月23日
- 作者:Kali
- 邮箱:cyysu.github.io@gmail.com/2869905223@qq.com/微信lwyx1413
- 版本:4.0
- 描述:我们这里的安装平台采用Linux,如果是windows平台可能都需要你来安装。
powershell系列教程
# 第一种方法 加入APT源,然后apt安装curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.listsudo apt-get updatesudo apt-get install -y powershell# 第二种方法 下载powershell deb包进行安装,这里推荐采用这个方式大家到下面那这个网址自己去下载,然后按照deb包安装方式进行安装。
https://github.com/PowerShell/PowerShell/tree/master
# 这里建议大家执行的时候在英文路径下,目前这个对中文支持还不是很好。mj@DZ:~/powershell$ powershellPowerShell v6.0.0-beta.8Copyright (C) Microsoft Corporation. All rights reserved.PS /home/mj/powershell>PS /home/mj/powershell> dirPS /home/mj/powershell> touch 123.txtPS /home/mj/powershell> dirDirectory: /home/mj/powershellMode LastWriteTime Length Name---- ------------- ------ ---------- 17/10/23 下午8:02 0 123.txtPS /home/mj/powershell># 清除命令可以使用Linux下的clear或者windows下的cls# 获取时间命令PS /home/mj/powershell> Get-Date2017年10月23日星期一 下午8:03:47# 获取系统开机时间PS /home/mj/powershell> Get-UptimeDays : 1Hours : 16Minutes : 55Seconds : 9Milliseconds : 0Ticks : 1473090000000TotalDays : 1.70496527777778TotalHours : 40.9191666666667TotalMinutes : 2455.15TotalSeconds : 147309TotalMilliseconds : 147309000# 获取当前目录的两种方式PS /home/mj/powershell> pwdPath----/home/mj/powershellPS /home/mj/powershell> Get-LocationPath----/home/mj/powershell# 常见的创建删除命令啥的我推荐用Linux上的,毕竟我们很熟悉Linux上命令了。rm rmdir mkdir touch cat ls cp 等等# 如果想查看某个命令的使用信息如:cpio --help# 显示系统中所有的进程。PS /home/mj/powershell> Get-ProcessNPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName------ ----- ----- ------ -- -- -----------0 0.00 2.04 0.00 2138 126 (sd-pam)0 0.00 2.05 0.00 2745 743 (sd-pam)0 0.00 7.66 2.73 1068 068 accounts-daemon0 0.00 0.00 0.00 98 0 acpi_thermal_pm# 如果我们想查看某一进程的详细信息PS /home/mj/powershell> Get-Process systemdNPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName------ ----- ----- ------ -- -- -----------0 0.00 5.77 6.26 1 1 systemd0 0.00 4.74 0.06 2126 126 systemd0 0.00 4.83 0.05 2743 743 systemd# 显示命令的帮助PS /home/mj/powershell> Get-Help clearNAMEClear-HostSYNOPSISClears the display in the host program.SYNTAXClear-Host [<CommonParameters>]DESCRIPTIONThe Clear-Host function removes all text from the current display, including commands and output that might have accumulated. When complete, it displays the command prompt. You can use the function name or its alias, CLS.Clear-Host affects only the current display. It does not delete saved results or remove any items from the session. Session-specific items, such as variables and functions, are not affected by this function.Because the behavior of the Clear-Host function is determined by the host program, Clear-Host might work differently in different host programs.# 查看所有命令PS /home/mj/powershell> Get-CommandCommandType Name Version Source----------- ---- ------- ------Function Add-NodeKeys 0.0 PSDesiredStateConfigurationFunction AddDscResourceProperty 0.0 PSDesiredStateConfigurationFunction AddDscResourcePropertyFromMetadata 0.0 PSDesiredStateConfiguration# 显示命令设置的别名PS /home/mj/powershell> Get-AliasCommandType Name Version Source----------- ---- ------- ------Alias ? -> Where-ObjectAlias % -> ForEach-Object# 给命令设置别名PS /home/mj/powershell> Set-Aliascmdlet Set-Alias at command pipeline position 1Supply values for the following parameters:Name:
支付宝 微信