PowerShell 3.0 实践(一)Windows 8 中的 PowerShell 3.0

Windows 8 惊艳登场,当Metro界面吸引了无数人的眼球时,其实还有很多特性值得关注,如PowerShell 3.0、Hyper-V 3.0、vhdx、IIS 8等。

PowerShell 2.0实践系列从本次开始全面转向3.0,体验一下PowerShell 3.0带来的管理方案提升。

很庆幸PowerGUI Script Editor 可以在Windows 8下安装:官方下载

PowerShell 3.0 实践(一)Windows 8 中的 PowerShell 3.0_第1张图片

本系列全部脚本在Windows 8 x64(PowerShell 3.0) + PowerGUI Script Editor 3.0 Free Edition x64 上测试通过

 

一、PowerShell 3.0概述

如同PowerShell 2.0内置于Windows 7和 Windows Server 2008 R2,在Build大会上发布的Windows 8 Developer Preview 和 Windows Server 8 Developer Preview也内置了PowerShell 3.0。我安装的Windows 8 Developer Preview x64,快捷键Win + R 打开运行,输入powershell即可打开PowerShell 3.0的命令行:

PowerShell 3.0 实践(一)Windows 8 中的 PowerShell 3.0_第2张图片

虽然标题栏还是1.0,但是通过全局变量 $host 可以查看具体版本信息:

PowerShell 3.0 实践(一)Windows 8 中的 PowerShell 3.0_第3张图片

 

未安装 Windows 8 的朋友也不必扫兴,微软已经放出了PowerShell 3.0 CTP1的下载,在这里下载:

需要注意的是操作系统必须为Windows 7 SP1 或 Windows Server 2008 R2 SP1,且需要.NET Framework 4.0。

PowerShell 3.0 实践(一)Windows 8 中的 PowerShell 3.0_第4张图片

 

PowerShell 3.0 只是 WMF(Windows Management Framework 3.0,Windows 管理框架)的一部分,WMF 3.0的新特性有:

英文原文

1、PowerShell 3.0

支持 Workflows - 让你可以在命令行就可以操作 Windows Workflow Foundation

更稳定的 Session - 让你的 Session 可以更加适应不稳定的网络、突然停机的系统、随时重新连接

计划任务 - 让你从命令行就可以创建、管理 Windows 计划任务

权限托管 - 让受限的用户可以在特定情况下执行更高权限的脚本

更简化的语法 - 让脚本看起来更像程序或者更像自然语言

Cmdlet 发掘 - 改进的自动模块加载可以让你更容易发掘系统中的各种 Cmdlet

PowerShell ISE插件- 更容易编写脚本命令

 

2、WMI(Windows Management InstrumentationWindows管理规范)

         新的开发模型提供者 - 新的开发模型降低了管理成本,移除了对COM的依赖

         新的管理客户端API – 提供标准的公共信息模型(CIM = Common Information Model)操作,允许在Windows上管理*ninx等非Windows操作系统

 

附注:

公共信息模型CIM,是一个与具体实现无关的、用于描述管理信息的概念性模型。CIM分为两部分:CIM 规范(CIM Specification)和CIM 模式(CIM Schema)。CIM 规范提供了模型的正式定义,它描述了语言、命名、元模式和到其他管理模型(如SNMP MIB)的映射技术;CIM 模式则给出了实际模型的描述。CIM 模型由核心模型、公共模型和扩展模型三层构成。核心模型是一系列类、连接和属性的集合,该对象组提供了所有管理域通用的基本信息模型;公共模型提供特定管理域的通用信息模型,这些特定的管理域,如系统、应用程序、网络和设备等;扩展模型代表通用模型的特定技术扩展。

通过CIM 建模,能够得到管理域中实体的抽象和表示,包括它们的属性、操作和关系。这样的模型独立于任何具体的数据库、应用、协议以及平台。因此,CIM 模型要求不同开发商所提供的基于不同平台的应用都采用一种标准的格式来描述管理数据,以使数据能够在多种应用间共享。CIM 采用面向对象的方式构建了一种新的适用于管理系统、网络的结构和概念模型。CIM 建模是一种通用方法。特定管理域的CIM 建模是在核心模型和公共模型的基础上进行扩展。

