1.Get-ErrorReport
功能:收集调试信息,以便确定在工作环境中的问题。
语法:
Get-ErrorReport [-ProblemDescription] <String> [-ProblemScriptTimeoutSeconds] <Double> [[-Destination] <DirectoryInfo>] [-ProblemScript] <ScriptBlock> [-DontIncludeServerLogs] [<CommonParameters>]
例子:
$script = { Connect-VIServer 10.23.34.36 $vapp = Get-VApp Get-VM VM -Location $vapp } $script | Get-ErrorReport -ProblemScriptTimeoutSeconds 10 -ProblemDescription "No VM is returned. There are several VMs in this vApp. The vApp is in a DRS-enabled cluster. All VMs part of the vApp are expected to be returned." -Destination 'D:\bug reports'
2.Get-Log
功能:从vSphere检索日志条目。
语法:
Get-Log [-Key] <String[]> [[-VMHost] <VMHost[]>] [[-StartLineNum] <Int32>] [[-NumLines] <Int32>] [-Server <VIServer[]>] [<CommonParameters>]
Get-Log [[-VMHost] <VMHost[]>] [-Bundle] [-DestinationPath] <String> [-Server <VIServer[]>] [-RunAsync] [<CommonParameters>]
例子:
$keys = Get-LogType Get-Log -Key $keys[0]
3.Get-LogType
功能:检索虚拟机主机有关的日志信息。
语法:
Get-LogType [[-VMHost] <VMHost[]>] [-Server <VIServer[]>] [<CommonParameters>]
例子:
$host = Get-VMHost -State "Connected" Get-Logtype -VMHost $host
4.Get-OSCustomizationSpec
功能:检索在vSphere的服务器上可用的操作系统自定义规范。
语法:
Get-OSCustomizationSpec [[-Server] <VIServer[]>] [[-Name] <String[]>] [-Id <String[]>] [-Type <OSCustomizationSpecType>] [<CommonParameters>]
例子:
(1)
Get-OSCustomizationSpec "test"
(2)
New-VM -Name VM -VMHost Host -Template Template -OSCustomizationSpec $spec
5.New-OSCustomizationSpec
功能:创建一个新的操作系统的自定义规范。
语法:
New-OSCustomizationSpec [-OSType <String>] [-Server <VIServer[]>] [-Name <String>] [-Type <OSCustomizationSpecType>] [-DnsServer <String[]>] [-DnsSuffix <String[]>] [-Domain <String>] [-NamingScheme <String>] [-NamingPrefix <String>] [-Description <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-OSCustomizationSpec -OSCustomizationSpec <OSCustomizationSpec> [-Server <VIServer[]>] [-Name <String>] [-Type <OSCustomizationSpecType>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-OSCustomizationSpec -FullName <String> -OrgName <String> [-OSType <String>] [-ChangeSid] [-DeleteAccounts] [-Server <VIServer[]>] [-Name <String>] [-Type <OSCustomizationSpecType>] [-DnsServer <String[]>] [-DnsSuffix <String[]>] [-GuiRunOnce <String[]>] [-AdminPassword <String>] [-TimeZone <String>] [-AutoLogonCount <Int32>] [-Domain <String>] [-Workgroup <String>] [-DomainCredentials <PSCredential>] [-DomainUsername <String>] [-DomainPassword <String>] [-ProductKey <String>] [-NamingScheme <String>] [-NamingPrefix <String>] [-Description <String>] [-LicenseMode <LicenseMode>] [-LicenseMaxConnections <Int32>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
(1)
New-OSCustomizationSpec -Name Spec -OSType Windows -FullName Administrator -OrgName Organization -NamingScheme Fixed -NamingPrefix Computer -ProductKey "xxxx-xxxx" -LicenseMode PerSeat -Workgroup Workgroup –ChangeSid
(2)
New-OSCustomizationSpec -Name Spec -OSType Windows -Description "This spec adds a computer in a domain." -FullName Administrator -OrgName Organization -NamingScheme Fixed -NamingPrefix "Computer" -ProductKey "xxxx-xxxx" -LicenseMode Perserver -LicenseMaxConnections 30 -AdminPassword pass -Domain Domain -DomainUsername Root -DomainPassword pass
6.Remove-OSCustomizationSpec
功能:删除指定的操作系统自定义规范。
语法:
Remove-OSCustomizationSpec [-OSCustomizationSpec] <OSCustomizationSpec[]> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Remove-OSCustomizationSpec Spec –Confirm
7.Set-OSCustomizationSpec
功能:更改指定的操作系统自定义规范。
语法:
Set-OSCustomizationSpec [-OSCustomizationSpec] <OSCustomizationSpec[]> [-NewSpec <OSCustomizationSpec>] [-Type <OSCustomizationSpecType>] [-Server <VIServer[]>] [-Name <String>] [-DnsServer <String[]>] [-DnsSuffix <String[]>] [-Domain <String>] [-NamingScheme <String>] [-NamingPrefix <String>] [-Description <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
Set-OSCustomizationSpec [-FullName <String>] [-OrgName <String>] [-ChangeSID [<Boolean>]] [-DeleteAccounts [<Boolean>]] [-OSCustomizationSpec] <OSCustomizationSpec[]> [-NewSpec <OSCustomizationSpec>] [-Type <OSCustomizationSpecType>] [-Server <VIServer[]>] [-Name <String>] [-DnsServer <String[]>] [-DnsSuffix <String[]>] [-GuiRunOnce <String[]>] [-AdminPassword <String>] [-TimeZone <String>] [-AutoLogonCount <Int32>] [-Domain <String>] [-Workgroup <String>] [-DomainCredentials <PSCredential>] [-DomainUsername <String>] [-DomainPassword <String>] [-ProductKey <String>] [-NamingScheme <String>] [-NamingPrefix <String>] [-Description <String>] [-LicenseMode <LicenseMode>] [-LicenseMaxConnections <Int32>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Set-OSCustomizationSpec Spec -Description 'This is a test OS customization specification.'
8.get-powerclicommunity
功能:访问PowerCLI社区
语法:
get-powerclicommunity [<CommonParameters>]
例子:
get-powerclicommunity
9.Get-PowerCLIConfiguration
功能:检索在vSphere PowerCLI代理服务器的配置和默认策略。
语法:
Get-PowerCLIConfiguration [<CommonParameters>]
例子:
Get-PowerCLIConfiguration
10.Get-PowerCLIDocumentation
功能:访问PowerCLI帮助文件。
语法:
Get-PowerCLIDocumentation [<CommonParameters>]
例子:
Get-PowerCLIDocumentation
11.Get-PowerCLIVersion
功能:检索已安装的PowerCLI snapins的版本。
语法:
Get-PowerCLIVersion [<CommonParameters>]
例子:
(1)
Get-PowerCLIVersion
(2)
Get-PowerCLIVersion | select -expand SnapinVersions
12.Get-Stat
功能:检索vSphere服务器上可用的统计资料。
语法:
Get-Stat [-Entity] <VIObject[]> [-Common] [-Memory] [-Cpu] [-Disk] [-Network] [-Stat <String[]>] [-Start <DateTime>] [-Finish <DateTime>] [-MaxSamples <Int32>] [-IntervalMins <Int32>] [-IntervalSecs <Int32>] [-Instance <String[]>] [-Realtime] [<CommonParameters>]
例子:
(1)
Get-Stat -Entity VM -Start 5/5/2008 -Finish 7/10/2008 -Disk -IntervalSecs 300
(2)
Get-Stat ?Entity Host ?Cpu ?Instance 0, "
13.Get-Statlnterval
功能:检索现有统计数据的时间间隔。
语法:
Get-StatInterval [[-Name] <String[]>] [[-SamplingPeriodSecs] <Int32[]>] [-Server <VIServer[]>] [<CommonParameters>]
例子:
Get-StatInterval
14.New-StatInterval
功能:创建一个具有指定参数统计的时间间隔。
语法:
New-StatInterval [-Name] <String> [-SamplingPeriodSecs] <Int32> [-StorageTimeSecs] <Int32> [[-Server] <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
New-StatInterval -Name Minute -SamplingPeriodSecs 60 -StorageTimeSecs 600
15.Remove-StatInterval
功能:删除统计所提供的采样间隔期或指定名称。
语法:
Remove-StatInterval [-Interval] <StatInterval[]> [[-Server] <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Remove-StatInterval -Interval *
16.Set-StatInterval
功能:更改统计的时间间隔。
语法:
Set-StatInterval [[-SamplingPeriodSecs] <Int32>] [[-StorageTimeSecs] <Int32>] [-Interval] <StatInterval[]> [[-Server] <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
Set-StatInterval -Interval "past day" -StorageTimeSecs 700000
17.Get-StatType
功能:为检索对象的类型库存统计数字。
语法:
Get-StatType [[-Name] <String[]>] [-Entity] <InventoryItem[]> [-Start <DateTime>] [-Finish <DateTime>] [-Interval <StatInterval[]>] [-Realtime] [-Server <VIServer[]>] [<CommonParameters>]
例子:
Get-StatType -Entity VM
18.Get-VICredentialStoreItem
功能:检索vSphere服务器上可用的凭据存储项目
语法:
Get-VICredentialStoreItem [[-Host] <String>] [[-User] <String>] [[-File] <String>] [<CommonParameters>]
例子:
Get-VICredentialStoreItem -User admin -Host 192.168.1.10 -File 'credentials.xml'
19.New-VICredentialStoreItem
功能:在创建凭据存储新条目。
语法:
New-VICredentialStoreItem [-Host] <String> [-User] <String> [[-Password] <String>] [[-File] <String>] [<CommonParameters>]
例子:
New-VICredentialStoreItem -Host 192.168.1.10 -User Admin -Password pass
20.Remove-VICredentialStoreItem
功能:删除指定的凭据存储项目。
语法:
Remove-VICredentialStoreItem [-CredentialStoreItem] <VICredentialStoreItem[]> [-WhatIf] [-Confirm] [<CommonParameters>]
Remove-VICredentialStoreItem [[-Host] <String>] [[-User] <String>] [[-File] <String>] [-WhatIf] [-Confirm] [<CommonParameters>]
例子:
(1)
Remove-VICredentialStoreItem -Host 192.168.1.100 –Confirm
(2)
Remove-VICredentialStoreItem -User 'admin' -Host '192.168.*' -File 'credentials.xml' -Confirm
21.Get-VIEvent
功能:检索有关vSphere服务器上的事件的信息。
语法:
Get-VIEvent [[-Entity] <VIObject[]>] [-Start <DateTime>] [-Finish <DateTime>] [-Username <String>] [-MaxSamples <Int32>] [-Types <EventCategory[]>] [-Server <VIServer[]>] [<CommonParameters>]
例子:
(1)
Get-VIEvent -Entity VM -Username admin -Type error -MaxSamples 15
(2)
Connect-VIServer -Server 10.23.113.41 $events = Get-VIEvent -MaxSamples 100 foreach ($event in $events) {if ($event.fullFormattedMessage -match "User (.*)@\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b logged in") {Write-Host ("User " + $matches[1] + " logged in at:" + $event.createdTime)} }
22.Get-VMHostSysLogServer
功能:显示指定主机的远程syslog服务器。
语法:
Get-VMHostSysLogServer [-VMHost] <VMHost[]> [-Server <VIServer[]>] [<CommonParameters>]
例子:
$sysLogServer = Get-VMHostSysLogServer -VMHost 10.23.123.234
23.Get-VMResourceConfiguration
功能:检索有关虚拟机之间的资源分配信息。
语法:
Get-VMResourceConfiguration [-Server <VIServer[]>] [-VM] <VirtualMachine[]> [<CommonParameters>]
例子:
Get-VMResourceConfiguration -VM VM | Format-Custom -Property DiskResourceConfiguration