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下安装:官方下载

本系列全部脚本在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,体验企业级的自动化管理任务。

(0)

相关推荐

  • 揭秘PowerShell 5.0新特性和新功能

    Windows PowerShell 5.0中包含了大量的新特性和新功能,提升了整体的用户体验.虽然其中一些功能只能供硬核PowerShell开发人员使用,但其他新功能和特性具有广泛的适用性. 例如其中一个新功能是远程文件编辑.管理员暂时可以通过PowerShell建立与另一个Windows服务器的远程会话.新的远程文件编辑功能在此基础之上进行构建,从而能够建立一个远程会话,然后在远程计算机上编辑文件. 建立远程会话的方法通常相同.你可以使用Enter-PSSession命令,附上–Comput

  • Powershell 获取特定的网页信息的代码

    Powershell可以很轻松的获取网页的信息并读取到对应的内容.如果对象的格式是XML或者Json,那就更容易处理了,一般经常使用invoke-restmethod和invoke-webrequest这两个命令.前者主要是获取Json格式的内容,后者可以获取整个网页的内容. 比如说我希望查询明天悉尼的天气如何.网上随便搜了一个提供API的站点 http://openweathermap.org/current#name 我打算搜索悉尼的,那么对应的格式是 http://api.openweat

  • PowerShell 4.0实现自动化设置服务器

    PowerShell是微软Windows操作系统中一款强大的操作工具.PowerShell的版本随Windows的发布而更新,例如最新的Windows Server 2012 R2/Windows 8.1中提供了最新的PowerShell 4.0版本.预计明年Windows Server新版本将带来PowerShell 5.0版本. PowerShell 4.0带来了很多有助于管理员的新功能,最显著的是增强了自动化功能.这里笔者分享Mark Minasi在国外网站windowsitpro上发表的

  • Powershell错误处理之what-if

    自动化具有高度方便的特点,同时也可能会自动产生一些不可避免的错误.这也就是Powershell为什么会有一些专门来防止和处理危险的机制:这些机制会对接下来要执行的操作进行确认. 试运行:模拟操作 如果你想知道一个确定的命令会产生什么影响,你可以进行试运行.这时,Powershell不会执行任何对系统有影响的操作,只会告诉你如果没有模拟运行,可能产生什么影响和后果.通过-whatif 参数.事实上,许多cmdltes都支持试运行. #如果执行stop-process -name *a*会终止下面的

  • Powershell 查询 Windows 日志的方法

    论坛里面有人询问如何使用powershell脚本查询文件修改的审计日志,豆子服务器没开这个功能,不过尝试写了个类似的脚本可以查询日志,并输出对应的xml内容. 基本方法是get-winevent, 可以指定对应的eventid,获取列表.如果想获取这个事件具体的内容,需要根据不同事件的xml内容进行变化. 比如 $Events = Get-WinEvent -ComputerName syddc01 -FilterHashtable @{Logname='Security';Id=4771} -

  • PowerShell用户认证Function实例代码

       在最近工作中遇到对用户验证,需要根据用户名和密码验证用户是否合法.在外文网站找到的这段代码,在这里分享给大家,如果你也需要用户验证的话,那么可以直接copy使用,现在没地方用,也可以收藏备用. Function Test-UserCredential { [CmdletBinding()] [OutputType([System.Boolean])] param( [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [System

  • Powershell 查找用户的主SMTP地址

    今天同事让我生成一个报表,列出用户的主SMTP地址后缀是@aus.ddb.com的用户. Get-ADUser可以直接获取相关信息,不过主SMTP是隐藏在ProxyAddress这个属性里面的,如果1个用户有多个邮件地址,大写的SMTP的那个就是主地址. 脚本如下,获取所有用户的信息,然后创建一个空对象,对每一个对象的属性进行处理,把对应的值放入对象, 最后过滤结果输出. $users = Get-ADUser -Filter {proxyAddresses -like '*'} -Search

  • 使用PowerShell修改注册表

    下面的例子里, PowerShell修改了注册表键值, 完成了Security loop disable, 和loopbackcheck disable. 复制代码 代码如下: #Security loop disable so that you can look at it on the same machine if(($gchn = Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0\" -Nam

  • powershell解决win10开始菜单和通知中心无法打开

    问题描述 笔者用的是现在并不成熟的Win10操作系统,昨天首先就遇到了打开计算器出现闪退的情况,然后我google 找到了一个方案 点击开始菜单,输入"Powershell"在搜索结果中右键单击Powershell,选择"以管理员身份运行"在打开的窗口里面输入以下内容 复制代码 代码如下: Get-AppXPackage -AllUsers | Foreach {Add-AppxPackage -DisableDevelopmentMode -Register &q

  • PowerShell使用小技巧分享

    如何使用PowerShell修改Host文件 下面的命令, 为Host文件添加了一条记录, 让/sps2010/hostheader1/这个url指向server自己. 复制代码 代码如下: $url="http://sps2010/hostheader1/" if( (Get-Content $env:windir\System32\drivers\etc\hosts |?{$_ -imatch "\s$url"}) -eq $null){"`n127.

随机推荐