总的来说公共信息模型(CIM)是一个标准,定义了一个前后一致的模型,依据这个模型,网络设备、系统和应用程序能显示有关它们自己的信息,并使这些信息能被管理工具利用CIM能描述诸如桌面软件和硬件配置、CPU 封装块的序列号以及某个特殊路由器端口上的流量水平等信息。

也许CIM有别于以前标准的最重要之处是其表示组成计算机系统或公司网络的不同单元和部件之间关系的能力。DIF主席、Novell的公司设计师Winston Bumpus 称,利用CIM"你能看到这台计算机是否与这个应用 程序连在一起,它是在运行从这台服务器上送出的服务。"他还说,通过跟踪路径和检查一路上每个部件的状态,管理工具就能" 回答我为什么不能送出电子邮件这样的问题了。"

CIMOM 公共信息模型对象管理器(Common Information Model Object Manager)

是一个描述操作系统构成单元的对象数据库,为MMC和脚本程序提供了一个访问操作系统构成单元的公共接口。

 

3、WinRM(Windows Remote Management,Windows 远程管理)

更稳定的连接 - 更加适应不稳定的网络、突然停机的系统、随时重新连接

更弹性的连接 - 当连接中断后,可以迅速重新连接

 

4、PowerShell Web服务

支持REST形式的Web服务使用开放式数据协议(Open Data Protocol ,OData)远程执行PowerShell脚本,支持Windows和非Windows客户端。

 

二、Windows Server 8中的PowerShell 3.0新模块

ADDeploymentWF

AppLocker

Appx

BestPractices

BitsTransfer

BranchCache

CimCmdlets

ClusterAwareUpdating

DirectAccessClientComponents

Dism

DnsClient

DnsConfig

DnsLookup

DnsNrpt

FailoverClusters

 

FileServer

iSCSI

KdsCmdlets

Microsoft.PowerShell.Core

Microsoft.PowerShell.Diagnostics

Microsoft.PowerShell.Host

Microsoft.PowerShell.Management

Microsoft.PowerShell.Security

Microsoft.PowerShell.Utility

Microsoft.WSMan.Management

MicrosoftiSCSITarget

MsDtc

NetAdapter

NetLbfo

NetQos

NetSwitchTeam

NetTCPIP

netwnv

NetworkConnectivityStatus

NetworkSecurity

NetworkTransition

PKIClient

PrintManagement

PS_MMAgent

PSDiagnostics

PSScheduledJob

PSWorkflow

RDManagement

ScheduledTasks

SecureBoot

ServerManager

ServerManagerShell

SmbShare

SmbWitness

Storage

TelemetryManagement

TroubleshootingPack

TrustedPlatformModule

UserAccessLogging

Wdac

Whea

 

三、Windows 8 Developer Preview中的PowerShell 3.0的命令与别名

ac

asnp

clc

cli

clp

clv

compare

cpi

cpp

cvpa

dbp

diff

ebp

epal

epcsv

fc

fl

foreach

%

ft

fw

gal

gbp

gc

gci

gcm

gdr

gcs

ghy

gi

gl

gm

gmo

gp

gps

group

gsv

gsnp

gu

gv

gwmi

iex

ihy

ii

ipmo

iwmi

ipal

ipcsv

measure

mi

mp

nal

ndr

ni

nv

nmo

oh

ogv

ise

rbp

rdr

ri

rni

rnp

rp

rmo

rsnp

rv

rwmi

rvpa

sal

sasv

sbp

sc

select

si

sl

swmi

sleep

sort

sp

saps

start

spps

spsv

sv

tee

where

?

write

rcsn

cnsn

dnsn

irm

iwr

cat

cd

clear

cp

h

history

kill

lp

ls

man

mount

md

mv

popd

ps

pushd

pwd

r

rm

rmdir

echo

cls

chdir

copy

del

dir

erase

move

rd

ren

set

type

icm

clhy

gjb

rcjb

rjb

sajb

spjb

wjb

sujb

rujb

nsn

gsn

rsn

ipsn

epsn

etsn

exsn

sls

Add-History

Add-PSSnapin

Clear-History

Connect-PSSession

Disable-PSRemoting

Disable-PSSessionConfiguration

