PowerShell(0)-Windows PowerShell交互界面
我们将实验Windows PowerShell的功能,这是一系列的实验。
可参阅《Windows PowerShell应用手册》,机械工业出版社 Lee Holmes著,赵松德 王英群译。
PowerShell笔记 19:02 2011-4-18
1、PS支持常规的Windows命令行:ipconfig notepad……
2、PS命令行可通过Tab键补全: get-pr<tab> -N<tab> lsass
3、PS支持通配符参数:gps l*s
4、PS支持直接调用.Net Framework 类库
PS C:\> [System.Console]::WriteLine("{0},{1}",5%2.2,5/2)
0.6,2.5
PS C:\> [DateTime]::Now
2011年4月18日 19:09:54
PS C:\> calc
PS C:\> $process = Get-Process calc
PS C:\> $process.kill()
5、可组合的命令:
PS C:\> Get-Process |
>> Where-Object { $_.Handles -ge 500 } |
>> Sort-Object Handles |
>> Format-Table Handles, Name, Description -Auto
>>
Handles Name Description
------- ---- -----------
531 explorer Windows Explorer
564 csrss
967 powershell PowerShell.EXE
1076 System
1568 svchost Generic Host Process for Win32 Services
6、若要查找与给定的通配符匹配的所有命令,用Get-Command名伶。
PS C:\> Get-Command *process*
CommandType Name Definition
----------- ---- ----------
Cmdlet Get-Process Get-Process [[-Name] <String[]>] [-Verbose] [-De...
Application qprocess.exe C:\WINDOWS\system32\qprocess.exe
Cmdlet Stop-Process Stop-Process [-Id] <Int32[]> [-PassThru] [-Verbo...
7、若要查找一个命令可以做什么,用 Get-Help 获得帮助
Get_Help Get-Process
8、无处不在的脚本:计算系统的句柄总数,分析网页
PS C:\> $count = 0
PS C:\> foreach($process in Get-Process) { $count += $process.Handles }
PS C:\> $count
10149
PS C:\> $webClient = New-Object System.Net.WebClient
PS C:\> $content = $webClient.DownloadString("http://www.google.com/")
PS C:\> $content.Substring(0,1000)
Exception calling "Substring" with "2" argument(s): "Index and length must refer to a location within the string.
Parameter name: length"
At line:1 char:19
+ $content.Substring( <<<< 0,1000)
PS C:\> $content
<HTML><frameset border='0' frameSpacing='0' rows='100%,0' frameBorder='0'>
<frame id ='frm123' name='frm123' src='http://219.146.13.122/main.do?param=ABaW1zaT00NjAwMzY3NjA2MDUwNDImdXJsPXd3dy5nb2
9nbGUuY29tLyYyPS0xOTM5OTIyMjcy&ref=1'><frame id ='frmOLD' name='frmOLD' src='http://118.213.88.152/tongji.html'></frame
set></HTML>
PS C:\>
PS C:\> sqlcmd -S .\sqlexpress -E
1> use northwind
2> go
Changed database context to 'Northwind'.
1> select top 1 firstname,lastname,title from employees
2> go
firstname lastname title
---------- -------------------- ------------------------------
Nancy Davolio Sales Representative
(1 rows affected)
9、PS管理WMI(Windows Management Instrumentation)
PS C:\> Get-WmiObject win32_bios
SMBIOSBIOSVersion : R0051V1
Manufacturer : Phoenix Technologies LTD
Name : Ver 1.00PARTTBLL
SerialNumber : 28240893-9003733
Version : Sony - 20051201
10、PS使用活动目录(Active Directory),注意WinNT的大小写
PS C:\> [ADsI] "WinNT://./AdministratOR" | Format-List *
…………
11、PS导航功能
PS C:\WINDOWS> Set-Location c:\
PS C:\> Get-ChildItem
……
PS C:\> Set-Location HKCU:\Software\Microsoft\Windows\
PS HKCU:\Software\Microsoft\Windows> Get-ChildItem
Hive: Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows
SKC VC Name Property
--- -- ---- --------
27 0 CurrentVersion {}
3 1 Shell {BagMRU Size}
4 1 ShellNoRoam {BagMRU Size}
PS HKCU:\Software\Microsoft\Windows> Set-Location cert:\CurrentUser\Root
PS cert:\CurrentUser\Root> Get-ChildItem
Directory: Microsoft.PowerShell.Security\Certificate::CurrentUser\Root
Thumbprint Subject
---------- -------
CDD4EEAE6000AC7F40C3802C171E30148030C072 CN=Microsoft Root Certificate Authority, DC=microsoft, DC=com
A43489159A520F0D93D032CCAF37E7FE20A8B419 CN=Microsoft Root Authority, OU=Microsoft Corporation, OU=Copyright (c) 19...
转载于:https://www.cnblogs.com/flaaash/archive/2011/04/18/2020170.html
PowerShell(0)-Windows PowerShell交互界面相关推荐
- Windows PowerShell:Windows PowerShell的简介、入门、使用方法之详细攻略
Windows PowerShell:Windows PowerShell的简介.入门.使用方法之详细攻略 目录 Windows PowerShell的简介 PowerShell VS Unix Sh ...
- 我的.Net Core 3.0 windows 桌面程序界面绘制 -- 从.net framework复制代码法
今天想用 .net core做个小程序.却意外的发现没有可视化编辑器!!!(重要的事情用三个感叹号) 虽然我搞了十多年的 .net 开发,但是我确实从来没有自己编辑过 Designer.cs 这个文件 ...
- Windows PowerShell™ 用户手册(zz)
Windows PowerShell™ 用户手册 Microsoft Corporation 发布日期:2006 年 9 月 摘要 Windows PowerShell™ 是专为系统管理员设计的新 W ...
- Windows PowerShell™ 用户手册
Windows PowerShell™ 用户手册 Microsoft Corporation 发布日期:2006 年 9 月 摘要 Windows PowerShell™ 是专为系统管理员设计的新 W ...
- 1. Windows Powershell初接触
1. Windows Powershell初接触 我们之中有些人是因为需要配置Exchange Server2007,才开始对Windows Powershell全新的学习.但是,我认为可以使用WMI ...
- win7禁用powershell_简述Windows 7中的Windows PowerShell功能
Win7之家( www.win7china.com):简述Windows 7中的Windows PowerShell功能 也许有人会问,这么多的Windows版本过去了,命令提示符怎么还是那样啊?以前 ...
- Windows PowerShell与命令提示符的比较
从Windows 7到Windows 10,Microsoft提供了Windows Command Prompt和Windows PowerShell选项.它们是两个命令行界面,可帮助用户直接与操作系 ...
- 《Windows PowerShell实战指南(第2版)》——1.4 搭建自己的实验环境
本节书摘来自异步社区<Windows PowerShell实战指南(第2版)>一书中的第1章,第1.4节,作者:[美]Don Jones(道·琼斯) , Jeffery Hicks(杰弗瑞 ...
- 易学易用的Windows PowerShell(转)
出处:http://www.cnblogs.com/shanyou/archive/2007/02/12/648204.html Windows PowerShell 是微软为 Windows 环境所 ...
最新文章
- mysql 设计表_mysql,表设计
- NLP - 15 分钟搭建中文文本分类模型
- levelDB数据库使用及实例 - 高性能nosql存储数据库
- You are what you say!
- Spring boot的@Conditional派生注解
- Nginx负载均衡的原理及流程分析
- (转)MySQL数据库的优化-运维架构师必会高薪技能,笔者近六年来一线城市工作实战经验...
- react实战课程_在使用React一年后,我学到的最重要的课程
- “年薪25万只是白菜价”已成过去式,AI 岗位年薪下降8.9%!
- you are not authorized to view this page
- 数据科学和人工智能技术笔记 一、向量、矩阵和数组
- IIS 500 错误解决
- java领域模型设计实例_Java 开发架构篇:DDD 模型领域层决策规则树服务设计
- logback日志回顾整理--2018年8月8日
- 2022年五一建模比赛A题#五一建模
- 项目配置管理工具研究
- android gms测试,谷歌GMS认证需要测试哪些项目?
- Apple Developer苹果签名工具
- python网络编程原理_图解Python网络编程
- linux非连续内存,(转)linux高端内存管理之非连续内存区(分配和释放)