Windows 8 中的 PowerShell 3.0

PowerShell並不是在Windows 8上首次出現,所以,很多IT專業人員、程序員和高級用戶都非常熟悉了。在這裏重提PowerShell,主要是爲了爲一些之前沒有了解過PowerShell用戶,還有對PowerShell 3.0不是特別瞭解的用戶。PowerShell高手可以跳過此文。

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下安裝:官方下載

本系列全部腳本在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的命令行:

雖然標題欄還是1.0,但是通過全局變量 $host 可以查看具體版本信息:

未安裝 Windows 8 的朋友也不必掃興,微軟已經放出了PowerShell 3.0 CTP1的下載,在這裏下載:

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

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 Instrumentation,Windows管理規範)

新的開發模型提供者 - 新的開發模型降低了管理成本,移除了對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

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

小結:

Windows 8包含的PowerShell 3.0進行了很大的更新,尤其在Windows Server 8中,幾乎所有的管理工作都可以使用PowerShell來完成,甚至一部分管理只能用PowerShell。後續篇章會繼續在Windows 8中測試PowerShell 3.0,體驗企業級的自動化管理任務。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章