Disconnect-PSSession

Enable-PSRemoting

Enable-PSSessionConfiguration

Enter-PSSession

Exit-PSSession

Export-Console

Export-ModuleMember

ForEach-Object

Get-Command

Get-Help

Get-History

Get-Job

Get-Module

Get-PSSession

Get-PSSessionConfiguration

Get-PSSnapin

Import-Module

Invoke-Command

Invoke-History

New-Module

New-ModuleManifest

New-PSSession

New-PSSessionConfigurationFile

New-PSSessionOption

New-PSTransportOption

Out-Default

Out-Host

Out-Null

Receive-Job

Receive-PSSession

Register-JobEvent

Register-PSSessionConfiguration

Remove-Job

Remove-Module

Remove-PSSession

Remove-PSSnapin

Resume-Job

Save-Help

Set-PSDebug

Set-PSSessionConfiguration

Set-StrictMode

Start-Job

Stop-Job

Suspend-Job

Test-ModuleManifest

Test-PSSessionConfigurationFile

Unregister-PSSessionConfiguration

Update-Help

Wait-Job

Where-Object

Add-Computer

Add-Content

Checkpoint-Computer

Clear-Content

Clear-EventLog

Clear-Item

Clear-ItemProperty

Complete-Transaction

Convert-Path

Copy-Item

Copy-ItemProperty

Debug-Process

Disable-ComputerRestore

Enable-ComputerRestore

Export-CimCommand

Get-ChildItem

Get-ComputerRestorePoint

Get-Content

Get-ControlPanelItem

Get-EventLog

Get-HotFix

Get-Item

Get-ItemProperty

Get-Location

Get-Process

Get-PSDrive

Get-PSProvider

Get-Service

Get-Transaction

Get-WmiObject

Invoke-Item

Invoke-WmiMethod

Join-Path

Limit-EventLog

Move-Item

Move-ItemProperty

New-EventLog

New-Item

New-ItemProperty

New-PSDrive

New-Service

New-WebServiceProxy

Pop-Location

Push-Location

Register-WmiEvent

Remove-Computer

Remove-EventLog

Remove-Item

Remove-ItemProperty

Remove-PSDrive

Remove-WmiObject

Rename-Computer

Rename-Item

Rename-ItemProperty

Reset-ComputerMachinePassword

Resolve-Path

Restart-Computer

Restart-Service

Restore-Computer

Resume-Service

Set-Content

Set-Item

Set-ItemProperty

Set-Location

Set-Service

Set-WmiInstance

Show-ControlPanelItem

Show-EventLog

Split-Path

Start-Process

Start-Service

Start-Transaction

Stop-Computer

Stop-Process

Stop-Service

Suspend-Service

Test-ComputerSecureChannel

Test-Connection

Test-Path

Undo-Transaction

Use-Transaction

Wait-Process

Write-EventLog

Add-Member

Add-Type

Clear-Variable

Compare-Object

ConvertFrom-Csv

ConvertFrom-Json

ConvertFrom-StringData

ConvertTo-Csv

ConvertTo-Html

ConvertTo-Json

ConvertTo-Xml

Disable-PSBreakpoint

Enable-PSBreakpoint

Export-Alias

Export-Clixml

Export-Csv

Export-FormatData

Export-PSSession

Format-Custom

Format-List

Format-Table

Format-Wide

Get-Alias

Get-Culture

Get-Date

Get-Event

Get-EventSubscriber

Get-FormatData

Get-Host

Get-Member

Get-PSBreakpoint

Get-PSCallStack

Get-Random

Get-TraceSource

Get-TypeData

Get-UICulture

Get-Unique

Get-Variable

Group-Object

Import-Alias

Import-Clixml

Import-Csv

Import-LocalizedData

Import-PSSession

Invoke-Expression

Invoke-RestMethod

Invoke-WebRequest

Measure-Command

Measure-Object

New-Alias

New-Event

New-Object

New-TimeSpan

New-Variable

Out-File

Out-GridView

Out-Printer

Out-String

Read-Host

Register-EngineEvent

Register-ObjectEvent

Remove-Event

Remove-PSBreakpoint

Remove-TypeData

Remove-Variable

Select-Object

Select-String

