什么是Microsoft Powershell? 如何自动执行任务?
PowerShell is a task automation and configuration management provided by Microsoft for Windows Operating systems. Powershell provides interactive shell for issuing commands. Powershell platform also provides scripting language.
PowerShell是Microsoft为Windows操作系统提供的任务自动化和配置管理。 Powershell提供了用于发布命令的交互式外壳。 Powershell平台还提供脚本语言。
Powershell have access to the underlying operating system components like COM
, WMI
WS-Management
etc. Powershell is developed in .Net framework.
Powershell可以访问诸如COM
, WMI
WS-Management
等底层操作系统组件。Powershell是在.Net框架中开发的。
版本号 (Versions)
Powershell started developing in 2003 but it takes some time to release first version.
Powershell于2003年开始开发,但是发布第一版需要一些时间。
PowerShell 1.0 (PowerShell 1.0)
First version released in 2006 and supported operating systems are
2006年发布的第一个版本和受支持的操作系统是
- Windows XP SP2,Windows XP SP2,
- Windows Server 2003 SP1, Windows Server 2003 SP1,
- Windows Vista Windows Vista
Powershell 2.0 (Powershell 2.0)
Powershell 2.0 is integrated with Windows 7 and Windows Server 2008 R2 . The following new features are added to the v2
Powershell 2.0与Windows 7和Windows Server 2008 R2集成在一起。 v2中添加了以下新功能
-
Powershell Remoting
will enabled scripts and cmdlets to run remote systemsPowershell Remoting
将使脚本和cmdlet能够运行远程系统 -
Background Jobs
allow run scripts asynchronouslyBackground Jobs
允许异步运行脚本 -
Transactions
will added and can be used for write operations like registryTransactions
将被添加,并可用于注册表之类的写操作 -
Modules
are used to organize scripts and script files in a name space manner.Modules
用于以命名空间的方式组织脚本和脚本文件。 -
Script Debugging
is used to trouble shot scripts while runningScript Debugging
用于在运行时对拍摄的脚本进行故障排除 -
Eventing
is an other useful feature used to listening, forwarding management and system eventsEventing
是另一个有用的功能,用于侦听,转发管理和系统事件 -
Integrate Scripting Environment
is a tool used to write, run and debug Powershell scripts.Integrate Scripting Environment
是用于编写,运行和调试Powershell脚本的工具。 -
Network File transfer
can transfer files to remote systems.Network File transfer
可以将文件传输到远程系统。
Powershell 3.0 (Powershell 3.0)
Powershell version 3 is integrated to the Windows 8 and Windows Server 2012 and following features are added
Powershell版本3已集成到Windows 8和Windows Server 2012中,并添加了以下功能
-
Scheduled Jobs
is very useful feature added in this versionScheduled Jobs
是此版本中添加的非常有用的功能 -
Code Completion
is used to auto complete or suggest commandsCode Completion
用于自动完成或建议命令
Powershell 4.0(Powershell 4.0)
Version 4.0 comes with Windows 8.1 and Windows Server 2012 R2
Windows 8.1和Windows Server 2012 R2随附版本4.0
-
Desired State Configuration
allow to specify end configuration of a serviceDesired State Configuration
允许指定服务的最终配置 -
Where
andForEach
keywords for loopsWhere
和ForEach
循环关键字
Powershell 5.0 (Powershell 5.0)
Version 5 have following features
版本5具有以下功能
-
Class Definition
will enable more complex data structure creationClass Definition
将使创建更复杂的数据结构成为可能 -
Enumeration
is used to foreach in array like structuresEnumeration
用于在类似数组的结构中进行传授
Cmdlet(Cmdlet)
Cmdlet or commandlets are specialized commands to implements specific functions. Cmdlet uses Verb-Noun pattern for naming. For example Get-ChildItem
express cmdlet function with verb Get
and noun ChildItem
.
Cmdlet或Commandlet是用于实现特定功能的专用命令。 Cmdlet使用动词名词模式进行命名。 例如, Get-ChildItem
使用动词Get
和名词ChildItem
表达cmdlet函数。
集成Shell环境ISE (Integrate Shell Environment ISE)
ISE is simple tool provided by Powershell to develop, run, debug Powershell scripts. It provides existing cmdlets help and auto completion to easy Powershell development job.
ISE是Powershell提供的用于开发,运行,调试Powershell脚本的简单工具。 它提供现有的cmdlet帮助和自动完成功能,以简化Powershell开发工作。
翻译自: https://www.poftut.com/microsoft-powershell-can-automate-tasks/