Differences between revisions 14 and 15
Revision 14 as of 2020-05-14 06:42:15
Size: 7280
Editor: localhost
Comment:
Revision 15 as of 2020-05-14 06:42:46
Size: 7280
Editor: localhost
Comment:
Deletions are marked like this. Additions are marked like this.
Line 92: Line 92:
  * [[https://vdc-download.vmware.com/vmwb-repository/dcr-public/da47f910-60ac-438b-8b9b-6122f4d14524/16b7274a-bf8b-4b4c-a05e-746f2aa93c8c/doc/vim.vm.GuestOsDescriptor.GuestOsIdentifier.html | GuestId]]   * [[https://vdc-download.vmware.com/vmwb-repository/dcr-public/da47f910-60ac-438b-8b9b-6122f4d14524/16b7274a-bf8b-4b4c-a05e-746f2aa93c8c/doc/vim.vm.GuestOsDescriptor.GuestOsIdentifier.html | GuestID]]

Install

Windows 2008R2

Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
get-host
$PSVersionTable
Install-Module VMware.PowerCLI -Scope CurrentUser

PS C:\Users\Administrator> get-host


Name             : ConsoleHost
Version          : 5.1.14409.1005
InstanceId       : cee5ec9e-f773-452a-b675-00cc8f1d491f
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : zh-CN
CurrentUICulture : zh-CN
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace



PS C:\Users\Administrator> Get-PowerCLIVersion
警告: Please consider joining the VMware Customer Experience Improvement Program, so you can help us make PowerCLI a better product. You can join using the following command:

Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true

VMware's Customer Experience Improvement Program ("CEIP") provides VMware with information that enables VMware to improve its products and services, to fix problems, and to advise you on how best to deploy and use our products.  As part of the CEIP, VMware collects technical
information about your organization抯 use of VMware products and services on a regular basis in association with your organization抯 VMware license key(s).  This information does not personally identify any individual.

For more details: type "help about_ceip" to see the related help article.

To disable this warning and set your preference use the following command and restart PowerShell:
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true or $false.
警告: The cmdlet "Get-PowerCLIVersion" is deprecated. Please use the 'Get-Module' cmdlet instead.

PowerCLI Version
----------------
   VMware PowerCLI 11.5.0 build 14912921
---------------
Component Versions
---------------
   VMware Common PowerCLI Component 11.5 build 14898112
   VMware Cis Core PowerCLI Component PowerCLI Component 11.5 build 14898113
   VMware VimAutomation VICore Commands PowerCLI Component PowerCLI Component 11.5 build 14899560

Configration

Set-ExecutionPolicy RemoteSigned
Set-PowerCLIConfiguration -ProxyPolicy NoProxy
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore

Use

Connect-VIServer -server 192.168.25.60 -Protocol https -Username 'administrator@vsphere.local'

PowerCLI to quickly retrieve the time setting on all the hosts managed by specific vCenter instances

foreach ($esx in (get-vmhost)) {$esx.Name + " -> " + (get-view $esx.ExtensionData.ConfigManager.DateTimeSystem).QueryDateTime().ToLocalTime()}

Script to list VM Network Adapter Type, exporting issue

Get-VM | Get-NetworkAdapter | 
Where-object {$_.Type -ne "Vmxnet3"} | 
Select @{N="VM";E={$_.Parent.Name}},Name,Type |
export-Csv  c:\Network_Interface.csv -NoTypeInformation

Deploy VMs from template PowerCLI Script

Name    IP      SUBNET  GATEWAY DNS1    DNS2    vmhost  template        cluster csm     datastore
testVM1 192.168.1.2     255.255.240.0   192.168.1.1     192.168.1.7     192.168.1.8     testVMHost.domain.local testVMTemplate  test VM Cluster testCustomizationSpec   test Datastore
testVM2 192.168.1.3     255.255.240.0   192.169.1.1     192.168.1.7     192.168.1.8     testVMHost.domain.local testVMTemplate

Create VM

PS C:\Users\Administrator> New-VM -Name Dnsmasq-DNS-Server-01 -Datastore ESXi-25.200 -DiskGB 20 -DiskStorageFormat Thin -MemoryGB 4 -CD -GuestId rhel7_64Guest -NumCpu 2 -VMHost 192.168.25.200

Name                 PowerState Num CPUs MemoryGB
----                 ---------- -------- --------
Dnsmasq-DNS-Serve... PoweredOff 2        4.000

delete VM

  • Get-VM

PS C:\Users\Administrator> Get-VM

Name                 PowerState Num CPUs MemoryGB
----                 ---------- -------- --------
WIN-XP               PoweredOff 2        4.000
TTTT-02              PoweredOff 2        4.000
Edge-Host            PoweredOff 6        8.000
Product-Host         PoweredOff 6        10.000
Internet-Test-Client PoweredOff 1        0.375
nsxmgr-01            PoweredOff 4        16.000
TTTT-01              PoweredOff 2        4.000
New Virtual Machine  PoweredOff 1        0.250
WIN10                PoweredOff 2        6.000
LAMP_v7              PoweredOn  1        0.758
workspace            PoweredOff 1        0.250
CSR-Router           PoweredOff 1        4.000
BIG-IP-LTM           PoweredOn  2        4.000
Internet-router      PoweredOff 1        1.000
NSX-l2t-client-Xl... PoweredOff 6        8.000
test1                PoweredOff 1        2.000
t-vcenter            PoweredOn  2        10.000
FTD1                 PoweredOff 4        8.000

PS C:\Users\Administrator> Remove-VM -VM TTTT-01 -DeletePermanently

Perform operation?
Performing operation 'Removing VM from disk.' on VM 'TTTT-01'
[Y] 是(Y)  [A] 全是(A)  [N] 否(N)  [L] 全否(L)  [S] 暂停(S)  [?] 帮助 (默认值为“Y”):
PS C:\Users\Administrator> Get-VM

Name                 PowerState Num CPUs MemoryGB
----                 ---------- -------- --------
WIN-XP               PoweredOff 2        4.000
TTTT-02              PoweredOff 2        4.000
Edge-Host            PoweredOff 6        8.000
Product-Host         PoweredOff 6        10.000
Internet-Test-Client PoweredOff 1        0.375
nsxmgr-01            PoweredOff 4        16.000
New Virtual Machine  PoweredOff 1        0.250
WIN10                PoweredOff 2        6.000
LAMP_v7              PoweredOn  1        0.758
workspace            PoweredOff 1        0.250
CSR-Router           PoweredOff 1        4.000
BIG-IP-LTM           PoweredOn  2        4.000
Internet-router      PoweredOff 1        1.000
NSX-l2t-client-Xl... PoweredOff 6        8.000
test1                PoweredOff 1        2.000
t-vcenter            PoweredOn  2        10.000
FTD1                 PoweredOff 4        8.000

Get/Change CPUID

Winodws script

http://vknowledge.net/2014/04/17/how-to-fake-a-vms-guest-os-cpuid/

  • Enable excution

PS C:\Users\Administrator> Get-ExecutionPolicy
Restricted

PS C:\Users\Administrator>   set-executionpolicy remotesigned

执行策略更改
执行策略可以防止您执行不信任的脚本。更改执行策略可能会使您面临 about_Execution_Policies
帮助主题中所述的安全风险。是否要更改执行策略?
[Y] 是(Y)  [N] 否(N)  [S] 挂起(S)  [?] 帮助 (默认值为“Y”):
  • Get cpuid

PS C:\Users\Administrator> Get-WmiObject Win32_Processor | select ProcessorId

ProcessorId
-----------
0FABFBFF000106A5
0FABFBFF000006A5
  • convert HEX to ascii

désert/VMware/PowerCLI (last edited 2020-07-24 15:03:34 by localhost)