Select-Xml

Send-MailMessage

Set-Alias

Set-Date

Set-PSBreakpoint

Set-TraceSource

Set-Variable

Show-Command

Sort-Object

Start-Sleep

Tee-Object

Trace-Command

Unblock-File

Unregister-Event

Update-FormatData

Update-List

Update-TypeData

Wait-Event

Write-Debug

Write-Error

Write-Host

Write-Output

Write-Progress

Write-Verbose

Write-Warning

Set-AppLockerPolicy

Get-AppLockerPolicy

Test-AppLockerPolicy

Get-AppLockerFileInformation

New-AppLockerPolicy

Add-BitsFile

Remove-BitsTransfer

Complete-BitsTransfer

Get-BitsTransfer

Start-BitsTransfer

Resume-BitsTransfer

Set-BitsTransfer

Suspend-BitsTransfer

Get-CimInstance

Get-CimSession

New-CimSession

New-CimSessionOption

Remove-CimSession

Get-CimAssociatedInstance

Get-CimClass

Invoke-CimMethod

New-CimInstance

Register-CimIndicationEvent

Remove-CimInstance

Set-CimInstance

Resolve-DnsName

Resolve-DnsName

Get-KdsRootKey

Add-KdsRootKey

Test-KdsRootKey

Get-KdsConfiguration

Set-KdsConfiguration

Clear-KdsCache

Get-WinEvent

Get-Counter

Import-Counter

Export-Counter

New-WinEvent

Start-Transcript

Stop-Transcript

Get-Acl

Set-Acl

Get-PfxCertificate

Get-Credential

Get-ExecutionPolicy

Set-ExecutionPolicy

Get-AuthenticodeSignature

Set-AuthenticodeSignature

ConvertFrom-SecureString

ConvertTo-SecureString

Disable-WSManCredSSP

Enable-WSManCredSSP

Get-WSManCredSSP

Set-WSManQuickConfig

Test-WSMan

Invoke-WSManAction

Connect-WSMan

Disconnect-WSMan

Get-WSManInstance

Set-WSManInstance

Remove-WSManInstance

New-WSManInstance

New-WSManSessionOption

New-DtcDiagnosticTransaction

Complete-DtcDiagnosticTransaction

Join-DtcDiagnosticResourceManager

Receive-DtcDiagnosticTransaction

Send-DtcDiagnosticTransaction

Start-DtcDiagnosticResourceManager

Stop-DtcDiagnosticResourceManager

Undo-DtcDiagnosticTransaction

New-NetAuthenticationProposal

New-NetMainModeCryptoProposal

New-NetQuickModeCryptoProposal

Get-DAPolicyChange

Get-AutoEnrollmentPolicy

Set-AutoEnrollmentPolicy

Export-Certificate

Import-Certificate

Get-Certificate

Switch-Certificate

Import-PfxCertificate

Export-PfxCertificate

Test-Certificate

New-CertificateNotificationTask

Get-CertificateNotificationTask

Remove-CertificateNotificationTask

Add-EnrollmentPolicyServer

Get-EnrollmentPolicyServer

Remove-EnrollmentPolicyServer

New-SelfSignedCertificate

Get-PfxData

New-JobTrigger

Add-JobTrigger

Remove-JobTrigger

Get-JobTrigger

Set-JobTrigger

Enable-JobTrigger

Disable-JobTrigger

New-ScheduledJobOption

Get-ScheduledJobOption

Set-ScheduledJobOption

Register-ScheduledJob

Get-ScheduledJob

Set-ScheduledJob

Unregister-ScheduledJob

Enable-ScheduledJob

Disable-ScheduledJob

Import-PSWorkflow

New-PSWorkflowExecutionOption

New-JobTrigger

Add-JobTrigger

Remove-JobTrigger

Get-JobTrigger

Set-JobTrigger

Enable-JobTrigger

Disable-JobTrigger

New-ScheduledJobOption

Get-ScheduledJobOption

Set-ScheduledJobOption

Register-ScheduledJob

Get-ScheduledJob

Set-ScheduledJob

Unregister-ScheduledJob

Enable-ScheduledJob

Disable-ScheduledJob

Confirm-SecureBootUEFI

Set-SecureBootUEFI

Get-SecureBootUEFI

Format-SecureBootUEFI

Test-SecureBootPolicy

Repair-SecureBootPolicy

ConvertFrom-SecureBootPolicy

Install-SecureBootPolicy

Get-TroubleshootingPack

Invoke-TroubleshootingPack

Get-Tpm

Initialize-Tpm

Clear-Tpm

Unblock-Tpm

Enable-TpmAutoProvisioning

Disable-TpmAutoProvisioning

Import-TpmOwnerAuth

Set-TpmOwnerAuth

ConvertTo-TpmOwnerAuth

 

四、PowerShell 3.0基础命令快速参考

Connect-PSSession

ConvertFrom-Json

ConvertTo-Json

Disable-PSRemoting

Disconnect-PSSession

Export-CimCommand

Get-ControlPanelItem

Get-TypeData

Invoke-RestMethod

Invoke-WebRequest

New-PSSessionConfigurationFile

New-PSTransportOption

New-WinEvent

Receive-PSSession

Register-JobEvent

Remove-TypeData

Rename-Computer

Resume-Job

Save-Help

Show-Command

Show-ControlPanelItem

Suspend-Job

Test-PSSessionConfigurationFile

Unblock-File

Update-Help

Connect-PSSession ALIASES cnsn

SYNTAX

Connect-PSSession [-ComputerName] <string[]> [-Credential <PSCredential>] [-Authentication

<AuthenticationMechanism> {Default | Basic | Negotiate | NegotiateWithImplicitCredential | Credssp | Digest |

Kerberos}] [-CertificateThumbprint <string>] [-Port <int>] [-UseSSL] [-SessionOption <PSSessionOption>]

[-ThrottleLimit <int>] [-WhatIf] [-Confirm] [<CommonParameters>]

Connect-PSSession [-Session] <PSSession[]> [-SessionOption <PSSessionOption>] [-ThrottleLimit <int>] [-WhatIf]

[-Confirm] [<CommonParameters>]

Connect-PSSession [-ComputerName] <string[]> -InstanceId <Guid[]> [-Credential <PSCredential>] [-Authentication

<AuthenticationMechanism> {Default | Basic | Negotiate | NegotiateWithImplicitCredential | Credssp | Digest |

Kerberos}] [-CertificateThumbprint <string>] [-Port <int>] [-UseSSL] [-SessionOption <PSSessionOption>]

[-ThrottleLimit <int>] [-WhatIf] [-Confirm] [<CommonParameters>]

Connect-PSSession [-ComputerName] <string[]> -Name <string[]> [-Credential <PSCredential>] [-Authentication

<AuthenticationMechanism> {Default | Basic | Negotiate | NegotiateWithImplicitCredential | Credssp | Digest |

Kerberos}] [-CertificateThumbprint <string>] [-Port <int>] [-UseSSL] [-SessionOption <PSSessionOption>]

[-ThrottleLimit <int>] [-WhatIf] [-Confirm] [<CommonParameters>]

Connect-PSSession [-Id] <int[]> [-SessionOption <PSSessionOption>] [-ThrottleLimit <int>] [-WhatIf] [-Confirm]

[<CommonParameters>]

ConvertFrom-Json ALIASES None

SYNTAX

ConvertFrom-Json [-InputObject] <string> [<CommonParameters>]

ConvertTo-Json ALIASES None

SYNTAX

ConvertTo-Json [-InputObject] <Object> [-Depth <int>] [-Compress] [<CommonParameters>]

Disable-PSRemoting ALIASES None

SYNTAX

Disable-PSRemoting [-Force] [-WhatIf] [-Confirm] [<CommonParameters>]

Disconnect-PSSession ALIASES dnsn

SYNTAX

Disconnect-PSSession [-Session] <PSSession[]> [[-SessionOption] <PSSessionOption>] [[-ThrottleLimit] <int>]

[-WhatIf] [-Confirm] [<CommonParameters>]

 

Disconnect-PSSession [[-SessionOption] <PSSessionOption>] [[-ThrottleLimit] <int>] [-InstanceId <Guid[]>]

[-WhatIf] [-Confirm] [<CommonParameters>]

 

Disconnect-PSSession [[-ComputerName] <string[]>] [[-SessionOption] <PSSessionOption>] [[-ThrottleLimit] <int>]

[-WhatIf] [-Confirm] [<CommonParameters>]

 

Disconnect-PSSession [[-SessionOption] <PSSessionOption>] [[-ThrottleLimit] <int>] [-Name <string[]>] [-WhatIf]

[-Confirm] [<CommonParameters>]

 

Disconnect-PSSession [-Id] <int[]> [[-SessionOption] <PSSessionOption>] [[-ThrottleLimit] <int>] [-WhatIf]

[-Confirm] [<CommonParameters>]

Export-CimCommand ALIASES None

SYNTAX

Export-CimCommand [-CmdletDefinitionPath] <string> [-OutputModule <string>] [-Force] [-Encoding <string>]

[-TypesPath <string>] [-FormatPath <string>] [-HelpPath <string>] [-UseOldSystemManagementApi] [<CommonParameters>]

Get-ControlPanelItem ALIASES None

SYNTAX

Get-ControlPanelItem [[-Name] <string[]>] [-Category <string[]>] [<CommonParameters>]

 

Get-ControlPanelItem -CanonicalName <string[]> [-Category <string[]>] [<CommonParameters>]

Get-TypeData ALIASES None

SYNTAX

Get-TypeData [[-TypeName] <string[]>] [<CommonParameters>]

Invoke-RestMethod ALIASES irm

SYNTAX

Invoke-RestMethod [-Uri] <Uri> [-Method <WebRequestMethod> {Default | Get | Head | Post | Put | Delete | Trace |

Options}] [-ReturnType <RestReturnType> {Detect | Json | Xml}] [-Session <WebRequestSession>] [-SessionVariable

<string>] [-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <string>] [-Certificate

<X509Certificate>] [-UserAgent <string>] [-DisableKeepAlive] [-Timeout <int>] [-Headers <IDictionary>]

[-MaximumRedirection <int>] [-Proxy <Uri>] [-ProxyCredential <PSCredential>] [-ProxyUseDefaultCredentials] [-Body

<Object>] [-ContentType <string>] [-TransferEncoding <string>] [-InFile <string>] [-OutFile <string>] [-PassThru]

[<CommonParameters>]

Invoke-WebRequest ALIASES iwr

SYNTAX

Invoke-WebRequest [-Uri] <Uri> [-UseBasicParsing] [-Session <WebRequestSession>] [-SessionVariable <string>]

[-Credential <PSCredential>] [-UseDefaultCredentials] [-CertificateThumbprint <string>] [-Certificate

<X509Certificate>] [-UserAgent <string>] [-DisableKeepAlive] [-Timeout <int>] [-Headers <IDictionary>]

[-MaximumRedirection <int>] [-Method <WebRequestMethod> {Default | Get | Head | Post | Put | Delete | Trace |

Options}] [-Proxy <Uri>] [-ProxyCredential <PSCredential>] [-ProxyUseDefaultCredentials] [-Body <Object>]

[-ContentType <string>] [-TransferEncoding <string>] [-InFile <string>] [-OutFile <string>] [-PassThru]

[<CommonParameters>]

New-PSSessionConfigurationFile ALIASES NONE

SYNTAX

New-PSSessionConfigurationFile [-Path] <string> [-SchemaVersion <Version>] [-Guid <Guid>] [-Author <string>]

[-CompanyName <string>] [-Copyright <string>] [-Description <string>] [-PowerShellVersion <Version>] [-SessionType

<SessionType> {Empty | RestrictedRemoteServer | Default}] [-ModulesToImport <string[]>] [-AssembliesToLoad

<string[]>] [-VisibleAliases <string[]>] [-VisibleCmdlets <string[]>] [-VisibleFunctions <string[]>]

[-VisibleProviders <string[]>] [-VisibleVariables <string[]>] [-AliasDefinitions <hashtable[]>]

[-FunctionDefinitions <hashtable[]>] [-VariableDefinitions <hashtable[]>] [-EnvironmentVariables <Object>]

[-TypesToProcess <string[]>] [-FormatsToProcess <string[]>] [-LanguageMode <PSLanguageMode> {FullLanguage |

RestrictedLanguage | NoLanguage}] [-ExecutionPolicy <ExecutionPolicy> {Unrestricted | RemoteSigned | AllSigned |

Restricted | Default | Bypass | Undefined}] [-ScriptsToProcess <string[]>] [<CommonParameters>]

New-PSTransportOption

SYNTAX

New-PSTransportOption [-MaxIdleTimeout <int>] [-ProcessIdleTimeout <int>] [-MaxSessions <int>]

[-MaxConcurrentCommandsPerSession <int>] [-ReservedConcurrentCommandsPerSession <int>] [-MaxSessionsPerUser <int>]

[-MaxMemoryPerSessionMB <int>] [-MaxProcessesPerSession <int>] [-MaxConcurrentUsers <int>] [-IdleTimeout <int>]

[-OutputBufferingMode <OutputBufferingMode>] [<CommonParameters>]

New-WinEvent

SYNTAX

New-WinEvent [-ProviderName] <string> [-Id] <int> [[-Payload] <Object[]>] [-Version <byte>] [-Force]

[<CommonParameters>]

Receive-PSSession ALIASES rcsn

SYNTAX

Receive-PSSession [-Session] <PSSession> [-OutTarget <OutTarget> {Default | Host | Job}] [-JobName <string>]

[-WhatIf] [-Confirm] [<CommonParameters>]

 

Receive-PSSession [[-Id] <int>] [-OutTarget <OutTarget> {Default | Host | Job}] [-JobName <string>] [-WhatIf]

[-Confirm] [<CommonParameters>]

 

Receive-PSSession [[-ComputerName] <string>] [-Name <string>] [-OutTarget <OutTarget> {Default | Host | Job}]

[-JobName <string>] [-Credential <PSCredential>] [-Authentication <AuthenticationMechanism> {Default | Basic |

Negotiate | NegotiateWithImplicitCredential | Credssp | Digest | Kerberos}] [-CertificateThumbprint <string>]

[-Port <int>] [-UseSSL] [-WhatIf] [-Confirm] [<CommonParameters>]

 

Receive-PSSession [[-ComputerName] <string>] [[-InstanceId] <Guid>] [-OutTarget <OutTarget> {Default | Host |

Job}] [-JobName <string>] [-Credential <PSCredential>] [-Authentication <AuthenticationMechanism> {Default | Basic

| Negotiate | NegotiateWithImplicitCredential | Credssp | Digest | Kerberos}] [-CertificateThumbprint <string>]

[-Port <int>] [-UseSSL] [-WhatIf] [-Confirm] [<CommonParameters>]

 

Receive-PSSession [[-InstanceId] <Guid>] [-OutTarget <OutTarget> {Default | Host | Job}] [-JobName <string>]

[-WhatIf] [-Confirm] [<CommonParameters>]

 

Receive-PSSession [-Name <string>] [-OutTarget <OutTarget> {Default | Host | Job}] [-JobName <string>] [-WhatIf]

[-Confirm] [<CommonParameters>]

Register-JobEvent

SYNTAX

Register-JobEvent [-InputJobObject] <Job> [-EventName] <string> [[-SourceIdentifier] <string>] [[-Action]

<scriptblock>] [-MessageData <psobject>] [-SupportEvent] [-Forward] [<CommonParameters>]

Remove-TypeData

SYNTAX

Remove-TypeData -TypeData <TypeData> [-WhatIf] [-Confirm] [<CommonParameters>]

 

Remove-TypeData [-TypeName] <string> [-WhatIf] [-Confirm] [<CommonParameters>]

 

Remove-TypeData [-Path <string[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

Rename-Computer

SYNTAX

Rename-Computer [-NewName] <string> [-ComputerName <string>] [-PassThru] [-DomainCredential <PSCredential>]

[-LocalCredential <PSCredential>] [-Force] [-Restart] [-WhatIf] [-Confirm] [<CommonParameters>]

Resume-Job ALIASES rujb

SYNTAX

Resume-Job [-Id] <int[]> [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]

 

Resume-Job [-Job] <Job[]> [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]

 

Resume-Job [[-Name] <string[]>] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]

 

Resume-Job [[-InstanceId] <Guid[]>] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]

 

Resume-Job [-PassThru] [-State <JobState> {NotStarted | Running | Completed | Failed | Stopped | Blocked |

Suspended | Disconnected | Suspending | Stopping}] [-WhatIf] [-Confirm] [<CommonParameters>]

 

Resume-Job [-PassThru] [-Filter <hashtable>] [-WhatIf] [-Confirm] [<CommonParameters>]

Save-Help

SYNTAX

Save-Help [[-DestinationPath] <string[]>] [[-UICulture] <string[]>] [-Force] [<CommonParameters>]

 

Save-Help [[-DestinationPath] <string[]>] [[-InputObject] <psmoduleinfo[]>] [[-UICulture] <string[]>]

[-LiteralPath <string[]>] [-Force] [<CommonParameters>]

 

Save-Help [[-DestinationPath] <string[]>] [[-Module] <string[]>] [[-UICulture] <string[]>] [-LiteralPath

<string[]>] [-Force] [<CommonParameters>]

 

Save-Help [[-UICulture] <string[]>] [-LiteralPath <string[]>] [-Force] [<CommonParameters>]

Show-Command

SYNTAX

Show-Command [[-Name] <string>] [-Height <double>] [-Width <double>] [-NoCommonParameter] [-NoErrorPopup]

[<CommonParameters>]

Show-ControlPanelItem

SYNTAX

Show-ControlPanelItem [-Name] <string[]> [<CommonParameters>]

 

Show-ControlPanelItem -CanonicalName <string[]> [<CommonParameters>]

 

Show-ControlPanelItem [[-InputObject] <ControlPanelItem[]>] [<CommonParameters>]<strong></strong>

Suspend-Job ALIASES sujb

SYNTAX

Suspend-Job [-Id] <int[]> [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]

 

Suspend-Job [-Job] <Job[]> [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]

 

Suspend-Job [[-Name] <string[]>] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]

 

Suspend-Job [[-InstanceId] <Guid[]>] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]

 

Suspend-Job [-PassThru] [-State <JobState> {NotStarted | Running | Completed | Failed | Stopped | Blocked |

Suspended | Disconnected | Suspending | Stopping}] [-WhatIf] [-Confirm] [<CommonParameters>]

 

Suspend-Job [-PassThru] [-Filter <hashtable>] [-WhatIf] [-Confirm] [<CommonParameters>]

Test-PSSessionConfigurationFile

SYNTAX

Test-PSSessionConfigurationFile [-Path] <string> [<CommonParameters>]

Unblock-File

SYNTAX

Unblock-File [-Path] <string[]> [-WhatIf] [-Confirm] [<CommonParameters>]

 

Unblock-File [-LiteralPath] <string[]> [-WhatIf] [-Confirm] [<CommonParameters>]

Update-Help

SYNTAX

Update-Help [[-SourcePath] <string[]>] [[-UICulture] <string[]>] [-LiteralPath <string[]>] [-Recurse] [-Force]

[<CommonParameters>]

 

Update-Help [[-Module] <string[]>] [[-SourcePath] <string[]>] [[-UICulture] <string[]>] [-LiteralPath <string[]>]

[-Recurse] [-Force] [<CommonParameters>]

 

Update-Help [[-InputObject] <psmoduleinfo[]>] [[-SourcePath] <string[]>] [[-UICulture] <string[]>] [-LiteralPath

<string[]>] [-Recurse] [-Force] [<CommonParameters>]

 

五、最后写几个命令

查看目前加载的所有模块:Get-Module –All

PowerShell 3.0 实践(一)Windows 8 中的 PowerShell 3.0_第5张图片

 

查看ScheduledTasks模块包含的所有命令:Get-Command –Module ScheduledTasks

PowerShell 3.0 实践(一)Windows 8 中的 PowerShell 3.0_第6张图片

 

 

小结:

Windows 8包含的PowerShell 3.0进行了很大的更新,尤其在Windows Server 8中,几乎所有的管理工作都可以使用PowerShell来完成,甚至一部分管理只能用PowerShell。后续篇章会继续在Windows 8中测试PowerShell 3.0,体验企业级的自动化管理任务。

你可能感兴趣的:(PowerShell 3.0 实践(一)Windows 8 中的 PowerShell 3.0)