├── Get-VMID.psm1 ├── Media ├── Get-VMID.png ├── Set-CBT.png ├── Get-NewVMs.png ├── Get-VMDisk.png ├── Konfig-ESXi.png ├── Start-UNMAP.png ├── Get-NICDetails.png ├── Get-VMmaxIOPS.png ├── Set-IOPSLimit.png ├── Apply-Hardening.png ├── Recommend-Sizing.png ├── Get-UplinkDetails.png ├── Set-CBT_VI-Property.png ├── Get-NewAndRemovedVMs.png ├── Validate-ESXiPackages.png └── Get-NewAndRemovedVMs_Detail.png ├── Push-vLIMessage.psm1 ├── .vscode └── settings.json ├── Set-ConsolidationFix.psm1 ├── FUNDING.yml ├── Set-IOPSLimit.xml ├── .gitattributes ├── ReadTheDocs └── CreateDoc.ps1 ├── .gitignore ├── Helper ├── Update-PowerShellGallery.psm1 └── Update-ModuleManifestData.psm1 ├── doc ├── index.rst └── Features │ ├── cmd_validate.rst │ ├── cmd_apply.rst │ ├── cmd_start.rst │ ├── cmd_konfig.rst │ ├── cmd_recommend.rst │ ├── cmd_push.rst │ ├── cmd_set.rst │ └── cmd_get.rst ├── Validate-ESXiPackages.psm1 ├── Get-NICDetails.psm1 ├── Apply-Hardening.psm1 ├── README.md ├── Get-VMDisk.psm1 ├── Start-UNMAP.psm1 ├── Get-VMmaxIOPS.psm1 ├── Get-UplinkDetails.psm1 ├── Set-CBT.psm1 ├── Get-NewAndRemovedVMs.psm1 ├── vSphere-Modules.psd1 ├── Get-VMHostUplinkDetails.psm1 ├── Get-NewVMs.psm1 ├── Konfig-ESXi.psm1 ├── Set-IOPSLimit.psm1 ├── Set-VMHostSecureNTP.psm1 ├── LICENSE └── Recommend-Sizing.psm1 /Get-VMID.psm1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Get-VMID.psm1 -------------------------------------------------------------------------------- /Media/Get-VMID.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Get-VMID.png -------------------------------------------------------------------------------- /Media/Set-CBT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Set-CBT.png -------------------------------------------------------------------------------- /Media/Get-NewVMs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Get-NewVMs.png -------------------------------------------------------------------------------- /Media/Get-VMDisk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Get-VMDisk.png -------------------------------------------------------------------------------- /Media/Konfig-ESXi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Konfig-ESXi.png -------------------------------------------------------------------------------- /Media/Start-UNMAP.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Start-UNMAP.png -------------------------------------------------------------------------------- /Push-vLIMessage.psm1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Push-vLIMessage.psm1 -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | // Place your settings in this file to overwrite default and user settings. 2 | { 3 | } -------------------------------------------------------------------------------- /Media/Get-NICDetails.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Get-NICDetails.png -------------------------------------------------------------------------------- /Media/Get-VMmaxIOPS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Get-VMmaxIOPS.png -------------------------------------------------------------------------------- /Media/Set-IOPSLimit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Set-IOPSLimit.png -------------------------------------------------------------------------------- /Media/Apply-Hardening.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Apply-Hardening.png -------------------------------------------------------------------------------- /Media/Recommend-Sizing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Recommend-Sizing.png -------------------------------------------------------------------------------- /Set-ConsolidationFix.psm1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Set-ConsolidationFix.psm1 -------------------------------------------------------------------------------- /FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [vMarkusK] 2 | custom: ["https://www.paypal.me/mycloudrevolution", "https://flattr.com/@vMarkus_K"] -------------------------------------------------------------------------------- /Media/Get-UplinkDetails.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Get-UplinkDetails.png -------------------------------------------------------------------------------- /Media/Set-CBT_VI-Property.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Set-CBT_VI-Property.png -------------------------------------------------------------------------------- /Media/Get-NewAndRemovedVMs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Get-NewAndRemovedVMs.png -------------------------------------------------------------------------------- /Media/Validate-ESXiPackages.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Validate-ESXiPackages.png -------------------------------------------------------------------------------- /Media/Get-NewAndRemovedVMs_Detail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vMarkusK/vSphere-Modules/HEAD/Media/Get-NewAndRemovedVMs_Detail.png -------------------------------------------------------------------------------- /Set-IOPSLimit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | B 7 | 250 8 | 9 | 10 | S 11 | 1000 12 | 13 | 14 | G 15 | -1 16 | 17 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /ReadTheDocs/CreateDoc.ps1: -------------------------------------------------------------------------------- 1 | $verbs = (Get-Command -Module vSphere-Modules | 2 | ForEach-Object -Process { 3 | $_.Name.Split('-')[0] 4 | } | 5 | Select-Object -Unique) 6 | 7 | foreach ($verb in $verbs) 8 | { 9 | $data = @() 10 | $data += "$verb Commands" 11 | $data += '=========================' 12 | $data += '' 13 | $data += "This page contains details on **$verb** commands." 14 | $data += '' 15 | foreach ($help in (Get-Command -Module vSphere-Modules | Where-Object -FilterScript { 16 | $_.name -match $verb 17 | })) 18 | { 19 | $data += $help.Name 20 | $data += '-------------------------' 21 | $data += '' 22 | $data += Get-Help -Name $help.name -Detailed 23 | $data += '' 24 | } 25 | 26 | $data | Out-File -FilePath "$PSScriptRoot\cmd_$($verb.ToLower()).rst" -Encoding utf8 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /Helper/Update-PowerShellGallery.psm1: -------------------------------------------------------------------------------- 1 | <# 2 | 3 | .SYNOPSIS 4 | 5 | .DESCRIPTION 6 | 7 | .PARAMETER Path 8 | 9 | .PARAMETER ApiKey 10 | 11 | .EXAMPLE 12 | Update-PowerShellGallery -Path .\My-Folder -ApiKey 'c5bb9aea-333-666-9b34-e8c70eb1fdb2' 13 | 14 | #Requires PS -Version 5.0 15 | #> 16 | function Update-PowerShellGallery { 17 | 18 | [CmdletBinding()] 19 | 20 | Param ( 21 | 22 | [Parameter(Mandatory=$true)] 23 | [ValidateNotNullOrEmpty()] 24 | [String]$Path, 25 | 26 | [Parameter(Mandatory=$true)] 27 | [ValidateNotNullOrEmpty()] 28 | [String]$ApiKey 29 | 30 | ) 31 | Process { 32 | $PublishParams = @{ 33 | NuGetApiKey = $ApiKey 34 | Path = $Path 35 | } 36 | 37 | Publish-Module @PublishParams 38 | } 39 | } -------------------------------------------------------------------------------- /doc/index.rst: -------------------------------------------------------------------------------- 1 | Welcome to my vSphere Module Collection 2 | ======================== 3 | 4 | .. image:: http://readthedocs.org/projects/vsphere-modules/badge/?version=latest 5 | :target: http://vsphere-modules.readthedocs.io/en/latest/?badge=latest 6 | 7 | 8 | 9 | .. image:: http://mycloudrevolution.com/wp-content/uploads/2016/06/PowerCLI-1.png 10 | :target: http://vmware.com/go/powercli 11 | 12 | This my collection of VMware PowerCLI Modules. These Module should extend and facilitate the out of the box Features. 13 | Project Page: http://mycloudrevolution.com/projekte/vsphere-powershell-modules/ 14 | 15 | .. _available on GitHub: https://github.com/mycloudrevolution/vSphere-Modules 16 | 17 | The main documentation for the site is organized into a couple sections: 18 | 19 | * :ref:`feature-docs` 20 | 21 | .. _feature-docs: 22 | 23 | .. toctree:: 24 | :maxdepth: 2 25 | :glob: 26 | :caption: Feature Documentation 27 | 28 | Features/* 29 | -------------------------------------------------------------------------------- /doc/Features/cmd_validate.rst: -------------------------------------------------------------------------------- 1 | Validate Commands 2 | ========================= 3 | 4 | This page contains details on **Validate** commands. 5 | 6 | Validate-ESXiPackages 7 | ------------------------- 8 | 9 | 10 | NAME 11 | Validate-ESXiPackages 12 | 13 | ÜBERSICHT 14 | 15 | 16 | SYNTAX 17 | Validate-ESXiPackages [-Cluster] [-RefernceHost] [] 18 | 19 | 20 | BESCHREIBUNG 21 | Compares all ESXi Host VIBs within a vSphere with a reference Hosts. 22 | 23 | 24 | PARAMETER 25 | -Cluster 26 | vSphere Cluster to verify 27 | 28 | -RefernceHost 29 | The VIB Reference ESXi Host 30 | 31 | 32 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 33 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 34 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 35 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 36 | 37 | -------------------------- BEISPIEL 1 -------------------------- 38 | 39 | PS C:\>Validate-ESXiPackages -Cluster (Get-Cluster) -RefernceHost (Get-VMHost | Select-Object -First 1) 40 | 41 | 42 | 43 | 44 | 45 | 46 | HINWEISE 47 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Validate-ESXiPackages -examples". 48 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Validate-ESXiPackages -detailed". 49 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Validate-ESXiPackages -full". 50 | Geben Sie zum Abrufen der Onlinehilfe Folgendes ein: "get-help Validate-ESXiPackages -online" 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /doc/Features/cmd_apply.rst: -------------------------------------------------------------------------------- 1 | Apply Commands 2 | ========================= 3 | 4 | This page contains details on **Apply** commands. 5 | 6 | Apply-Hardening 7 | ------------------------- 8 | 9 | 10 | NAME 11 | Apply-Hardening 12 | 13 | ÜBERSICHT 14 | 15 | 16 | SYNTAX 17 | Apply-Hardening [-VMs] [] 18 | 19 | 20 | BESCHREIBUNG 21 | Applys a set of Hardening options to your VMs 22 | 23 | 24 | PARAMETER 25 | -VMs 26 | Specify the VMs 27 | 28 | 29 | #Requires PS -Version 4.0 30 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 31 | 32 | 33 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 34 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 35 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 36 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 37 | 38 | -------------------------- BEISPIEL 1 -------------------------- 39 | 40 | PS C:\>Get-VM TST* | Apply-Hardening 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------- BEISPIEL 2 -------------------------- 48 | 49 | PS C:\>$SampleVMs = Get-VM "TST*" 50 | 51 | Apply-Hardening -VMs $SampleVMs 52 | 53 | 54 | 55 | 56 | HINWEISE 57 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Apply-Hardening -examples". 58 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Apply-Hardening -detailed". 59 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Apply-Hardening -full". 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /doc/Features/cmd_start.rst: -------------------------------------------------------------------------------- 1 | Start Commands 2 | ========================= 3 | 4 | This page contains details on **Start** commands. 5 | 6 | Start-UNMAP 7 | ------------------------- 8 | 9 | 10 | NAME 11 | Start-UNMAP 12 | 13 | ÜBERSICHT 14 | Process SCSI UNMAP on VMware Datastores 15 | 16 | 17 | SYNTAX 18 | Start-UNMAP [-ClusterName] [-DSWildcard] [-WhatIf] [-Confirm] [] 19 | 20 | 21 | BESCHREIBUNG 22 | This Function will process SCSI UNMAP on VMware Datastores via ESXCLI -V2 23 | 24 | 25 | PARAMETER 26 | -ClusterName 27 | 28 | -DSWildcard 29 | 30 | -WhatIf [] 31 | 32 | -Confirm [] 33 | 34 | 35 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 36 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 37 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 38 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 39 | 40 | -------------------------- BEISPIEL 1 -------------------------- 41 | 42 | PS C:\>Start-UNMAP -ClusterName myCluster -DSWildcard *RAID5* 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------- BEISPIEL 2 -------------------------- 50 | 51 | PS C:\>Start-UNMAP -ClusterName myCluster -DSWildcard *RAID5* -Verbose -WhatIf 52 | 53 | 54 | 55 | 56 | 57 | 58 | HINWEISE 59 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Start-UNMAP -examples". 60 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Start-UNMAP -detailed". 61 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Start-UNMAP -full". 62 | Geben Sie zum Abrufen der Onlinehilfe Folgendes ein: "get-help Start-UNMAP -online" 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /doc/Features/cmd_konfig.rst: -------------------------------------------------------------------------------- 1 | Konfig Commands 2 | ========================= 3 | 4 | This page contains details on **Konfig** commands. 5 | 6 | Konfig-ESXi 7 | ------------------------- 8 | 9 | 10 | NAME 11 | Konfig-ESXi 12 | 13 | ÜBERSICHT 14 | 15 | 16 | SYNTAX 17 | Konfig-ESXi [-VMHost] [-NTP] [-syslog] [] 18 | 19 | 20 | BESCHREIBUNG 21 | This Function sets the Basic settings for a new ESXi. 22 | 23 | * NTP 24 | * SSH 25 | * Syslog 26 | * Power Management 27 | * HP 3PAR SATP/PSP Rule 28 | * ... 29 | 30 | 31 | PARAMETER 32 | -VMHost 33 | Host to configure. 34 | 35 | -NTP 36 | NTP Server(s) to set. 37 | 38 | -syslog 39 | Syslog Server to set, e.g. "udp://loginsight.lan.local:514" 40 | 41 | DNS Name must be resolvable! 42 | 43 | 44 | #Requires PS -Version 4.0 45 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 46 | 47 | 48 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 49 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 50 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 51 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 52 | 53 | -------------------------- BEISPIEL 1 -------------------------- 54 | 55 | PS C:\>Konfig-ESXi -VMHost myesxi.lan.local -NTP 192.168.2.1, 192.168.2.2 -syslog "udp://loginsight.lan.local:514" 56 | 57 | 58 | 59 | 60 | 61 | 62 | HINWEISE 63 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Konfig-ESXi -examples". 64 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Konfig-ESXi -detailed". 65 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Konfig-ESXi -full". 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /doc/Features/cmd_recommend.rst: -------------------------------------------------------------------------------- 1 | Recommend Commands 2 | ========================= 3 | 4 | This page contains details on **Recommend** commands. 5 | 6 | Recommend-Sizing 7 | ------------------------- 8 | 9 | 10 | NAME 11 | Recommend-Sizing 12 | 13 | ÜBERSICHT 14 | 15 | 16 | SYNTAX 17 | Recommend-Sizing [-ClusterNames] [[-Stats]] [[-StatsRange] ] [] 18 | 19 | 20 | BESCHREIBUNG 21 | This Function collects Basic vSphere Informations for a Hardware Sizing Recommandation. Focus is in Compute Ressources. 22 | 23 | 24 | PARAMETER 25 | -ClusterNames 26 | List of your vSphere Cluser Names to process. 27 | 28 | -Stats [] 29 | Enables Stats Collection. 30 | 31 | Warning: At the moment this is only fully tested with vSphere 5.5 and vSphere 6.5! 32 | 33 | -StatsRange 34 | Time Range in Minutes for the Stats Collection. 35 | Default is 24h. 36 | 37 | #Requires PS -Version 4.0 38 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 39 | 40 | 41 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 42 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 43 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 44 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 45 | 46 | -------------------------- BEISPIEL 1 -------------------------- 47 | 48 | PS C:\>Recommend-Sizing -ClusterNames Cluster01, Cluster02 -Stats -StatsRange 60 -Verbose 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------- BEISPIEL 2 -------------------------- 56 | 57 | PS C:\>Recommend-Sizing -ClusterNames Cluster01, Cluster02 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------- BEISPIEL 3 -------------------------- 65 | 66 | PS C:\>Recommend-Sizing -ClusterNames Cluster01 67 | 68 | 69 | 70 | 71 | 72 | 73 | HINWEISE 74 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Recommend-Sizing -examples". 75 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Recommend-Sizing -detailed". 76 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Recommend-Sizing -full". 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /doc/Features/cmd_push.rst: -------------------------------------------------------------------------------- 1 | Push Commands 2 | ========================= 3 | 4 | This page contains details on **Push** commands. 5 | 6 | Push-vLIMessage 7 | ------------------------- 8 | 9 | 10 | NAME 11 | Push-vLIMessage 12 | 13 | ÜBERSICHT 14 | Push Messages to VMware vRealize Log Inisght. 15 | 16 | 17 | SYNTAX 18 | Push-vLIMessage [-Text] [-vLIServer] [-vLIAgentID] [[-Hostname] ] [[-FieldName] ] [[-FieldContent] ] [] 19 | 20 | 21 | BESCHREIBUNG 22 | Push Messages to VMware vRealize Log Inisght. 23 | 24 | 25 | PARAMETER 26 | -Text 27 | Specify the Event Text 28 | 29 | -vLIServer 30 | Specify the vLI FQDN 31 | 32 | -vLIAgentID 33 | Specify the vLI Agent ID 34 | 35 | -Hostname 36 | Specify the Hostanme displayed in vLI 37 | 38 | -FieldName 39 | Specify the a Optinal Field Name for vLI 40 | 41 | -FieldContent 42 | Specify the a Optinal FieldContent for the Field in -FieldName for vLI 43 | If FielName is missing and FielContent is given, it will be ignored 44 | 45 | 46 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 47 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 48 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 49 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 50 | 51 | -------------------------- BEISPIEL 1 -------------------------- 52 | 53 | PS C:\>Push-vLIMessage -vLIServer "loginsight.lan.local -vLIAgentID "12862842-5A6D-679C-0E38-0E2BE888BB28" -Text "My Test" 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------- BEISPIEL 2 -------------------------- 61 | 62 | PS C:\>Push-vLIMessage -vLIServer "loginsight.lan.local -vLIAgentID "12862842-5A6D-679C-0E38-0E2BE888BB28" -Text "My Test" -Hostname MyTEST -FieldName myTest -FieldContent myTest 63 | 64 | 65 | 66 | 67 | 68 | 69 | HINWEISE 70 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Push-vLIMessage -examples". 71 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Push-vLIMessage -detailed". 72 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Push-vLIMessage -full". 73 | Geben Sie zum Abrufen der Onlinehilfe Folgendes ein: "get-help Push-vLIMessage -online" 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /Validate-ESXiPackages.psm1: -------------------------------------------------------------------------------- 1 | function Validate-ESXiPackages { 2 | <# 3 | .DESCRIPTION 4 | Compares all ESXi Host VIBs within a vSphere with a reference Hosts. 5 | 6 | .NOTES 7 | File Name : Validate-ESXiPackages.ps1 8 | Author : Markus Kraus 9 | Version : 1.0 10 | State : Ready 11 | 12 | Tested Against Environment: 13 | 14 | vSphere Version: 6.0 U2, 6.5 U1 15 | PowerCLI Version: PowerCLI 10.0.0 build 7895300 16 | PowerShell Version: 4.0 17 | OS Version: Windows Server 2012 R2 18 | 19 | .LINK 20 | https://mycloudrevolution.com/ 21 | 22 | .EXAMPLE 23 | Validate-ESXiPackages -Cluster (Get-Cluster) -RefernceHost (Get-VMHost | Select-Object -First 1) 24 | 25 | .PARAMETER Cluster 26 | vSphere Cluster to verify 27 | 28 | .PARAMETER RefernceHost 29 | The VIB Reference ESXi Host 30 | #> 31 | 32 | [CmdletBinding()] 33 | param( 34 | [Parameter(Mandatory=$True, ValueFromPipeline=$True, HelpMessage="vSphere Cluster to verify")] 35 | [ValidateNotNullorEmpty()] 36 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.ComputeResourceImpl] $Cluster, 37 | [Parameter(Mandatory=$True, ValueFromPipeline=$false, HelpMessage="The VIB Reference ESXi Host")] 38 | [ValidateNotNullorEmpty()] 39 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl] $RefernceHost 40 | ) 41 | 42 | Process { 43 | 44 | #region: Get reference VIBs 45 | $EsxCli2 = Get-ESXCLI -VMHost $RefernceHost -V2 46 | $RefernceVibList = $esxcli2.software.vib.list.invoke() 47 | #endregion 48 | 49 | #region: Compare reference VIBs 50 | $MyView = @() 51 | foreach ($VmHost in ($Cluster | Get-VMHost)) { 52 | 53 | $EsxCli2 = Get-ESXCLI -VMHost $VmHost -V2 54 | $VibList = $esxcli2.software.vib.list.invoke() 55 | [Array]$VibDiff = Compare-Object -ReferenceObject $RefernceVibList.ID -DifferenceObject $VibList.ID 56 | 57 | if($VibDiff.Count -gt 0) { 58 | $VibDiffSideIndicator = @() 59 | foreach ($Item in $VibDiff) { 60 | $VibDiffSideIndicator += $($Item.SideIndicator + " " + $Item.InputObject) 61 | } 62 | } 63 | else { 64 | $VibDiffSideIndicator = $null 65 | } 66 | 67 | $Report = [PSCustomObject] @{ 68 | Host = $VmHost.Name 69 | Version = $VmHost.Version 70 | Build = $VmHost.Build 71 | VibDiffCount = $VibDiff.Count 72 | VibDiff = $VibDiff.InputObject 73 | VibDiffSideIndicator = $VibDiffSideIndicator 74 | } 75 | $MyView += $Report 76 | 77 | } 78 | #region: Compare reference VIBs 79 | 80 | $MyView 81 | } 82 | } -------------------------------------------------------------------------------- /Get-NICDetails.psm1: -------------------------------------------------------------------------------- 1 | function Get-NICDetails { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Markus Kraus 6 | Twitter: @VMarkus_K 7 | Private Blog: mycloudrevolution.com 8 | =========================================================================== 9 | Changelog: 10 | 2017.02 ver 1.0 Base Release 11 | =========================================================================== 12 | External Code Sources: 13 | - 14 | =========================================================================== 15 | Tested Against Environment: 16 | vSphere Version: ESXi 6.0 U2, ESXi 6.5 17 | PowerCLI Version: PowerCLI 6.3 R1, PowerCLI 6.5 R1 18 | PowerShell Version: 4.0, 5.0 19 | OS Version: Windows 8.1, Server 2008 R2, Server 2012 R2 20 | Keyword: ESXi, NIC, vmnic, Driver, Firmware 21 | =========================================================================== 22 | 23 | .DESCRIPTION 24 | Reports Firmware and Driver Details for your ESXi vmnics. 25 | 26 | .Example 27 | Get-NICDetails -Clustername * 28 | 29 | .PARAMETER Clustername 30 | Name or Wildcard of your vSphere Cluster Name to process. 31 | 32 | 33 | #Requires PS -Version 4.0 34 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 35 | #> 36 | 37 | [CmdletBinding()] 38 | param( 39 | [Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)] 40 | [ValidateNotNullorEmpty()] 41 | [String] $Clustername 42 | 43 | ) 44 | 45 | Begin { 46 | $Validate = $True 47 | 48 | if (($myCluster = Get-Cluster -Name $Clustername).count -lt 1) { 49 | $Validate = $False 50 | thow "No Cluster '$myCluster' found!" 51 | } 52 | 53 | } 54 | 55 | Process { 56 | 57 | $MyView = @() 58 | if ($Validate -eq $True) { 59 | 60 | foreach ($myVMhost in ($myCluster | Get-VMHost)) { 61 | 62 | $esxcli2 = Get-ESXCLI -VMHost $myVMhost -V2 63 | $niclist = $esxcli2.network.nic.list.invoke() 64 | 65 | $nicdetails = @() 66 | foreach ($nic in $niclist) { 67 | 68 | $args = $esxcli2.network.nic.get.createargs() 69 | $args.nicname = $nic.name 70 | $nicdetail = $esxcli2.network.nic.get.Invoke($args) 71 | $nicdetails += $nicdetail 72 | 73 | } 74 | ForEach ($nicdetail in $nicdetails){ 75 | $NICReport = [PSCustomObject] @{ 76 | Host = $myVMhost.Name 77 | vmnic = $nicdetail.Name 78 | LinkStatus = $nicdetail.LinkStatus 79 | BusInfo = $nicdetail.driverinfo.BusInfo 80 | Driver = $nicdetail.driverinfo.Driver 81 | FirmwareVersion = $nicdetail.driverinfo.FirmwareVersion 82 | DriverVersion = $nicdetail.driverinfo.Version 83 | } 84 | $MyView += $NICReport 85 | } 86 | 87 | } 88 | 89 | $MyView 90 | 91 | } 92 | } 93 | } -------------------------------------------------------------------------------- /Apply-Hardening.psm1: -------------------------------------------------------------------------------- 1 | function Apply-Hardening { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Markus Kraus 6 | Twitter: @VMarkus_K 7 | Private Blog: mycloudrevolution.com 8 | =========================================================================== 9 | Changelog: 10 | 2016.11 ver 2.0 Base Release 11 | =========================================================================== 12 | External Code Sources: 13 | 14 | =========================================================================== 15 | Tested Against Environment: 16 | vSphere Version: 5.5 U2 17 | PowerCLI Version: PowerCLI 6.3 R1, PowerCLI 6.5 R1 18 | PowerShell Version: 4.0, 5.0 19 | OS Version: Windows 8.1, Server 2012 R2 20 | Keyword: VM, Hardening, Security 21 | =========================================================================== 22 | 23 | .DESCRIPTION 24 | Applys a set of Hardening options to your VMs 25 | 26 | .Example 27 | Get-VM TST* | Apply-Hardening 28 | 29 | .Example 30 | $SampleVMs = Get-VM "TST*" 31 | Apply-Hardening -VMs $SampleVMs 32 | 33 | .PARAMETER VMs 34 | Specify the VMs 35 | 36 | 37 | #Requires PS -Version 4.0 38 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 39 | #> 40 | 41 | [CmdletBinding()] 42 | param( 43 | [Parameter(Mandatory=$true, 44 | ValueFromPipeline=$True, 45 | Position=0)] 46 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] 47 | $VMs 48 | ) 49 | 50 | Process { 51 | #region: Create Options 52 | $ExtraOptions = @{ 53 | "isolation.tools.diskShrink.disable"="true"; 54 | "isolation.tools.diskWiper.disable"="true"; 55 | "isolation.tools.copy.disable"="true"; 56 | "isolation.tools.paste.disable"="true"; 57 | "isolation.tools.dnd.disable"="true"; 58 | "isolation.tools.setGUIOptions.enable"="false"; 59 | "log.keepOld"="10"; 60 | "log.rotateSize"="100000" 61 | "RemoteDisplay.maxConnections"="2"; 62 | "RemoteDisplay.vnc.enabled"="false"; 63 | 64 | } 65 | if ($DebugPreference -eq "Inquire") { 66 | Write-Output "VM Hardening Options:" 67 | $ExtraOptions | Format-Table -AutoSize 68 | } 69 | 70 | $VMConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec 71 | 72 | Foreach ($Option in $ExtraOptions.GetEnumerator()) { 73 | $OptionValue = New-Object VMware.Vim.optionvalue 74 | $OptionValue.Key = $Option.Key 75 | $OptionValue.Value = $Option.Value 76 | $VMConfigSpec.extraconfig += $OptionValue 77 | } 78 | #endregion 79 | 80 | #region: Apply Options 81 | ForEach ($VM in $VMs){ 82 | $VMv = Get-VM $VM | Get-View 83 | $state = $VMv.Summary.Runtime.PowerState 84 | Write-Output "...Starting Reconfiguring VM: $VM " 85 | $TaskConf = ($VMv).ReconfigVM_Task($VMConfigSpec) 86 | if ($state -eq "poweredOn") { 87 | Write-Output "...Migrating VM: $VM " 88 | $TaskMig = $VMv.MigrateVM_Task($null, $_.Runtime.Host, 'highPriority', $null) 89 | } 90 | } 91 | } 92 | #endregion 93 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | vSphere Modules 2 | =============== 3 | [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=vMarkus_K&url=https://github.com/mycloudrevolution/vSphere-Modules&title=vSphere-Modules&language=Powershell&tags=github&category=software) 4 | 5 | # About 6 | 7 | ## Project Owner: 8 | 9 | Markus Kraus [@vMarkus_K](https://twitter.com/vMarkus_K) 10 | 11 | MY CLOUD-(R)EVOLUTION [mycloudrevolution.com](http://mycloudrevolution.com/) 12 | 13 | ## Project Description 14 | 15 | This Repository contains a collection of my VMware vSphere Functions. 16 | 17 | # Modules 18 | 19 | ## Get-VMID.psm1 20 | 21 | This Funcion will quickly return all IDs of VMs. 22 | 23 | ![Get-VMID](/Media/Get-VMID.png) 24 | 25 | ## Get-VMmaxIOPS.psm1 26 | 27 | This Function will Create a VM Disk IOPS Report. 28 | 29 | ![Get-VMmaxIOPS](/Media/Get-VMmaxIOPS.png) 30 | 31 | ## Push-vLIMessage.psm1 32 | 33 | Push Messages to VMware vRealize Log Inisght. 34 | 35 | ## Set-ConsolidationFix.psm1 36 | 37 | Set VM SnapShot Consolidation Timout Workaround. 38 | 39 | ## Start-UNMAP.psm1 40 | 41 | Process SCSI UNMAP on VMware Datastores. 42 | 43 | ![Start-UNMAP](/Media/Start-UNMAP.png) 44 | 45 | ## Get-VMDisk.psm1 46 | 47 | This Function reports VM vDisks and Datastores. 48 | 49 | ![Get-VMDisk](/Media/Get-VMDisk.png) 50 | 51 | ## Apply-Hardening.psm1 52 | 53 | Applys a set of Hardening options to the VMss 54 | 55 | ![Apply-Hardening](/Media/Apply-Hardening.png) 56 | 57 | ## Set-IOPSLimit.psm1 58 | 59 | Report and Set VM Disk IO Limits 60 | 61 | ![Set-IOPSLimit](/Media/Set-IOPSLimit.png) 62 | 63 | ## Set-CBT.psm1 64 | 65 | This Function enables or disables CBT. In addition a new VI-Property is added. 66 | 67 | ![Set-CBT](/Media/Set-CBT.png) 68 | 69 | ![Set-CBT_VI-Property](/Media/Set-CBT_VI-Property.png) 70 | 71 | ## Recommend-Sizing.psm1 72 | 73 | This Function collects Basic vSphere Informations for a Hardware Sizing Recommandation. Focus is in Compute Ressources. 74 | 75 | ![Set-IOPSLimit](/Media/Recommend-Sizing.png) 76 | 77 | ## Konfig-ESXi.psm1 78 | 79 | This Function sets the Basic settings for a new ESXi. 80 | 81 | ![Konfig-ESXi](/Media/Konfig-ESXi.png) 82 | 83 | ## Get-NewVMs.psm1 84 | 85 | This Function report newly created VMs by Cluster. 86 | 87 | Prease use the enhanced version "Get-NewAndRemovedVMs" insted! 88 | 89 | ![Get-NewVMs](/Media/Get-NewVMs.png) 90 | 91 | ## Get-NewAndRemovedVMs.psm1 92 | 93 | This Function report newly created VMs by Cluster. 94 | 95 | ![Get-NewAndRemovedVMs](/Media/Get-NewAndRemovedVMs.png) 96 | 97 | ## Get-NICDetails.psm1 98 | 99 | This Function reports Firmware and Driver Details for your ESXi vmnic(s). 100 | 101 | ![Get-NICDetails](/Media/Get-NICDetails.png) 102 | 103 | ## Get-UplinkDetails.psm1 104 | 105 | This Function collects detailed informations about your ESXi Host connections to pSwitch and DVS / vSwitch. 106 | 107 | ![Get-UplinkDetails](/Media/Get-UplinkDetails.png) 108 | 109 | ## Validate-ESXiPackages.psm1 110 | 111 | This Function compares all ESXi Host VIBs within a vSphere with a reference Hosts. 112 | 113 | ![Validate-ESXiPackages](/Media/Validate-ESXiPackages.png) -------------------------------------------------------------------------------- /Get-VMDisk.psm1: -------------------------------------------------------------------------------- 1 | function Get-VMDisk { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Markus Kraus 6 | Twitter: @VMarkus_K 7 | Private Blog: mycloudrevolution.com 8 | =========================================================================== 9 | Changelog: 10 | 2016.09 ver 1.0 Base Release 11 | 2016.11 ver 1.1 VM pipe 12 | 2020.02 ver 1.2 Add SCSI ID 13 | =========================================================================== 14 | External Code Sources: 15 | http://www.lucd.info/2011/04/22/get-the-maximum-iops/ 16 | =========================================================================== 17 | Tested Against Environment: 18 | vSphere Version: 6.7 U3 19 | PowerCLI Version: PowerCLI 11.5 20 | PowerShell Version: 5.1, 6.1 21 | OS Version: Windows 2016, Windows 10 22 | =========================================================================== 23 | Keywords vSphere, ESXi, VM, vDisk 24 | =========================================================================== 25 | 26 | .Description 27 | This Function reports VM vDisks and Datastores: 28 | 29 | Get-VM MyTest | Get-VMDisk | Format-Table -AutoSize 30 | 31 | Name PowerState Datastore Path Disk StorageFormat CapacityGB Controller Unit 32 | ---- ---------- --------- ---- ---- ------------- ---------- ---------- ---- 33 | MyTest PoweredOff data01 MyTest/MyTest.vmdk Hard disk 1 Thin 16 0 0 34 | MyTest PoweredOff data02 MyTest/MyTest_1.vmdk Hard disk 2 Thin 20 1 0 35 | MyTest PoweredOff data01 MyTest/MyTest_2.vmdk Hard disk 3 Thick 20 1 1 36 | 37 | .Example 38 | Get-VM -Name TST* | Get-VMDisk 39 | 40 | .Example 41 | Get-Folder -Name TST | Get-VM | Get-VMDisk | ft -AutoSize 42 | 43 | #Requires PS -Version 5.0 44 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 45 | #> 46 | 47 | [CmdletBinding()] 48 | param( 49 | [Parameter(Mandatory=$True, ValueFromPipeline=$True, Position=0, HelpMessage = "VMs to process")] 50 | [ValidateNotNullorEmpty()] 51 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] $myVMs 52 | ) 53 | Process { 54 | $View = @() 55 | foreach ($myVM in $myVMs){ 56 | $VMDKs = $myVM | get-HardDisk 57 | foreach ($VMDK in $VMDKs) { 58 | if ($VMDK -ne $null){ 59 | [int]$CapacityGB = $VMDK.CapacityKB/1024/1024 60 | $Report = [PSCustomObject] @{ 61 | Name = $myVM.name 62 | PowerState = $myVM.PowerState 63 | Datastore = $VMDK.FileName.Split(']')[0].TrimStart('[') 64 | Path = $VMDK.FileName.Split(']')[1].TrimStart('[') 65 | Disk = $VMDK.Name 66 | StorageFormat = $VMDK.StorageFormat 67 | CapacityGB = $CapacityGB 68 | Controller = $VMDK.ExtensionData.ControllerKey -1000 69 | Unit = $VMDK.ExtensionData.UnitNumber 70 | } 71 | $View += $Report 72 | } 73 | } 74 | } 75 | $View | Sort-Object VMname, Controller, Unit 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Start-UNMAP.psm1: -------------------------------------------------------------------------------- 1 | function Start-UNMAP { 2 | <# 3 | .SYNOPSIS 4 | Process SCSI UNMAP on VMware Datastores 5 | 6 | .DESCRIPTION 7 | This Function will process SCSI UNMAP on VMware Datastores via ESXCLI -V2 8 | 9 | .Example 10 | Start-UNMAP -ClusterName myCluster -DSWildcard *RAID5* 11 | 12 | .Example 13 | Start-UNMAP -ClusterName myCluster -DSWildcard *RAID5* -Verbose -WhatIf 14 | 15 | .Notes 16 | NAME: Start-UNMAP.psm1 17 | AUTHOR: Markus Kraus 18 | LASTEDIT: 23.09.2016 19 | VERSION: 1.0 20 | KEYWORDS: VMware, vSphere, ESXi, SCSI, VAAI, UNMAP 21 | 22 | .Link 23 | http://mycloudrevolution.com/ 24 | 25 | #Requires PS -Version 4.0 26 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 27 | #> 28 | 29 | [CmdletBinding(SupportsShouldProcess = $true,ConfirmImpact='High')] 30 | param( 31 | [Parameter(Mandatory=$true, Position=0)] 32 | [String]$ClusterName, 33 | [Parameter(Mandatory=$true, Position=1)] 34 | [String]$DSWildcard 35 | ) 36 | Process { 37 | $Validate = $true 38 | #region: PowerCLI Session Timeout 39 | Write-Verbose "Set Session Timeout ..." 40 | $initialTimeout = (Get-PowerCLIConfiguration -Scope Session).WebOperationTimeoutSeconds 41 | Set-PowerCLIConfiguration -Scope Session -WebOperationTimeoutSeconds -1 -Confirm:$False | Out-Null 42 | #endregion 43 | 44 | #region: Get Cluster 45 | $Cluster = Get-Cluster -Name $ClusterName -ErrorAction SilentlyContinue 46 | Write-Verbose "vSphere Cluster: $Cluster" 47 | if (!$Cluster){Write-Error "No Cluster found!"; $Validate = $false} 48 | #endregion 49 | 50 | #region: Get Hosts 51 | $ClusterHosts = $Cluster | Get-VMHost -ErrorAction SilentlyContinue | where {$_.ConnectionState -eq "Connected" -and $_.PowerState -eq "PoweredOn"} 52 | Write-Verbose "vSphere Cluster Hosts: $ClusterHosts" 53 | if (!$ClusterHosts){Write-Error "No Hosts found!"; $Validate = $false} 54 | #endregion 55 | 56 | #region: Get Datastores 57 | $ClusterDataStores = $Cluster | Get-Datastore -ErrorAction SilentlyContinue | where {$_.Name -like $DSWildcard -and $_.State -eq "Available" -and $_.Accessible -eq "True"} 58 | Write-Verbose "vSphere Cluster Datastores: $ClusterDataStores" 59 | if (!$ClusterDataStores){Write-Error "No Datastores found!"; $Validate = $false} 60 | #endregion 61 | 62 | #region: Process Datastores 63 | if ($Validate -eq $true) { 64 | Write-Verbose "Starting Loop..." 65 | foreach ($ClusterDataStore in $ClusterDataStores) { 66 | Write-Verbose "vSphere Datastore to Process: $ClusterDataStore" 67 | $myHost = $ClusterHosts[(Get-Random -Maximum ($ClusterHosts).count)] 68 | Write-Verbose "vSphere Host to Process: $myHost" 69 | $esxcli2 = $myHost | Get-ESXCLI -V2 70 | $arguments = $esxcli2.storage.vmfs.unmap.CreateArgs() 71 | $arguments.volumelabel = $ClusterDataStore 72 | $arguments.reclaimunit = "256" 73 | if ($PSCmdlet.ShouldProcess( $ClusterDataStore,"Starting UNMAP on $myHost")) { 74 | $stopwatch = [System.Diagnostics.Stopwatch]::StartNew() 75 | try { 76 | Write-Output "Starting UNMAP for $ClusterDataStore on $myHost..." 77 | $esxcli2.storage.vmfs.unmap.Invoke($arguments) 78 | } 79 | catch { 80 | Write-Output "A Error occured: " "" $error[0] "" 81 | } 82 | $stopwatch.Stop() 83 | Write-Output "UNMAP duration: $($stopwatch.Elapsed.Minutes)" 84 | } 85 | 86 | } 87 | } 88 | else { 89 | Write-Error "Validation Failed. Processing Loop Skipped!" 90 | } 91 | #endregion 92 | 93 | #region: Revert PowerCLI Session Timeout 94 | Write-Verbose "Revert Session Timeout ..." 95 | Set-PowerCLIConfiguration -Scope Session -WebOperationTimeoutSeconds $initialTimeout -Confirm:$False | Out-Null 96 | #endregion 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /Get-VMmaxIOPS.psm1: -------------------------------------------------------------------------------- 1 | function Get-VMmaxIOPS { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Markus Kraus 6 | Twitter: @VMarkus_K 7 | Private Blog: mycloudrevolution.com 8 | =========================================================================== 9 | Changelog: 10 | 2016.08 ver 1.0 Base Release 11 | 2016.11 ver 1.1 New Counters 12 | =========================================================================== 13 | External Code Sources: 14 | http://www.lucd.info/2011/04/22/get-the-maximum-iops/ 15 | https://communities.vmware.com/thread/485386 16 | =========================================================================== 17 | Tested Against Environment: 18 | vSphere Version: 5.5 U2, 6.5 19 | PowerCLI Version: PowerCLI 6.3 R1, PowerCLI 6.5 R1 20 | PowerShell Version: 4.0, 5.0 21 | OS Version: Windows 8.1, Server 2012 R2 22 | =========================================================================== 23 | Keywords vSphere, ESXi, VM, Storage, Sizing 24 | =========================================================================== 25 | 26 | .DESCRIPTION 27 | This Function will Create a VM Disk IOPS Report 28 | 29 | .Example 30 | Get-Folder -Name TST | Get-VM | where {$_.PowerState -eq "PoweredOn"} | Get-VMmaxIOPS -Minutes 120 | ft -AutoSize 31 | 32 | .Example 33 | Get-Cluster -Name TST | Get-VM | where {$_.PowerState -eq "PoweredOn"} | Get-VMmaxIOPS 34 | 35 | .Example 36 | Get-VM -Name TST*| where {$_.PowerState -eq "PoweredOn"} | Get-VMmaxIOPS -Minutes 120 | ft -AutoSize 37 | 38 | .PARAMETER VMs 39 | Specify the VMs 40 | 41 | .PARAMETER Minutes 42 | Time Range in Minutes for the Stats Collection. 43 | Default is 30 Minutes. 44 | 45 | #Requires PS -Version 4.0 46 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 47 | #> 48 | 49 | [CmdletBinding()] 50 | param( 51 | [Parameter(Mandatory=$true, ValueFromPipeline=$True, Position=0)] 52 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] 53 | $VMs, 54 | [Parameter(Mandatory=$false, Position=1)] 55 | [int] $Minutes = 30 56 | ) 57 | 58 | Process { 59 | if ($_.PowerState -eq "PoweredOn") { 60 | #region: Global Definitions 61 | [int]$TimeRange = "-" + $Minutes 62 | #endregion 63 | 64 | #region: Creating VM Stats 65 | $VMMetrics = "virtualDisk.numberReadAveraged.average","virtualDisk.numberWriteAveraged.average" 66 | $Start = (Get-Date).AddMinutes($TimeRange) 67 | $VMStats = Get-Stat -Realtime -Stat $VMMetrics -Entity $VMs -Start $Start -Verbose:$False 68 | #endregion 69 | 70 | #region: Creating HD-Tab 71 | $hdTab = @{} 72 | foreach($hd in (Get-Harddisk -VM $VMs)){ 73 | $controllerKey = $hd.Extensiondata.ControllerKey 74 | $controller = $hd.Parent.Extensiondata.Config.Hardware.Device | where{$_.Key -eq $controllerKey} 75 | $hdTab[$hd.Parent.Name + "/scsi" + $controller.BusNumber + ":" + $hd.Extensiondata.UnitNumber] = $hd.FileName.Split(']')[0].TrimStart('[') 76 | } 77 | #endregion 78 | 79 | #region: Creating Reports 80 | $reportPerf = @() 81 | $reportPerf = $VMStats | Group-Object -Property {$_.Entity.Name},Instance | %{ 82 | New-Object PSObject -Property @{ 83 | VM = $_.Values[0] 84 | Disk = $_.Values[1] 85 | IOPSWriteAvg = [math]::round( ($_.Group | ` 86 | where{$_.MetricId -eq "virtualDisk.numberWriteAveraged.average"} | ` 87 | Measure-Object -Property Value -Maximum).Maximum ,2) 88 | IOPSReadAvg = [math]::round( ($_.Group | ` 89 | where{$_.MetricId -eq "virtualDisk.numberReadAveraged.average"} | ` 90 | Measure-Object -Property Value -Maximum).Maximum ,2) 91 | Datastore = $hdTab[$_.Values[0] + "/"+ $_.Values[1]] 92 | } 93 | } 94 | } 95 | Else { 96 | Write-Error "VM $($_.Name) is Powered Off! IOPS Processing Skipped" 97 | } 98 | $reportPerf | Select-Object VM, Disk, Datastore, IOPSWriteAvg, IOPSReadAvg 99 | #endregion 100 | } 101 | } -------------------------------------------------------------------------------- /Helper/Update-ModuleManifestData.psm1: -------------------------------------------------------------------------------- 1 | <# 2 | 3 | .SYNOPSIS 4 | Bump the version of a module manifest file 5 | 6 | .DESCRIPTION 7 | Increment the version number of a module manifest file by following the Semantic Versioning standard -> http://semver.org/ 8 | 9 | It is possible to update either the MAJOR,MINOR or PATCH patch version of the module depending on what changes have been made 10 | to the module. 11 | 12 | Updates FunctionsToExport and NestedModules. 13 | 14 | .PARAMETER Path 15 | The path to the module manifest file 16 | 17 | .PARAMETER Major 18 | Increase the major version of the module by 1 19 | 20 | .PARAMETER Minor 21 | Increase the minor version of the module by 1 22 | 23 | .PARAMETER Patch 24 | Increase the patch version of the module by 1 25 | 26 | .EXAMPLE 27 | Update-ModuleManifestData -Path .\ModuleManifest.psd1 -Major 28 | 29 | .EXAMPLE 30 | Update-ModuleManifestData -Path .\ModuleManifest.psd1 -Minor 31 | 32 | .EXAMPLE 33 | Update-ModuleManifestData -Path .\ModuleManifest.psd1 -Patch 34 | 35 | #Requires PS -Version 5.0 36 | #> 37 | function Update-ModuleManifestData { 38 | 39 | [CmdletBinding()] 40 | 41 | Param ( 42 | 43 | [Parameter(Mandatory=$true)] 44 | [ValidateNotNullOrEmpty()] 45 | [String]$Path, 46 | 47 | [Parameter(Mandatory=$true, ParameterSetName="Major")] 48 | [ValidateNotNullOrEmpty()] 49 | [Switch]$Major, 50 | 51 | [Parameter(Mandatory=$true, ParameterSetName="Minor")] 52 | [ValidateNotNullOrEmpty()] 53 | [Switch]$Minor, 54 | 55 | [Parameter(Mandatory=$true, ParameterSetName="Patch")] 56 | [ValidateNotNullOrEmpty()] 57 | [Switch]$Patch 58 | 59 | ) 60 | 61 | Write-Verbose -Message "Working with manifest file $($Path)" 62 | 63 | if (!(Test-Path -Path $Path)) { 64 | 65 | throw "Could not find file: $($Path)" 66 | 67 | } 68 | 69 | $ModuleManifest = Get-Item -Path $Path 70 | $ResolvedPath = Resolve-Path -Path $Path -ErrorAction Stop | Select-Object -ExpandProperty Path 71 | 72 | Write-Verbose -Message "Resolved path: $($ResolvedPath)" 73 | $ModuleManifest_String = Invoke-Expression -Command (Get-Content -Path $ResolvedPath | Out-String) 74 | $CurrentModuleVersion = $ModuleManifest_String.ModuleVersion 75 | 76 | Write-Verbose -Message "Current module version is $($CurrentModuleVersion)" 77 | 78 | [Int]$MajorVersion = $CurrentModuleVersion.Split(".")[0] 79 | [Int]$MinorVersion = $CurrentModuleVersion.Split(".")[1] 80 | [Int]$PatchVersion = $CurrentModuleVersion.Split(".")[2] 81 | 82 | switch ($PSCmdlet.ParameterSetName) { 83 | 84 | 'Major' { 85 | 86 | Write-Verbose -Message "Bumping module major release number" 87 | 88 | $MajorVersion++ 89 | $MinorVersion = 0 90 | $PatchVersion = 0 91 | 92 | break 93 | 94 | } 95 | 96 | 'Minor' { 97 | 98 | Write-Verbose -Message "Bumping module minor release number" 99 | 100 | $MinorVersion++ 101 | $PatchVersion = 0 102 | 103 | break 104 | 105 | } 106 | 107 | 'Patch' { 108 | 109 | Write-Verbose -Message "Bumping module patch release number" 110 | 111 | $PatchVersion++ 112 | 113 | break 114 | } 115 | 116 | } 117 | $ModuleVersion = "$($MajorVersion).$($MinorVersion).$($PatchVersion)" 118 | 119 | Write-Verbose -Message "Module version updated to $($ModuleVersion)" 120 | 121 | Write-Verbose -Message "Searching for functions in $("$($ModuleManifest.DirectoryName)")" 122 | 123 | $ModuleRoot = $ModuleManifest.DirectoryName.Split("\")[-1] 124 | 125 | $Functions = Get-ChildItem -Path "$($ModuleManifest.DirectoryName)" -Filter '*.psm1' -Recurse | Sort-Object 126 | 127 | $FunctionsToExport = $Functions | Select-Object -ExpandProperty BaseName | Sort-Object 128 | $NestedModules = $Functions | % {$_.FullName.Substring($_.FullName.IndexOf($ModuleRoot)+$ModuleRoot.Length).Trim("\")} 129 | 130 | Write-Verbose -Message "Found $($Functions.Count) function(s)" 131 | $FunctionsToExport 132 | 133 | if (!$Functions) { 134 | 135 | throw "No functions found" 136 | 137 | } 138 | 139 | Update-ModuleManifest -Path $Path -ModuleVersion $ModuleVersion -NestedModules $NestedModules -FunctionsToExport $FunctionsToExport -CmdletsToExport * -AliasesToExport * -VariablesToExport * -Verbose:$VerbosePreference 140 | 141 | } -------------------------------------------------------------------------------- /Get-UplinkDetails.psm1: -------------------------------------------------------------------------------- 1 | function Get-UplinkDetails { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Markus Kraus 6 | Twitter: @VMarkus_K 7 | Private Blog: mycloudrevolution.com 8 | =========================================================================== 9 | Changelog: 10 | 2017.03 ver 1.0 Base Release 11 | =========================================================================== 12 | External Code Sources: 13 | Get-CDP Version from @LucD22 14 | https://communities.vmware.com/thread/319553 15 | =========================================================================== 16 | Tested Against Environment: 17 | vSphere Version: vSphere 6.0 U2 18 | PowerCLI Version: PowerCLI 6.3 R1 19 | PowerShell Version: 4.0 20 | OS Version: Server 2012 R2 21 | Keyword: ESXi, Network, CDP, DVS, vSwitch, VMNIC 22 | =========================================================================== 23 | 24 | .DESCRIPTION 25 | This Function collects detailed informations about your ESXi Host connections to pSwitch and DVS / vSwitch 26 | 27 | .Example 28 | Get-UplinkDetails -Clustername * | ft -AutoSize 29 | 30 | .Example 31 | Get-UplinkDetails -Clustername MyCluster001 | ft -AutoSize 32 | 33 | .Example 34 | Get-UplinkDetails -Clustername MyCluster* | Sort Clustername, Hostname, DVS | ft -AutoSize 35 | 36 | .PARAMETER Clustername 37 | Your vSphere Cluster Name or Wildcard 38 | 39 | 40 | #Requires PS -Version 4.0 41 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 42 | #> 43 | 44 | [CmdletBinding()] 45 | param( 46 | [Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)] 47 | [String] $Clustername 48 | 49 | ) 50 | 51 | Begin { 52 | $Validate = $True 53 | 54 | if (($myCluster = Get-Cluster -Name $Clustername).count -lt 1) { 55 | $Validate = $False 56 | throw "No Cluster '$myCluster' found" 57 | } 58 | if (($myHosts = $myCluster | Get-VMHost).count -lt 1) { 59 | $Validate = $False 60 | throw "No Hosts in Cluster '$myCluster' found" 61 | } 62 | 63 | function Get-CDP ($VMhost){ 64 | $VMhostProxySwitch = $VMhost.NetworkInfo.ExtensionData.ProxySwitch 65 | $VMhostSwitch = $VMhost.NetworkInfo.VirtualSwitch 66 | 67 | $objReport = @() 68 | $VMhost| %{Get-View $_.ID} | 69 | %{ Get-View $_.ConfigManager.NetworkSystem} | 70 | %{ foreach($physnic in $_.NetworkInfo.Pnic){ 71 | 72 | $obj = "" | Select-Object Clustername,Hostname,VMNIC,PCI,MAC,DVS,vSwitch,CDP_Port,CDP_Device,CDP_Address 73 | 74 | $pnicInfo = $_.QueryNetworkHint($physnic.Device) 75 | foreach($hint in $pnicInfo){ 76 | $obj.Clustername = $VMhost.parent.name 77 | $obj.Hostname = $VMhost.name 78 | $obj.VMNIC = $physnic.Device 79 | $obj.PCI = $physnic.PCI 80 | $obj.MAC = $physnic.Mac 81 | if ($backing = ($VMhostProxySwitch | where {$_.Spec.Backing.PnicSpec.PnicDevice -eq $physnic.Device}).DvsName) { 82 | $obj.DVS = $backing 83 | } else { 84 | $obj.DVS = "-No Backing-" 85 | } 86 | if ($backing = ($VMhostSwitch | where {$_.Nic -eq $physnic.Device}).Name) { 87 | $obj.vSwitch = $backing 88 | } else { 89 | $obj.vSwitch = "-No Backing-" 90 | } 91 | if( $hint.ConnectedSwitchPort ) { 92 | $obj.CDP_Port = $hint.ConnectedSwitchPort.PortId 93 | $obj.CDP_Device = $hint.ConnectedSwitchPort.DevId 94 | $obj.CDP_Address = $hint.ConnectedSwitchPort.Address 95 | } else { 96 | $obj.CDP_Port = "-No Info-" 97 | $obj.CDP_Device = "-No Info-" 98 | $obj.CDP_Address = "-No Info-" 99 | } 100 | 101 | 102 | } 103 | $objReport += $obj 104 | } 105 | } 106 | $objReport 107 | } 108 | 109 | } 110 | 111 | Process { 112 | 113 | $MyView = @() 114 | 115 | if ($Validate -eq $True) { 116 | 117 | foreach ($myHost in $myHosts) { 118 | 119 | $CDP = Get-CDP $myHost 120 | $MyView += $CDP 121 | 122 | } 123 | 124 | $MyView | Sort Clustername, Hostname, VMNIC 125 | 126 | } 127 | } 128 | } -------------------------------------------------------------------------------- /Set-CBT.psm1: -------------------------------------------------------------------------------- 1 | function Set-CBT { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Markus Kraus 6 | Twitter: @VMarkus_K 7 | Private Blog: mycloudrevolution.com 8 | =========================================================================== 9 | Changelog: 10 | 2016.11 ver 1.0 Base Release 11 | =========================================================================== 12 | External Code Sources: 13 | http://wahlnetwork.com/2015/12/01/change-block-tracking-cbt-powercli/ 14 | =========================================================================== 15 | Tested Against Environment: 16 | vSphere Version: 5.5 U2 17 | PowerCLI Version: PowerCLI 6.3 R1 18 | PowerShell Version: 4.0 19 | OS Version: Windows Server 2012 R2 20 | =========================================================================== 21 | Keywords vSphere, ESXi, VM, Storage, CBT, Backup 22 | =========================================================================== 23 | 24 | .DESCRIPTION 25 | This Function enables or disables CBT. 26 | 27 | .Example 28 | Get-VN TST* | Set-CBT -DisableCBT 29 | 30 | .Example 31 | Get-VN TST* | Set-CBT -EnableCBT 32 | 33 | .PARAMETER DisableCBT 34 | Disables CBT for any VMs found with it enabled 35 | 36 | .PARAMETER EnableCBT 37 | Enables CBT for any VMs found with it disabled 38 | 39 | #Requires PS -Version 4.0 40 | #> 41 | 42 | [CmdletBinding()] 43 | param( 44 | [Parameter(Mandatory=$True, ValueFromPipeline=$True, Position=0, HelpMessage = "VMs to process")] 45 | [ValidateNotNullorEmpty()] 46 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] $myVMs, 47 | [Parameter(Mandatory = $False,ValueFromPipeline=$False, Position = 1, HelpMessage = "Enables CBT for any VMs found with it disabled", ParameterSetName = "EnableCBT")] 48 | [ValidateNotNullorEmpty()] 49 | [Switch]$EnableCBT, 50 | [Parameter(Mandatory = $False,ValueFromPipeline=$False, Position = 1, HelpMessage = "Disables CBT for any VMs found with it enabled", ParameterSetName = "DisableCBT")] 51 | [ValidateNotNullorEmpty()] 52 | [Switch]$DisableCBT 53 | ) 54 | Process { 55 | 56 | $vmconfigspec = New-Object -TypeName VMware.Vim.VirtualMachineConfigSpec 57 | Write-Verbose -Message "Walking through given VMs" 58 | foreach($myVM in $myVMs) 59 | { 60 | if ($DisableCBT -and $myVM.ExtensionData.Config.ChangeTrackingEnabled -eq $true -and $myVM.ExtensionData.Snapshot -eq $null) 61 | { 62 | try 63 | { 64 | Write-Verbose -Message "Reconfiguring $($myVM.name) to disable CBT" -Verbose 65 | $vmconfigspec.ChangeTrackingEnabled = $false 66 | $myVM.ExtensionData.ReconfigVM($vmconfigspec) 67 | 68 | if ($myVM.PowerState -eq "PoweredOn" ) { 69 | Write-Verbose -Message "Creating a snapshot on $($myVM.name) to clear CBT file" -Verbose 70 | $SnapShot = New-Snapshot -VM $myVM -Name "CBT Cleanup" 71 | 72 | Write-Verbose -Message "Removing snapshot on $($myVM.name)" -Verbose 73 | $SnapShot| Remove-Snapshot -Confirm:$false 74 | } 75 | 76 | } 77 | catch 78 | { 79 | throw $myVM 80 | } 81 | } 82 | elseif ($EnableCBT -and $myVM.ExtensionData.Config.ChangeTrackingEnabled -eq $false -and $myVM.ExtensionData.Snapshot -eq $null) 83 | { 84 | Write-Verbose -Message "Reconfiguring $($myVM.name) to enable CBT" -Verbose 85 | $vmconfigspec.ChangeTrackingEnabled = $true 86 | $myVM.ExtensionData.ReconfigVM($vmconfigspec) 87 | 88 | if ($myVM.PowerState -eq "PoweredOn" ) { 89 | Write-Verbose -Message "Creating a snapshot on $($myVM.name) to Create CBT file" -Verbose 90 | $SnapShot = New-Snapshot -VM $myVM -Name "CBT Cleanup" 91 | 92 | Write-Verbose -Message "Removing snapshot on $($myVM.name)" -Verbose 93 | $SnapShot | Remove-Snapshot -Confirm:$false 94 | } 95 | } 96 | else 97 | { 98 | if ($myVM.ExtensionData.Snapshot -ne $null -and $EnableCBT) 99 | { 100 | Write-Warning -Message "Skipping $($myVM.name) - Snapshots found" 101 | } 102 | elseif ($myVM.ExtensionData.Snapshot -ne $null -and $DisableCBT) 103 | { 104 | Write-Warning -Message "Skipping $($myVM.name) - Snapshots found" 105 | } 106 | } 107 | } 108 | 109 | } 110 | } 111 | 112 | 113 | # Thanks to Luc's article: http://www.lucd.info/viproperties/ 114 | # Usage: Get-VM -Name TST* | select Name, CBTEnabled 115 | 116 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 117 | New-VIProperty -Name CBTEnabled -ObjectType VirtualMachine -ValueFromExtensionProperty "Config.ChangeTrackingEnabled" -Force -------------------------------------------------------------------------------- /Get-NewAndRemovedVMs.psm1: -------------------------------------------------------------------------------- 1 | function Get-NewAndRemovedVMs { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Markus Kraus 6 | Twitter: @VMarkus_K 7 | Private Blog: mycloudrevolution.com 8 | =========================================================================== 9 | Changelog: 10 | 2016.12 ver 1.0 Base Release 11 | 2017.01 ver 1.1 Added Summary 12 | =========================================================================== 13 | External Code Sources: 14 | https://github.com/alanrenouf/vCheck-vSphere 15 | =========================================================================== 16 | Tested Against Environment: 17 | vSphere Version: 5.5 U2, 6.5 18 | PowerCLI Version: PowerCLI 6.3 R1, PowerCLI 6.5 R1 19 | PowerShell Version: 4.0, 5.0 20 | OS Version: Windows 8.1, Server 2012 R2 21 | =========================================================================== 22 | Keywords vSphere, VM 23 | =========================================================================== 24 | 25 | .DESCRIPTION 26 | This Function report newly created and deleted VMs by Cluster. 27 | 28 | .Example 29 | Get-NewAndRemovedVMs -ClusterName Cluster* | ft -AutoSize 30 | 31 | .Example 32 | Get-NewAndRemovedVMs -ClusterName Cluster01 -Days 90 33 | 34 | .Example 35 | Get-NewAndRemovedVMs -ClusterName * -Days 90 -Summary 36 | 37 | .PARAMETER ClusterName 38 | Name or Wildcard of your vSphere Cluster Name(s) to report. 39 | 40 | .PARAMETER Summary 41 | Displays only a short summary instead of the whole report. 42 | 43 | .PARAMETER Day 44 | Range in Days to report. 45 | 46 | 47 | #Requires PS -Version 4.0 48 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 49 | #> 50 | 51 | param( 52 | [Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0, HelpMessage = "Name or Wildcard of your vSphere Cluster Name to report")] 53 | [ValidateNotNullorEmpty()] 54 | [String]$ClusterName, 55 | [Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=1, HelpMessage = "Displays only a summary")] 56 | [Switch]$Summary = $False, 57 | [Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=2, HelpMessage = "Range in Days to report")] 58 | [String]$Days = "30" 59 | ) 60 | Begin { 61 | If (!(Get-Cluster -Name $ClusterName -ErrorAction SilentlyContinue)) {throw "No vSphere Cluster matching the Name '$ClusterName' found."} 62 | function Get-VIEventPlus { 63 | 64 | param( 65 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]]$Entity, 66 | [string[]]$EventType, 67 | [DateTime]$Start, 68 | [DateTime]$Finish = (Get-Date), 69 | [switch]$Recurse, 70 | [string[]]$User, 71 | [Switch]$System, 72 | [string]$ScheduledTask, 73 | [switch]$FullMessage = $false, 74 | [switch]$UseUTC = $false 75 | ) 76 | 77 | process { 78 | $eventnumber = 100 79 | $events = @() 80 | $eventMgr = Get-View EventManager 81 | $eventFilter = New-Object VMware.Vim.EventFilterSpec 82 | $eventFilter.disableFullMessage = ! $FullMessage 83 | $eventFilter.entity = New-Object VMware.Vim.EventFilterSpecByEntity 84 | $eventFilter.entity.recursion = &{if($Recurse){"all"}else{"self"}} 85 | $eventFilter.eventTypeId = $EventType 86 | if($Start -or $Finish){ 87 | $eventFilter.time = New-Object VMware.Vim.EventFilterSpecByTime 88 | if($Start){ 89 | $eventFilter.time.beginTime = $Start 90 | } 91 | if($Finish){ 92 | $eventFilter.time.endTime = $Finish 93 | } 94 | } 95 | if($User -or $System){ 96 | $eventFilter.UserName = New-Object VMware.Vim.EventFilterSpecByUsername 97 | if($User){ 98 | $eventFilter.UserName.userList = $User 99 | } 100 | if($System){ 101 | $eventFilter.UserName.systemUser = $System 102 | } 103 | } 104 | if($ScheduledTask){ 105 | $si = Get-View ServiceInstance 106 | $schTskMgr = Get-View $si.Content.ScheduledTaskManager 107 | $eventFilter.ScheduledTask = Get-View $schTskMgr.ScheduledTask | 108 | where {$_.Info.Name -match $ScheduledTask} | 109 | Select -First 1 | 110 | Select -ExpandProperty MoRef 111 | } 112 | if(!$Entity){ 113 | $Entity = @(Get-Folder -NoRecursion) 114 | } 115 | $entity | %{ 116 | $eventFilter.entity.entity = $_.ExtensionData.MoRef 117 | $eventCollector = Get-View ($eventMgr.CreateCollectorForEvents($eventFilter)) 118 | $eventsBuffer = $eventCollector.ReadNextEvents($eventnumber) 119 | while($eventsBuffer){ 120 | $events += $eventsBuffer 121 | $eventsBuffer = $eventCollector.ReadNextEvents($eventnumber) 122 | } 123 | $eventCollector.DestroyCollector() 124 | } 125 | if (-not $UseUTC) 126 | { 127 | $events | % { $_.createdTime = $_.createdTime.ToLocalTime() } 128 | } 129 | 130 | $events 131 | } 132 | } 133 | } 134 | 135 | process { 136 | $result = Get-VIEventPlus -Start ((get-date).adddays(-$Days)) -EventType @("VmCreatedEvent", "VmBeingClonedEvent", "VmBeingDeployedEvent","VmRemovedEvent") 137 | $sortedResult = $result | Select CreatedTime, @{N='Cluster';E={$_.ComputeResource.Name}}, @{Name="VMName";Expression={$_.vm.name}}, UserName, @{N='Type';E={$_.GetType().Name}}, FullFormattedMessage | Sort CreatedTime 138 | $Output = $sortedResult | where {$_.Cluster -like $ClusterName} 139 | 140 | } 141 | end { 142 | If ($Summary) { 143 | 144 | $Created = [Array]$($Output | Where-Object {$_.Type -like "VmCreatedEvent"}) 145 | $Cloned = [Array]$($Output | Where-Object {$_.Type -like "VmBeingClonedEvent"}) 146 | $Deployed = [Array]$($Output | Where-Object {$_.Type -like "VmBeingDeployedEvent"}) 147 | $Removed = [Array]$($Output | Where-Object {$_.Type -like "VmRemovedEvent"}) 148 | 149 | $Report = [PSCustomObject] @{ 150 | Created = ($Created).count 151 | Cloned = ($Cloned).count 152 | Deployed = ($Deployed).count 153 | Removed = ($Removed).count 154 | 155 | } 156 | $Report 157 | } 158 | else { 159 | $Output 160 | } 161 | } 162 | } -------------------------------------------------------------------------------- /vSphere-Modules.psd1: -------------------------------------------------------------------------------- 1 | # 2 | # Modulmanifest f�r das Modul "PSGet_vSphere-Modules" 3 | # 4 | # Generiert von: Markus Kraus 5 | # 6 | # Generiert am: 25.06.2020 7 | # 8 | 9 | @{ 10 | 11 | # Die diesem Manifest zugeordnete Skript- oder Bin�rmoduldatei. 12 | # RootModule = '' 13 | 14 | # Die Versionsnummer dieses Moduls 15 | ModuleVersion = '1.2.0' 16 | 17 | # Unterst�tzte PSEditions 18 | # CompatiblePSEditions = @() 19 | 20 | # ID zur eindeutigen Kennzeichnung dieses Moduls 21 | GUID = '7274fb26-4736-4a3e-9a23-2f05a9f1b9b6' 22 | 23 | # Autor dieses Moduls 24 | Author = 'Markus Kraus' 25 | 26 | # Unternehmen oder Hersteller dieses Moduls 27 | CompanyName = 'mycloudrevolution.com' 28 | 29 | # Urheberrechtserkl�rung f�r dieses Modul 30 | Copyright = '(c) 2017 Markus Kraus.' 31 | 32 | # Beschreibung der von diesem Modul bereitgestellten Funktionen 33 | Description = 'This Repository contains a collection of my VMware vSphere Functions.' 34 | 35 | # Die f�r dieses Modul mindestens erforderliche Version des Windows PowerShell-Moduls 36 | # PowerShellVersion = '' 37 | 38 | # Der Name des f�r dieses Modul erforderlichen Windows PowerShell-Hosts 39 | # PowerShellHostName = '' 40 | 41 | # Die f�r dieses Modul mindestens erforderliche Version des Windows PowerShell-Hosts 42 | # PowerShellHostVersion = '' 43 | 44 | # Die f�r dieses Modul mindestens erforderliche Microsoft .NET Framework-Version. Diese erforderliche Komponente ist nur f�r die PowerShell Desktop-Edition g�ltig. 45 | # DotNetFrameworkVersion = '' 46 | 47 | # Die f�r dieses Modul mindestens erforderliche Version der CLR (Common Language Runtime). Diese erforderliche Komponente ist nur f�r die PowerShell Desktop-Edition g�ltig. 48 | # CLRVersion = '' 49 | 50 | # Die f�r dieses Modul erforderliche Prozessorarchitektur ("Keine", "X86", "Amd64"). 51 | # ProcessorArchitecture = '' 52 | 53 | # Die Module, die vor dem Importieren dieses Moduls in die globale Umgebung geladen werden m�ssen 54 | # RequiredModules = @() 55 | 56 | # Die Assemblys, die vor dem Importieren dieses Moduls geladen werden m�ssen 57 | # RequiredAssemblies = @() 58 | 59 | # Die Skriptdateien (PS1-Dateien), die vor dem Importieren dieses Moduls in der Umgebung des Aufrufers ausgef�hrt werden. 60 | # ScriptsToProcess = @() 61 | 62 | # Die Typdateien (.ps1xml), die beim Importieren dieses Moduls geladen werden sollen 63 | # TypesToProcess = @() 64 | 65 | # Die Formatdateien (.ps1xml), die beim Importieren dieses Moduls geladen werden sollen 66 | # FormatsToProcess = @() 67 | 68 | # Die Module, die als geschachtelte Module des in "RootModule/ModuleToProcess" angegebenen Moduls importiert werden sollen. 69 | NestedModules = @('Apply-Hardening.psm1', 70 | 'Get-NewAndRemovedVMs.psm1', 71 | 'Get-NewVMs.psm1', 72 | 'Get-NICDetails.psm1', 73 | 'Get-UplinkDetails.psm1', 74 | 'Get-VMDisk.psm1', 75 | 'Get-VMHostUplinkDetails.psm1', 76 | 'Get-VMID.psm1', 77 | 'Get-VMmaxIOPS.psm1', 78 | 'Konfig-ESXi.psm1', 79 | 'Push-vLIMessage.psm1', 80 | 'Recommend-Sizing.psm1', 81 | 'Set-CBT.psm1', 82 | 'Set-ConsolidationFix.psm1', 83 | 'Set-IOPSLimit.psm1', 84 | 'Set-VMHostSecureNTP.psm1', 85 | 'Start-UNMAP.psm1', 86 | 'Validate-ESXiPackages.psm1') 87 | 88 | # Aus diesem Modul zu exportierende Funktionen. Um optimale Leistung zu erzielen, verwenden Sie keine Platzhalter und l�schen den Eintrag nicht. Verwenden Sie ein leeres Array, wenn keine zu exportierenden Funktionen vorhanden sind. 89 | FunctionsToExport = 'Apply-Hardening', 'Get-NewAndRemovedVMs', 'Get-NewVMs', 90 | 'Get-NICDetails', 'Get-UplinkDetails', 'Get-VMDisk', 91 | 'Get-VMHostUplinkDetails', 'Get-VMID', 'Get-VMmaxIOPS', 'Konfig-ESXi', 92 | 'Push-vLIMessage', 'Recommend-Sizing', 'Set-CBT', 93 | 'Set-ConsolidationFix', 'Set-IOPSLimit', 'Set-VMHostSecureNTP', 94 | 'Start-UNMAP', 'Validate-ESXiPackages' 95 | 96 | # Aus diesem Modul zu exportierende Cmdlets. Um optimale Leistung zu erzielen, verwenden Sie keine Platzhalter und l�schen den Eintrag nicht. Verwenden Sie ein leeres Array, wenn keine zu exportierenden Cmdlets vorhanden sind. 97 | # CmdletsToExport = '*' 98 | 99 | # Die aus diesem Modul zu exportierenden Variablen 100 | # VariablesToExport = '*' 101 | 102 | # Aus diesem Modul zu exportierende Aliase. Um optimale Leistung zu erzielen, verwenden Sie keine Platzhalter und l�schen den Eintrag nicht. Verwenden Sie ein leeres Array, wenn keine zu exportierenden Aliase vorhanden sind. 103 | # AliasesToExport = '*' 104 | 105 | # Aus diesem Modul zu exportierende DSC-Ressourcen 106 | # DscResourcesToExport = @() 107 | 108 | # Liste aller Module in diesem Modulpaket 109 | # ModuleList = @() 110 | 111 | # Liste aller Dateien in diesem Modulpaket 112 | # FileList = @() 113 | 114 | # Die privaten Daten, die an das in "RootModule/ModuleToProcess" angegebene Modul �bergeben werden sollen. Diese k�nnen auch eine PSData-Hashtabelle mit zus�tzlichen von PowerShell verwendeten Modulmetadaten enthalten. 115 | PrivateData = @{ 116 | 117 | PSData = @{ 118 | 119 | # Tags applied to this module. These help with module discovery in online galleries. 120 | Tags = 'VMware','PowerCLI' 121 | 122 | # A URL to the license for this module. 123 | LicenseUri = 'https://github.com/mycloudrevolution/vSphere-Modules/blob/master/LICENSE' 124 | 125 | # A URL to the main website for this project. 126 | ProjectUri = 'https://github.com/mycloudrevolution/vSphere-Modules' 127 | 128 | # A URL to an icon representing this module. 129 | # IconUri = '' 130 | 131 | # ReleaseNotes of this module 132 | # ReleaseNotes = '' 133 | 134 | # External dependent modules of this module 135 | # ExternalModuleDependencies = '' 136 | 137 | } # End of PSData hashtable 138 | 139 | } # End of PrivateData hashtable 140 | 141 | # HelpInfo-URI dieses Moduls 142 | # HelpInfoURI = '' 143 | 144 | # Standardpr�fix f�r Befehle, die aus diesem Modul exportiert werden. Das Standardpr�fix kann mit "Import-Module -Prefix" �berschrieben werden. 145 | # DefaultCommandPrefix = '' 146 | 147 | } 148 | 149 | -------------------------------------------------------------------------------- /Get-VMHostUplinkDetails.psm1: -------------------------------------------------------------------------------- 1 | function Get-VMHostUplinkDetails { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Markus Kraus 6 | =========================================================================== 7 | Changelog: 8 | 2017.03 ver 1.0 Base Release 9 | 2020.03 ver 1.1 Add LLDP Support 10 | =========================================================================== 11 | External Code Sources: 12 | Get-CDP Version from @LucD22 13 | https://communities.vmware.com/thread/319553 14 | 15 | LLDP PowerCLI Tweak 16 | https://tech.zsoldier.com/2018/05/vmware-get-cdplldp-info-from.html 17 | =========================================================================== 18 | Tested Against Environment: 19 | vSphere Version: vSphere 6.7 U3 20 | PowerCLI Version: PowerCLI 11.5 21 | PowerShell Version: 5.1 22 | OS Version: Server 2016 23 | Keyword: ESXi, Network, CDP, LLDP, VDS, vSwitch, VMNIC 24 | =========================================================================== 25 | 26 | .DESCRIPTION 27 | This Function collects detailed informations about your ESXi Host connections to pSwitch and VDS / vSwitch. 28 | LLDP Informations might only be available when uplinks are connected to a VDS. 29 | 30 | .Example 31 | Get-VMHost -Name MyHost | Get-VMHostUplinkDetails -Type LLDP | Where-Object {$_.VDS -ne "-No Backing-"} | Format-Table -AutoSize 32 | 33 | .Example 34 | Get-VMHost -Name MyHost | Get-VMHostUplinkDetails -Type CDP | Where-Object {$_.VDS -ne "-No Backing-"} | Sort-Object ClusterName, HostName, vmnic | Format-Table -AutoSize 35 | 36 | .Example 37 | Get-Cluster -Name MyCluster | Get-VMHost | Get-VMHostUplinkDetails -Type LLDP | Format-Table -AutoSize 38 | 39 | .Example 40 | Get-Cluster -Name MyCluster | Get-VMHost | Get-VMHostUplinkDetails -Type CDP | Format-Table -AutoSize 41 | 42 | .PARAMETER myHosts 43 | Hosts to process 44 | 45 | 46 | #Requires PS -Version 5.0 47 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 48 | #> 49 | 50 | [CmdletBinding()] 51 | param( 52 | [Parameter(Mandatory=$True, ValueFromPipeline=$True, Position=0, HelpMessage = "Specifies the hosts for which you want to retrieve the uplink details.")] 53 | [ValidateNotNullorEmpty()] 54 | [Alias("myHosts")] 55 | [VMware.VimAutomation.Types.VMHost[]] $VMHost, 56 | [Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=1, HelpMessage = "Type of infos you want to collect (CDP / LLDP)")] 57 | [ValidateSet("CDP","LLDP")] 58 | [String] $Type 59 | 60 | ) 61 | 62 | Begin { 63 | 64 | 65 | function Get-Info ($VMhostToProcess){ 66 | $VMhostProxySwitch = $VMhostToProcess.NetworkInfo.ExtensionData.ProxySwitch 67 | $VMhostSwitch = $VMhostToProcess.NetworkInfo.VirtualSwitch 68 | 69 | $objReport = @() 70 | $VMhostToProcess| ForEach-Object{Get-View $_.ID} | 71 | ForEach-Object{ Get-View $_.ConfigManager.NetworkSystem} | 72 | ForEach-Object{ foreach($physnic in $_.NetworkInfo.Pnic){ 73 | 74 | if($Type -eq "CDP"){ 75 | $obj = "" | Select-Object ClusterName,HostName,vmnic,PCI,MAC,VDS,vSwitch,CDP_Port,CDP_Device,CDP_Address 76 | } 77 | elseif($Type -eq "LLDP"){ 78 | $obj = "" | Select-Object ClusterName,HostName,vmnic,PCI,MAC,VDS,vSwitch,LLDP_Port,LLDP_Chassis,LLDP_SystemName 79 | } 80 | else { 81 | Throw "Invalide Type" 82 | } 83 | 84 | $pnicInfo = $_.QueryNetworkHint($physnic.Device) 85 | foreach($hint in $pnicInfo){ 86 | $obj.ClusterName = $VMhostToProcess.parent.name 87 | $obj.HostName = $VMhostToProcess.name 88 | $obj.vmnic = $physnic.Device 89 | $obj.PCI = $physnic.PCI 90 | $obj.MAC = $physnic.Mac 91 | if ($backing = ($VMhostProxySwitch | Where-Object {$_.Spec.Backing.PnicSpec.PnicDevice -eq $physnic.Device})) { 92 | $obj.VDS = $backing.DvsName 93 | } 94 | else { 95 | $obj.VDS = "-No Backing-" 96 | } 97 | if ($backing = ($VMhostSwitch | Where-Object {$_.Nic -eq $physnic.Device})) { 98 | $obj.vSwitch = $backing.name 99 | } 100 | else { 101 | $obj.vSwitch = "-No Backing-" 102 | } 103 | if($Type -eq "CDP"){ 104 | if( $hint.ConnectedSwitchPort ) { 105 | $obj.CDP_Port = $hint.ConnectedSwitchPort.PortId 106 | $obj.CDP_Device = $hint.ConnectedSwitchPort.DevId 107 | $obj.CDP_Address = $hint.ConnectedSwitchPort.Address 108 | } 109 | else { 110 | $obj.CDP_Port = "-No Info-" 111 | $obj.CDP_Device = "-No Info-" 112 | $obj.CDP_Address = "-No Info-" 113 | } 114 | } 115 | if($Type -eq "LLDP"){ 116 | if( $hint.LldpInfo ) { 117 | $obj.LLDP_Port = $hint.LldpInfo.PortId 118 | $obj.LLDP_Chassis = $hint.LldpInfo.ChassisId 119 | $obj.LLDP_SystemName = ($hint.LldpInfo.Parameter | Where-Object key -eq "System Name").Value 120 | } 121 | else { 122 | $obj.LLDP_Port = "-No Info-" 123 | $obj.LLDP_Chassis = "-No Info-" 124 | $obj.LLDP_SystemName = "-No Info-" 125 | } 126 | } 127 | 128 | 129 | } 130 | $objReport += $obj 131 | } 132 | } 133 | $objReport 134 | } 135 | 136 | } 137 | 138 | Process { 139 | 140 | $VMHost | Foreach-Object { Write-Output (Get-Info $_) } 141 | 142 | } 143 | 144 | } 145 | -------------------------------------------------------------------------------- /Get-NewVMs.psm1: -------------------------------------------------------------------------------- 1 | function Get-NewVMs { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Markus Kraus 6 | Twitter: @VMarkus_K 7 | Private Blog: mycloudrevolution.com 8 | =========================================================================== 9 | Changelog: 10 | 2016.12 ver 1.0 Base Release 11 | =========================================================================== 12 | External Code Sources: 13 | http://www.lucd.info/2013/03/31/get-the-vmotionsvmotion-history/ 14 | =========================================================================== 15 | Tested Against Environment: 16 | vSphere Version: 5.5 U2 17 | PowerCLI Version: PowerCLI 6.3 R1, PowerCLI 6.5 R1 18 | PowerShell Version: 4.0, 5.0 19 | OS Version: Windows 8.1, Server 2012 R2 20 | =========================================================================== 21 | Keywords vSphere, VM 22 | =========================================================================== 23 | 24 | .DESCRIPTION 25 | This Function report newly created VMs by Cluster. 26 | 27 | .Example 28 | Get-NewVMs -ClusterName Cluster* | ft -AutoSize 29 | 30 | .Example 31 | Get-NewVMs -ClusterName Cluster01 32 | 33 | .Example 34 | Get-NewVMs -ClusterName Cluster01, Cluster02 -Days 60 | ft -AutoSize 35 | 36 | .PARAMETER ClusterName 37 | List or Wildcard of your vSphere Cluser Names to process. 38 | 39 | .PARAMETER Day 40 | Range to report. 41 | 42 | 43 | #Requires PS -Version 4.0 44 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 45 | #> 46 | 47 | param( 48 | [Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)] 49 | $ClusterName, 50 | [Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=1)] 51 | [String]$Days = "30" 52 | ) 53 | Begin { 54 | function Get-VIEventPlus { 55 | <# 56 | .SYNOPSIS Returns vSphere events 57 | .DESCRIPTION The function will return vSphere events. With 58 | the available parameters, the execution time can be 59 | improved, compered to the original Get-VIEvent cmdlet. 60 | .NOTES Author: Luc Dekens 61 | .PARAMETER Entity 62 | When specified the function returns events for the 63 | specific vSphere entity. By default events for all 64 | vSphere entities are returned. 65 | .PARAMETER EventType 66 | This parameter limits the returned events to those 67 | specified on this parameter. 68 | .PARAMETER Start 69 | The start date of the events to retrieve 70 | .PARAMETER Finish 71 | The end date of the events to retrieve. 72 | .PARAMETER Recurse 73 | A switch indicating if the events for the children of 74 | the Entity will also be returned 75 | .PARAMETER User 76 | The list of usernames for which events will be returned 77 | .PARAMETER System 78 | A switch that allows the selection of all system events. 79 | .PARAMETER ScheduledTask 80 | The name of a scheduled task for which the events 81 | will be returned 82 | .PARAMETER FullMessage 83 | A switch indicating if the full message shall be compiled. 84 | This switch can improve the execution speed if the full 85 | message is not needed. 86 | .EXAMPLE 87 | PS> Get-VIEventPlus -Entity $vm 88 | .EXAMPLE 89 | PS> Get-VIEventPlus -Entity $cluster -Recurse:$true 90 | #> 91 | 92 | param( 93 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]]$Entity, 94 | [string[]]$EventType, 95 | [DateTime]$Start, 96 | [DateTime]$Finish = (Get-Date), 97 | [switch]$Recurse, 98 | [string[]]$User, 99 | [Switch]$System, 100 | [string]$ScheduledTask, 101 | [switch]$FullMessage = $false 102 | ) 103 | 104 | process { 105 | $eventnumber = 100 106 | $events = @() 107 | $eventMgr = Get-View EventManager 108 | $eventFilter = New-Object VMware.Vim.EventFilterSpec 109 | $eventFilter.disableFullMessage = ! $FullMessage 110 | $eventFilter.entity = New-Object VMware.Vim.EventFilterSpecByEntity 111 | $eventFilter.entity.recursion = &{if($Recurse){"all"}else{"self"}} 112 | $eventFilter.eventTypeId = $EventType 113 | if($Start -or $Finish){ 114 | $eventFilter.time = New-Object VMware.Vim.EventFilterSpecByTime 115 | if($Start){ 116 | $eventFilter.time.beginTime = $Start 117 | } 118 | if($Finish){ 119 | $eventFilter.time.endTime = $Finish 120 | } 121 | } 122 | if($User -or $System){ 123 | $eventFilter.UserName = New-Object VMware.Vim.EventFilterSpecByUsername 124 | if($User){ 125 | $eventFilter.UserName.userList = $User 126 | } 127 | if($System){ 128 | $eventFilter.UserName.systemUser = $System 129 | } 130 | } 131 | if($ScheduledTask){ 132 | $si = Get-View ServiceInstance 133 | $schTskMgr = Get-View $si.Content.ScheduledTaskManager 134 | $eventFilter.ScheduledTask = Get-View $schTskMgr.ScheduledTask | 135 | where {$_.Info.Name -match $ScheduledTask} | 136 | Select -First 1 | 137 | Select -ExpandProperty MoRef 138 | } 139 | if(!$Entity){ 140 | $Entity = @(Get-Folder -Name Datacenters) 141 | } 142 | $entity | %{ 143 | $eventFilter.entity.entity = $_.ExtensionData.MoRef 144 | $eventCollector = Get-View ($eventMgr.CreateCollectorForEvents($eventFilter)) 145 | $eventsBuffer = $eventCollector.ReadNextEvents($eventnumber) 146 | while($eventsBuffer){ 147 | $events += $eventsBuffer 148 | $eventsBuffer = $eventCollector.ReadNextEvents($eventnumber) 149 | } 150 | $eventCollector.DestroyCollector() 151 | } 152 | $events 153 | } 154 | } 155 | } 156 | 157 | process { 158 | $result = Get-VIEventPlus -Entity (Get-Cluster -Name $ClusterName | Get-VM) -Start ((get-date).adddays(-$Days)) -EventType @("VmCreatedEvent", "VmBeingClonedEvent", "VmBeingDeployedEvent") 159 | $result | Select CreatedTime, @{N='Cluster';E={$_.ComputeResource.Name}}, UserName, @{N='Type';E={$_.GetType().Name}}, FullFormattedMessage | Sort CreatedTime 160 | } 161 | } -------------------------------------------------------------------------------- /doc/Features/cmd_set.rst: -------------------------------------------------------------------------------- 1 | Set Commands 2 | ========================= 3 | 4 | This page contains details on **Set** commands. 5 | 6 | Set-CBT 7 | ------------------------- 8 | 9 | 10 | NAME 11 | Set-CBT 12 | 13 | ÜBERSICHT 14 | 15 | 16 | SYNTAX 17 | Set-CBT [-myVMs] [[-EnableCBT]] [] 18 | 19 | Set-CBT [-myVMs] [[-DisableCBT]] [] 20 | 21 | 22 | BESCHREIBUNG 23 | This Function enables or disables CBT. 24 | 25 | 26 | PARAMETER 27 | -myVMs 28 | 29 | -EnableCBT [] 30 | Enables CBT for any VMs found with it disabled 31 | 32 | #Requires PS -Version 4.0 33 | 34 | -DisableCBT [] 35 | Disables CBT for any VMs found with it enabled 36 | 37 | 38 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 39 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 40 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 41 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 42 | 43 | -------------------------- BEISPIEL 1 -------------------------- 44 | 45 | PS C:\>Get-VN TST* | Set-CBT -DisableCBT 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------- BEISPIEL 2 -------------------------- 53 | 54 | PS C:\>Get-VN TST* | Set-CBT -EnableCBT 55 | 56 | 57 | 58 | 59 | 60 | 61 | HINWEISE 62 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Set-CBT -examples". 63 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Set-CBT -detailed". 64 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Set-CBT -full". 65 | 66 | 67 | Set-ConsolidationFix 68 | ------------------------- 69 | 70 | NAME 71 | Set-ConsolidationFix 72 | 73 | ÜBERSICHT 74 | Set VM SnapShot Consolidation Timout Workaround 75 | 76 | 77 | SYNTAX 78 | Set-ConsolidationFix [-vCenterVM] [-Fix] [] 79 | 80 | 81 | BESCHREIBUNG 82 | Set VM SnapShot Consolidation Timout Workaround 83 | 84 | 85 | PARAMETER 86 | -vCenterVM 87 | 88 | -Fix 89 | Timeout os Stun 90 | 91 | 92 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 93 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 94 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 95 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 96 | 97 | -------------------------- BEISPIEL 1 -------------------------- 98 | 99 | PS C:\>Set-ConsolidationFix -vCenterVM "myTest" -Fix "Timeout" 100 | 101 | 102 | 103 | 104 | 105 | 106 | -------------------------- BEISPIEL 2 -------------------------- 107 | 108 | PS C:\>Set-ConsolidationFix -vCenterVM "myTest" -Fix "Stun" 109 | 110 | 111 | 112 | 113 | 114 | 115 | HINWEISE 116 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Set-ConsolidationFix -examples". 117 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Set-ConsolidationFix -detailed". 118 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Set-ConsolidationFix -full". 119 | Geben Sie zum Abrufen der Onlinehilfe Folgendes ein: "get-help Set-ConsolidationFix -online" 120 | 121 | Set-IOPSLimit 122 | ------------------------- 123 | 124 | NAME 125 | Set-IOPSLimit 126 | 127 | ÜBERSICHT 128 | 129 | 130 | SYNTAX 131 | Set-IOPSLimit [-VMs] [-ConfigPath] [[-Exclusions] ] [[-SetLimit]] [] 132 | 133 | 134 | BESCHREIBUNG 135 | Report and Set VM Disk IO Limits 136 | 137 | 138 | PARAMETER 139 | -VMs 140 | Specify the VMs 141 | 142 | -ConfigPath 143 | Path to XML File with Valid Configuration 144 | 145 | Example: 146 | 147 | 148 | 149 | 150 | 151 | B 152 | 250 153 | 154 | 155 | S 156 | 1000 157 | 158 | 159 | G 160 | -1 161 | 162 | 163 | 164 | -Exclusions 165 | 166 | -SetLimit [] 167 | Switch to enforce the Limits 168 | 169 | #Requires PS -Version 4.0 170 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 171 | 172 | 173 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 174 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 175 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 176 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 177 | 178 | -------------------------- BEISPIEL 1 -------------------------- 179 | 180 | PS C:\>Get-VM -Name TST* | Set-IOPSLimit -ConfigPath C:\Scripts\vSphere-Modules\Set-IOPSLimit.xml -SetLimit | ft -AutoSize 181 | 182 | 183 | 184 | 185 | 186 | 187 | -------------------------- BEISPIEL 2 -------------------------- 188 | 189 | PS C:\>Get-VM -Name TST* | Set-IOPSLimit -ConfigPath C:\Scripts\vSphere-Modules\Set-IOPSLimit.xml | ft -AutoSize 190 | 191 | 192 | 193 | 194 | 195 | 196 | HINWEISE 197 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Set-IOPSLimit -examples". 198 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Set-IOPSLimit -detailed". 199 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Set-IOPSLimit -full". 200 | 201 | 202 | Set-VMHostSecureNTP 203 | ------------------------- 204 | 205 | NAME 206 | Set-VMHostSecureNTP 207 | 208 | ÜBERSICHT 209 | 210 | 211 | SYNTAX 212 | Set-VMHostSecureNTP [-VMHost] [-SetSecure] -NTP [] 213 | 214 | Set-VMHostSecureNTP [-VMHost] [-Secure] [] 215 | 216 | 217 | BESCHREIBUNG 218 | This function sets new NTP Servers on given ESXi Hosts and configures the host firewall to only accept NTP connections from these servers. 219 | 220 | 221 | PARAMETER 222 | -VMHost 223 | Specifies the hosts to configure 224 | 225 | -SetSecure [] 226 | Execute Set and Secure operation for new NTP Servers 227 | 228 | -NTP 229 | Specifies a Array of NTP Servers 230 | 231 | -Secure [] 232 | Execute Secure operation for exitsting NTP Servers 233 | 234 | #Requires PS -Version 5.1 235 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="11.5.0.0"} 236 | 237 | 238 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 239 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 240 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 241 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 242 | 243 | -------------------------- BEISPIEL 1 -------------------------- 244 | 245 | PS C:\>Get-VMHost | Set-VMHostSecureNTP -Secure 246 | 247 | 248 | 249 | 250 | 251 | 252 | -------------------------- BEISPIEL 2 -------------------------- 253 | 254 | PS C:\>Get-VMHost | Set-VMHostSecureNTP -Type SetSecure -NTP 10.100.1.1, 192.168.2.1 255 | 256 | 257 | 258 | 259 | 260 | 261 | HINWEISE 262 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Set-VMHostSecureNTP -examples". 263 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Set-VMHostSecureNTP -detailed". 264 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Set-VMHostSecureNTP -full". 265 | 266 | 267 | 268 | 269 | -------------------------------------------------------------------------------- /Konfig-ESXi.psm1: -------------------------------------------------------------------------------- 1 | function Konfig-ESXi { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Markus Kraus 6 | Twitter: @VMarkus_K 7 | Private Blog: mycloudrevolution.com 8 | =========================================================================== 9 | Changelog: 10 | 2016.12 ver 1.0 Base Release 11 | 2016.12 ver 1.1 ESXi 6.5 Tests, Minor enhancements 12 | =========================================================================== 13 | External Code Sources: 14 | Function My-Logger : http://www.virtuallyghetto.com/ 15 | =========================================================================== 16 | Tested Against Environment: 17 | vSphere Version: ESXi 5.5 U2, ESXi 6.5 18 | PowerCLI Version: PowerCLI 6.3 R1, PowerCLI 6.5 R1 19 | PowerShell Version: 4.0, 5.0 20 | OS Version: Windows 8.1, Server 2012 R2 21 | Keyword: ESXi, NTP, SSH, Syslog, SATP, 22 | =========================================================================== 23 | 24 | .DESCRIPTION 25 | This Function sets the Basic settings for a new ESXi. 26 | 27 | * NTP 28 | * SSH 29 | * Syslog 30 | * Power Management 31 | * HP 3PAR SATP/PSP Rule 32 | * ... 33 | 34 | .Example 35 | Konfig-ESXi -VMHost myesxi.lan.local -NTP 192.168.2.1, 192.168.2.2 -syslog "udp://loginsight.lan.local:514" 36 | 37 | .PARAMETER VMHost 38 | Host to configure. 39 | 40 | .PARAMETER NTP 41 | NTP Server(s) to set. 42 | 43 | .PARAMETER Syslog 44 | Syslog Server to set, e.g. "udp://loginsight.lan.local:514" 45 | 46 | DNS Name must be resolvable! 47 | 48 | 49 | #Requires PS -Version 4.0 50 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 51 | #> 52 | 53 | [CmdletBinding()] 54 | param( 55 | [Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)] 56 | [String] $VMHost, 57 | [Parameter(Mandatory=$true, ValueFromPipeline=$False, Position=1)] 58 | [array]$NTP, 59 | [Parameter(Mandatory=$true, ValueFromPipeline=$False, Position=2)] 60 | [String] $syslog 61 | 62 | ) 63 | 64 | Begin { 65 | Function My-Logger { 66 | param( 67 | [Parameter(Mandatory=$true)] 68 | [String]$message 69 | ) 70 | 71 | $timeStamp = Get-Date -Format "MM-dd-yyyy_hh-mm-ss" 72 | 73 | Write-Host -NoNewline -ForegroundColor White "[$timestamp]" 74 | Write-Host -ForegroundColor Green " $message" 75 | } 76 | function Set-MyESXiOption { 77 | [CmdletBinding()] 78 | param( 79 | [Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)] 80 | [String] $Name, 81 | [Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=1)] 82 | [String] $Value 83 | ) 84 | process { 85 | $myESXiOption = Get-AdvancedSetting -Entity $ESXiHost -Name $Name 86 | if ($myESXiOption.Value -ne $Value) { 87 | My-Logger " Setting ESXi Option $Name to Value $Value" 88 | $myESXiOption | Set-AdvancedSetting -Value $Value -Confirm:$false | Out-Null 89 | } 90 | else { 91 | My-Logger " ESXi Option $Name already has Value $Value" 92 | } 93 | } 94 | } 95 | } 96 | 97 | Process { 98 | $Validate = $True 99 | 100 | #region: Start vCenter Connection 101 | My-Logger "Starting to Process ESXi Server Connection to $VMHost ..." 102 | if (($global:DefaultVIServers).count -gt 0) { 103 | Disconnect-VIServer -Force -Confirm:$False -ErrorAction SilentlyContinue 104 | } 105 | $VIConnection = Connect-VIServer -Server $VMHost 106 | if (-not $VIConnection.IsConnected) { 107 | Write-Error "ESXi Connection Failed." 108 | $Validate = $False 109 | } 110 | elseif ($VIConnection.ProductLine -ne "EmbeddedEsx") { 111 | Write-Error "Connencted System is not an ESXi." 112 | $Validate = $False 113 | } 114 | else { 115 | $ESXiHost = Get-VMHost 116 | My-Logger "Connected ESXi Version: $($ESXiHost.Version) $($ESXiHost.Build) " 117 | } 118 | #endregion 119 | 120 | if ($Validate -eq $True) { 121 | 122 | #region: Enable SSH and disable SSH Warning 123 | $SSHService = $ESXiHost | Get-VMHostService | where {$_.Key -eq 'TSM-SSH'} 124 | My-Logger "Starting SSH Service..." 125 | if($SSHService.Running -ne $True){ 126 | Start-VMHostService -HostService $SSHService -Confirm:$false | Out-Null 127 | } 128 | else { 129 | My-Logger " SSH Service is already running" 130 | } 131 | My-Logger "Setting SSH Service to Automatic Start..." 132 | if($SSHService.Policy -ne "automatic"){ 133 | Set-VMHostService -HostService $SSHService -Policy "Automatic" | Out-Null 134 | } 135 | else { 136 | My-Logger " SSH Service is already set to Automatic Start" 137 | } 138 | My-Logger "Disabling SSH Warning..." 139 | Set-MyESXiOption -Name "UserVars.SuppressShellWarning" -Value "1" 140 | #endregion 141 | 142 | #region: Config NTP 143 | My-Logger "Removing existing NTP Server..." 144 | try { 145 | $ESXiHost | Remove-VMHostNtpServer -NtpServer (Get-VMHostNtpServer) -Confirm:$false 146 | } 147 | catch [System.Exception] { 148 | Write-Warning "Error during removing existing NTP Servers." 149 | } 150 | My-Logger "Setting new NTP Servers..." 151 | foreach ($myNTP in $NTP) { 152 | $ESXiHost | Add-VMHostNtpServer -ntpserver $myNTP -confirm:$False | Out-Null 153 | } 154 | 155 | My-Logger "Configure NTP Service..." 156 | $NTPService = $ESXiHost | Get-VMHostService| Where-Object {$_.key -eq "ntpd"} 157 | if($NTPService.Running -eq $True){ 158 | Stop-VMHostService -HostService $NTPService -Confirm:$false | Out-Null 159 | } 160 | if($NTPService.Policy -ne "on"){ 161 | Set-VMHostService -HostService $NTPService -Policy "on" -confirm:$False | Out-Null 162 | } 163 | 164 | My-Logger "Configure Local Time..." 165 | $HostTimeSystem = Get-View $ESXiHost.ExtensionData.ConfigManager.DateTimeSystem 166 | $HostTimeSystem.UpdateDateTime([DateTime]::UtcNow) 167 | 168 | My-Logger "Start NTP Service..." 169 | Start-VMHostService -HostService $NTPService -confirm:$False | Out-Null 170 | #endregion 171 | 172 | #region: Remove default PG 173 | My-Logger "Checking for Default Port Group ..." 174 | if ($defaultPG = $ESXiHost | Get-VirtualSwitch -Name vSwitch0 | Get-VirtualPortGroup -Name "VM Network" -ErrorAction SilentlyContinue ){ 175 | Remove-VirtualPortGroup -VirtualPortGroup $defaultPG -confirm:$False | Out-Null 176 | My-Logger " Default PG Removed" 177 | } 178 | else { 179 | My-Logger " No Default PG found" 180 | } 181 | #endregion 182 | 183 | #region: Configure Static HighPower 184 | My-Logger "Setting PowerProfile to Static HighPower..." 185 | try { 186 | $HostView = ($ESXiHost | Get-View) 187 | (Get-View $HostView.ConfigManager.PowerSystem).ConfigurePowerPolicy(1) 188 | } 189 | catch [System.Exception] { 190 | Write-Warning "Error during Configure Static HighPower. See latest errors..." 191 | } 192 | #endregion 193 | 194 | #region: Conf Syslog 195 | My-Logger "Setting Syslog Firewall Rule ..." 196 | $SyslogFW = ($ESXiHost | Get-VMHostFirewallException | where {$_.Name -eq 'syslog'}) 197 | if ($SyslogFW.Enabled -eq $False ){ 198 | $SyslogFW | Set-VMHostFirewallException -Enabled:$true -Confirm:$false | Out-Null 199 | My-Logger " Syslog Firewall Rule enabled" 200 | } 201 | else { 202 | My-Logger " Syslog Firewall Rule already enabled" 203 | } 204 | My-Logger "Setting Syslog Server..." 205 | Set-MyESXiOption -Name "Syslog.global.logHost" -Value $syslog 206 | #endregion 207 | 208 | #region: Change Disk Scheduler 209 | My-Logger "Changing Disk Scheduler..." 210 | Set-MyESXiOption -Name "Disk.SchedulerWithReservation" -Value "0" 211 | #endregion 212 | 213 | #region: Configure HP 3PAR SATP/PSP Rule 214 | My-Logger "Configure HP 3PAR SATP/PSP Rule" 215 | $esxcli2 = Get-ESXCLI -VMHost $ESXiHost -V2 216 | $arguments = $esxcli2.storage.nmp.satp.rule.add.CreateArgs() 217 | $arguments.satp = "VMW_SATP_ALUA" 218 | $arguments.psp = "VMW_PSP_RR" 219 | $arguments.pspoption = "iops=100" 220 | $arguments.claimoption = "tpgs_on" 221 | $arguments.vendor = "3PARdata" 222 | $arguments.model = "VV" 223 | $arguments.description = "HP 3PAR custom SATP Claimrule" 224 | try { 225 | $esxcli2.storage.nmp.satp.rule.add.Invoke($arguments) 226 | } 227 | catch { 228 | Write-Warning "Error during Configure HP 3PAR SATP/PSP Rule. See latest errors..." 229 | } 230 | #endregion 231 | 232 | } 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /Set-IOPSLimit.psm1: -------------------------------------------------------------------------------- 1 | function Set-IOPSLimit { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Markus Kraus 6 | Twitter: @VMarkus_K 7 | Private Blog: mycloudrevolution.com 8 | =========================================================================== 9 | Changelog: 10 | 2016.11 ver 2.0 Base Release 11 | =========================================================================== 12 | External Code Sources: 13 | http://www.lucd.info/2011/04/22/get-the-maximum-iops/ 14 | https://communities.vmware.com/thread/485386 15 | =========================================================================== 16 | Tested Against Environment: 17 | vSphere Version: 5.5 U2 18 | PowerCLI Version: PowerCLI 6.3 R1, PowerCLI 6.5 R1 19 | PowerShell Version: 4.0, 5.0 20 | OS Version: Windows 8.1, Server 2012 R2 21 | Keyword: VM, IOPS, Limits 22 | =========================================================================== 23 | 24 | .DESCRIPTION 25 | Report and Set VM Disk IO Limits 26 | 27 | .Example 28 | Get-VM -Name TST* | Set-IOPSLimit -ConfigPath C:\Scripts\vSphere-Modules\Set-IOPSLimit.xml -SetLimit | ft -AutoSize 29 | 30 | .Example 31 | Get-VM -Name TST* | Set-IOPSLimit -ConfigPath C:\Scripts\vSphere-Modules\Set-IOPSLimit.xml | ft -AutoSize 32 | 33 | .PARAMETER VMs 34 | Specify the VMs 35 | 36 | .PARAMETER ConfigPath 37 | Path to XML File with Valid Configuration 38 | 39 | Example: 40 | 41 | 42 | 43 | 44 | 45 | B 46 | 250 47 | 48 | 49 | S 50 | 1000 51 | 52 | 53 | G 54 | -1 55 | 56 | 57 | 58 | .PARAMETER SetLimit 59 | Switch to enforce the Limits 60 | 61 | #Requires PS -Version 4.0 62 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 63 | #> 64 | 65 | [CmdletBinding()] 66 | param( 67 | [Parameter(Mandatory=$True, ValueFromPipeline=$True, Position=0)] 68 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]] $VMs, 69 | [Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=1)] 70 | [String] $ConfigPath, 71 | [Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=2)] 72 | [String] $Exclusions = "Template_*|Test_*", 73 | [Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=3)] 74 | [Switch] $SetLimit 75 | 76 | ) 77 | Begin { 78 | $Validate = $True 79 | $XMLValidate = $True 80 | #region: Read XML 81 | If (Test-Path $ConfigPath) { 82 | try { 83 | $Variable = [XML] (Get-Content $ConfigPath) 84 | } 85 | catch { 86 | Write-Error "Invalid xml"; $XMLValidate = $False 87 | } 88 | } 89 | Else { 90 | Write-Error "Missing xml File"; $XMLValidate = $False 91 | } 92 | #endregion 93 | 94 | #region: Process XML Values 95 | [String] $B = $Variable.Config.Bronze.Name 96 | [Int] $B_Limit = $Variable.Config.Bronze.Value 97 | [String] $S = $Variable.Config.Silver.Name 98 | [Int] $S_Limit = $Variable.Config.Silver.Value 99 | [String] $G = $Variable.Config.Gold.Name 100 | [Int] $G_Limit = $Variable.Config.Gold.Value 101 | [String] $Split = ($Variable.Config.Variable | Where-Object {$_.Name -eq "Split"}).Value 102 | [Int] $Split_position = ($Variable.Config.Variable | Where-Object {$_.Name -eq "Split_Position"}).Value 103 | #endregion 104 | } 105 | 106 | Process { 107 | if ($XMLValidate -eq $True) { 108 | $Validate = $True 109 | #region: Filter VMs 110 | $myVMs = $VMs | where {($_ | Get-HardDisk).count -gt 0 -and ($_ | Get-HardDisk).ExtensionData.Controllerkey -ne 200} 111 | #endregion 112 | 113 | if ($null -ne $myVMs) { 114 | #region: Creating HD-Tab 115 | Write-Verbose "Starting to Create HD-Tab..." 116 | $hdTab = @{} 117 | foreach($hd in (Get-Harddisk -VM $myVMs)){ 118 | $controllerKey = $hd.Extensiondata.ControllerKey 119 | $controller = $hd.Parent.Extensiondata.Config.Hardware.Device | where{$_.Key -eq $controllerKey} 120 | $hdTab[$hd.Parent.Name + "/scsi" + $controller.BusNumber + ":" + $hd.Extensiondata.UnitNumber] = $hd.FileName.Split(']')[0].TrimStart('[') 121 | } 122 | #endregion 123 | 124 | #region: Creating and Process VM Rport 125 | Write-Verbose "Starting to Process VM Report..." 126 | $report = @() 127 | foreach ($myVM in $myVMs) { 128 | $VMHDDs = Get-HardDisk -VM $myVMs | select Name, ExtensionData, Filename, CapacityKB 129 | foreach ($VMHDD in $VMHDDs) { 130 | $row = "" | select VmName, ScsiID, Datastore, Tier, CapacityGB, CurrentIOLimit, PlannedIOLimit, IOLimitCorrect, HostSchedulerIsmClock, Processed 131 | $row.VmName = $myVM.Name 132 | $row.ScsiID = $([string]$VmHdd.extensiondata.controllerkey).substring(3,1) +":"+ $([string]$VmHdd.extensiondata.unitnumber) 133 | $row.Datastore = $($VmHdd.Filename.TrimStart("[")).split("]")[0] 134 | $row.Tier = $row.Datastore.Split($Split)[$Split_position] 135 | switch ($row.Tier) { 136 | $S {$row.PlannedIOLimit = $S_Limit} 137 | $B {$row.PlannedIOLimit = $B_Limit} 138 | $G {$row.PlannedIOLimit = $G_Limit} 139 | default {Write-Error "Invalid DS name or tier identifier" ; $Validate = $False} 140 | } 141 | if ($row.VmName -match $Exclusions) {$row.PlannedIOLimit = -1} 142 | elseif ($VmHdd.ExtensionData.Backing.DiskMode -eq "independent_persistent") {$row.PlannedIOLimit = -1} 143 | $row.CapacityGB = [Math]::round(($VmHdd.capacitykb / 1024 / 1024),2) 144 | $row.CurrentIOlimit = $VmHdd.ExtensionData.StorageIOAllocation.limit 145 | if ($row.CurrentIOLimit -eq -1 -and $row.PlannedIOLimit -ne -1 -and $row.VmName -notmatch $Exclusions) {$row.IOLimitCorrect = "No IO Limit Set"} 146 | elseif ($row.VmName -match $Exclusions) {$row.IOLimitCorrect = "Fixed Unlimited"} 147 | elseif ($VmHdd.ExtensionData.Backing.DiskMode -eq "independent_persistent") {$row.IOLimitCorrect = "Fixed Unlimited"} 148 | elseif ($row.CurrentIOLimit -gt $row.PlannedIOLimit) {$row.IOLimitCorrect = "Too High"} 149 | elseif ($row.CurrentIOLimit -lt $row.PlannedIOLimit) {$row.IOLimitCorrect = "Too Low"} 150 | else {$row.IOLimitCorrect = "Just Right"} 151 | $SchedulerWithReservation = (Get-AdvancedSetting -Entity $myVM.VMHost -Name Disk.SchedulerWithReservation).Value 152 | if ($SchedulerWithReservation -eq 0){ $row.HostSchedulerIsmClock = "False" } 153 | else{ $row.HostSchedulerIsmClock = "True" } 154 | $row.Processed = "False" 155 | if ($SetLimit -and $Validate -eq $True) { 156 | if ($row.IOLimitCorrect -ne "Just Right") { 157 | $VMDisk = $myVM | Get-HardDisk | where {$_.Name -eq $VmHdd.Name} 158 | if ($myVM.Name -match $Exclusions) { ## Remove Limit on Exclusions 159 | if ($VMDisk.ExtensionData.StorageIOAllocation.limit -ne -1) { 160 | $myVM | Get-VMResourceConfiguration | Set-VMResourceConfiguration -Disk $VMDisk -DiskLimitIOPerSecond "-1" | Out-Null 161 | $row.Processed = "True" 162 | } 163 | } 164 | elseif ($VMDisk.Persistence -eq "independentpersistent" ) { ## Remove Limit on Raw Devices 165 | if ($VMDisk.ExtensionData.StorageIOAllocation.limit -ne -1) { 166 | $myVM | Get-VMResourceConfiguration | Set-VMResourceConfiguration -Disk $VMDisk -DiskLimitIOPerSecond "-1" | Out-Null 167 | $row.Processed = "True" 168 | } 169 | 170 | } 171 | else { ## Set Limit 172 | $myVM | Get-VMResourceConfiguration | Set-VMResourceConfiguration -Disk $VMDisk -DiskLimitIOPerSecond $row.PlannedIOLimit | Out-Null 173 | $row.Processed = "True" 174 | if( $row.HostSchedulerIsmClock -eq "True" ){ Write-Warning "mClock Scheduler can couse unexpected Results!`nSee: http://anthonyspiteri.net/esxi-5-5-iops-limit-mclock-scheduler/" } 175 | } 176 | } 177 | } 178 | $report += $row 179 | } 180 | } 181 | #endregion 182 | if ($SetLimit -and $Validate -eq $False) {Write-Output "`n"; Write-Error "Validation Failed! VM Disk Processing Skipped"} 183 | $Report 184 | } 185 | } 186 | Else { 187 | Write-Error "XML Validation Failed! Processing Skipped" 188 | } 189 | } 190 | 191 | End { 192 | ## No End 193 | } 194 | 195 | } -------------------------------------------------------------------------------- /Set-VMHostSecureNTP.psm1: -------------------------------------------------------------------------------- 1 | function Set-VMHostSecureNTP { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Markus Kraus 6 | =========================================================================== 7 | Changelog: 8 | 2020.05 ver 1.0 Base Release 9 | =========================================================================== 10 | External Code Sources: 11 | - 12 | =========================================================================== 13 | Tested Against Environment: 14 | vSphere Version: vSphere 6.7 U3 15 | PowerCLI Version: PowerCLI 11.5 16 | PowerShell Version: 5.1 17 | OS Version: Windows 10 18 | Keyword: ESXi, NTP, Hardening, Security, Firewall 19 | =========================================================================== 20 | 21 | .DESCRIPTION 22 | This function sets new NTP Servers on given ESXi Hosts and configures the host firewall to only accept NTP connections from these servers. 23 | 24 | .Example 25 | Get-VMHost | Set-VMHostSecureNTP -Secure 26 | 27 | .Example 28 | Get-VMHost | Set-VMHostSecureNTP -Type SetSecure -NTP 10.100.1.1, 192.168.2.1 29 | 30 | .PARAMETER VMHost 31 | Specifies the hosts to configure 32 | 33 | .PARAMETER SetSecure 34 | Execute Set and Secure operation for new NTP Servers 35 | 36 | .PARAMETER NTP 37 | Specifies a Array of NTP Servers 38 | 39 | .PARAMETER Secure 40 | Execute Secure operation for exitsting NTP Servers 41 | 42 | #Requires PS -Version 5.1 43 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="11.5.0.0"} 44 | #> 45 | 46 | [CmdletBinding()] 47 | param( 48 | [Parameter(Mandatory=$True, ValueFromPipeline=$True, Position=0, HelpMessage = "Specifies the hosts to configure.")] 49 | [ValidateNotNullorEmpty()] 50 | [VMware.VimAutomation.Types.VMHost[]] $VMHost, 51 | [Parameter(Mandatory=$False, ValueFromPipeline=$False, ParameterSetName="SetSecure", HelpMessage = "Execute Set and Secure operation for new NTP Servers")] 52 | [Switch] $SetSecure, 53 | [Parameter(Mandatory=$True, ValueFromPipeline=$False, ParameterSetName="SetSecure", HelpMessage = "Specifies a Array of NTP Servers")] 54 | [ValidateNotNullorEmpty()] 55 | [ipaddress[]] $NTP, 56 | [Parameter(Mandatory=$False, ValueFromPipeline=$False, ParameterSetName="Secure", HelpMessage = "Execute Secure operation for exitsting NTP Servers")] 57 | [Switch] $Secure 58 | 59 | ) 60 | 61 | begin { 62 | 63 | function SetNTP ($MyHost) { 64 | ## Get NTP Service 65 | "Get NTP Service from VMHost ..." 66 | $NTPService = $MyHost | Get-VMHostService | Where-Object {$_.key -eq "ntpd"} 67 | ## Stop NTP Service if running 68 | "Stop NTP Service if running ..." 69 | if($NTPService.Running -eq $True){ 70 | Stop-VMHostService -HostService $NTPService -Confirm:$false | Out-Null 71 | } 72 | ## Enable NTP Service 73 | "Enable NTP Service if disabled..." 74 | if($NTPService.Policy -ne "on"){ 75 | Set-VMHostService -HostService $NTPService -Policy "on" -confirm:$False | Out-Null 76 | } 77 | ## Remove all existing NTP Servers 78 | "Remove all existing NTP Servers ..." 79 | try { 80 | $MyHost | Get-VMHostNtpServer | Foreach-Object { 81 | Remove-VMHostNtpServer -VMHost $MyHost -NtpServer $_ -Confirm:$false 82 | } 83 | } 84 | catch [System.Exception] { 85 | Write-Warning "Error during removing existing NTP Servers on Host '$($MyHost.Name)'." 86 | } 87 | ## Set New NTP Servers 88 | "Set New NTP Servers ..." 89 | foreach ($myNTP in $NTP) { 90 | $MyHost | Add-VMHostNtpServer -ntpserver $myNTP -confirm:$False | Out-Null 91 | } 92 | ## Set Current time on Host 93 | "Set Current time on VMHost ..." 94 | $HostTimeSystem = Get-View $MyHost.ExtensionData.ConfigManager.DateTimeSystem 95 | $HostTimeSystem.UpdateDateTime([DateTime]::UtcNow) 96 | ## Start NTP Service 97 | "Start NTP Service ..." 98 | Start-VMHostService -HostService $NTPService -confirm:$False | Out-Null 99 | ## Get New NTP Servers 100 | "Get New NTP Servers ..." 101 | $NewNTPServers = $MyHost | Get-VMHostNtpServer 102 | "`tNew NTP Servers: $($NewNTPServers -join ", ")" 103 | 104 | } 105 | 106 | function SecureNTP ($MyHost) { 107 | ## Get NTP Servers 108 | "Get NTP Servers to Secure ..." 109 | [Array]$CurrentNTPServers = $MyHost | Get-VMHostNtpServer 110 | "`tNTP Servers: $($CurrentNTPServers -join ", ")" 111 | ## Get ESXCLI -V2 112 | $esxcli = Get-ESXCLI -VMHost $MyHost -v2 113 | ## Get NTP Client Firewall 114 | "Get NTP Client Firewall ..." 115 | try { 116 | $FirewallGet = $esxcli.network.firewall.get.Invoke() 117 | } 118 | catch [System.Exception] { 119 | Write-Warning "Error during Rule List. See latest errors..." 120 | } 121 | "`tLoded: $($FirewallGet.Loaded)" 122 | "`tEnabled: $($FirewallGet.Enabled)" 123 | "`tDefaultAction: $($FirewallGet.DefaultAction)" 124 | ## Get NTP Client Firewall Rule 125 | "Get NTP Client Firewall RuleSet ..." 126 | $esxcliargs = $esxcli.network.firewall.ruleset.list.CreateArgs() 127 | $esxcliargs.rulesetid = "ntpClient" 128 | try { 129 | $FirewallRuleList = $esxcli.network.firewall.ruleset.list.Invoke($esxcliargs) 130 | } 131 | catch [System.Exception] { 132 | Write-Warning "Error during Rule List. See latest errors..." 133 | } 134 | "`tEnabled: $($FirewallRuleList.Enabled)" 135 | ## Set NTP Client Firewall Rule 136 | "Set NTP Client Firewall Rule ..." 137 | $esxcliargs = $esxcli.network.firewall.ruleset.set.CreateArgs() 138 | $esxcliargs.enabled = "true" 139 | $esxcliargs.allowedall = "false" 140 | $esxcliargs.rulesetid = "ntpClient" 141 | try { 142 | $esxcli.network.firewall.ruleset.set.Invoke($esxcliargs) 143 | } 144 | catch [System.Exception] { 145 | $ErrorMessage = $_.Exception.Message 146 | if ($ErrorMessage -ne "Already use allowed ip list") { 147 | Write-Warning "Error during Rule Set. See latest errors..." 148 | 149 | } 150 | 151 | } 152 | "Get NTP Client Firewall Rule AllowedIP ..." 153 | $esxcliargs = $esxcli.network.firewall.ruleset.allowedip.list.CreateArgs() 154 | $esxcliargs.rulesetid = "ntpClient" 155 | try { 156 | $FirewallRuleAllowedIPList = $esxcli.network.firewall.ruleset.allowedip.list.Invoke($esxcliargs) 157 | } 158 | catch [System.Exception] { 159 | Write-Warning "Error during Rule List. See latest errors..." 160 | } 161 | "`tAllowed IP Addresses: $($FirewallRuleAllowedIPList.AllowedIPAddresses -join ", ")" 162 | ## Remove Existing IP from firewall rule 163 | "Remove Existing IP from firewall rule ..." 164 | if ($FirewallRuleAllowedIPList.AllowedIPAddresses -ne "All") { 165 | foreach ($IP in $FirewallRuleAllowedIPList.AllowedIPAddresses) { 166 | $esxcliargs = $esxcli.network.firewall.ruleset.allowedip.remove.CreateArgs() 167 | $esxcliargs.rulesetid = "ntpClient" 168 | $esxcliargs.ipaddress = $IP 169 | try { 170 | $esxcli.network.firewall.ruleset.allowedip.remove.Invoke($esxcliargs) 171 | } 172 | catch [System.Exception] { 173 | Write-Warning "Error during AllowedIP remove. See latest errors..." 174 | } 175 | } 176 | 177 | } 178 | ## Set NTP Client Firewall Rule AllowedIP 179 | "Set NTP Client Firewall Rule AllowedIP ..." 180 | foreach ($myNTP in $CurrentNTPServers) { 181 | $esxcliargs = $esxcli.network.firewall.ruleset.allowedip.add.CreateArgs() 182 | $esxcliargs.ipaddress = $myNTP 183 | $esxcliargs.rulesetid = "ntpClient" 184 | try { 185 | $esxcli.network.firewall.ruleset.allowedip.add.Invoke($esxcliargs) 186 | } 187 | catch [System.Exception] { 188 | $ErrorMessage = $_.Exception.Message 189 | if ($ErrorMessage -ne "Ip address already exist.") { 190 | Write-Warning "Error during AllowedIP remove. See latest errors..." 191 | } 192 | } 193 | } 194 | ## Get New NTP Client Firewall Rule AllowedIP 195 | "Get New NTP Client Firewall Rule AllowedIP ..." 196 | $esxcliargs = $esxcli.network.firewall.ruleset.allowedip.list.CreateArgs() 197 | $esxcliargs.rulesetid = "ntpClient" 198 | try { 199 | $FirewallRuleAllowedIPList = $esxcli.network.firewall.ruleset.allowedip.list.Invoke($esxcliargs) 200 | } 201 | catch [System.Exception] { 202 | Write-Warning "Error during Rule List. See latest errors..." 203 | } 204 | "`tNew Allowed IP Addresses: $($FirewallRuleAllowedIPList.AllowedIPAddresses -join ", ")" 205 | 206 | 207 | } 208 | 209 | } 210 | 211 | process { 212 | 213 | if ($SetSecure) { 214 | "Execute Set and Secure operation for new NTP Servers ..." 215 | $VMHost | Foreach-Object { Write-Output (SetNTP $_) } 216 | $VMHost | Foreach-Object { Write-Output (SecureNTP $_) } 217 | } 218 | if ($Secure) { 219 | "Execute Secure operation for exitsting NTP Servers ..." 220 | $VMHost | Foreach-Object { Write-Output (SecureNTP $_) } 221 | } 222 | 223 | } 224 | 225 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /Recommend-Sizing.psm1: -------------------------------------------------------------------------------- 1 | function Recommend-Sizing { 2 | <# 3 | .NOTES 4 | =========================================================================== 5 | Created by: Markus Kraus 6 | Twitter: @VMarkus_K 7 | Private Blog: mycloudrevolution.com 8 | =========================================================================== 9 | Changelog: 10 | 2016.11 ver 1.0 Base Release 11 | 2016.11 ver 1.1 Optional Stats Collection 12 | 2016.11 ver 1.2 VM Stats from Realtime Data and new Counters 13 | =========================================================================== 14 | External Code Sources: 15 | http://www.lucd.info/2011/04/22/get-the-maximum-iops/ 16 | https://communities.vmware.com/thread/485386 17 | =========================================================================== 18 | Tested Against Environment: 19 | vSphere Version: 5.5 U2, 6.0 20 | PowerCLI Version: PowerCLI 6.3 R1, PowerCLI 6.5 R1 21 | PowerShell Version: 4.0, 5.0 22 | OS Version: Windows 8.1, Server 2012 R2 23 | =========================================================================== 24 | Keywords vSphere, ESXi, VM, Storage, Sizing 25 | =========================================================================== 26 | 27 | .DESCRIPTION 28 | This Function collects Basic vSphere Informations for a Hardware Sizing Recommandation. Focus is in Compute Ressources. 29 | 30 | .Example 31 | Recommend-Sizing -ClusterNames Cluster01, Cluster02 -Stats -StatsRange 60 -Verbose 32 | 33 | .Example 34 | Recommend-Sizing -ClusterNames Cluster01, Cluster02 35 | 36 | .Example 37 | Recommend-Sizing -ClusterNames Cluster01 38 | 39 | .PARAMETER ClusterNames 40 | List of your vSphere Cluser Names to process. 41 | 42 | .PARAMETER Stats 43 | Enables Stats Collection. 44 | 45 | Warning: At the moment this is only fully tested with vSphere 5.5 and vSphere 6.5! 46 | 47 | .PARAMETER StatsRange 48 | Time Range in Minutes for the Stats Collection. 49 | Default is 24h. 50 | 51 | #Requires PS -Version 4.0 52 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 53 | #> 54 | 55 | [CmdletBinding()] 56 | param( 57 | [Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)] 58 | [Array] $ClusterNames, 59 | [Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=1, ParameterSetName = "Stats")] 60 | [switch] $Stats, 61 | [Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=2, ParameterSetName = "Stats")] 62 | [int] $StatsRange = 1440 63 | 64 | ) 65 | Begin { 66 | if ($Stats) { 67 | Write-Warning "Stats Collection requested.`nAt the moment this is only fully tested with vSphere 5.5 and vSphere 6.5" 68 | [int]$TimeRange = "-" + $StatsRange 69 | } 70 | 71 | $Validate = $True 72 | #region: Check Clusters 73 | Write-Verbose "$(Get-Date -Format G) Starting Cluster Validation..." 74 | foreach ($ClusterName in $ClusterNames) { 75 | $TestCluster = Get-Cluster -Name $ClusterName -ErrorAction SilentlyContinue -Verbose:$False 76 | if(!($TestCluster)){ 77 | Write-Warning "No Custer found wth Name $ClusterName!" 78 | $Validate = $False 79 | } 80 | elseif ($TestCluster.count -gt 1) { 81 | Write-Warning "Multiple Custers found wth Name $ClusterName!`nUse a List of explicit Cluster Names: Recommend-Sizing -ClusterNames Cluster01, Cluster02 " 82 | $Validate = $False 83 | } 84 | } 85 | Write-Verbose "$(Get-Date -Format G) Cluster Validation completed" 86 | #endregion 87 | } 88 | 89 | Process { 90 | $MyView = @() 91 | if ($Validate -eq $True) { 92 | foreach ($ClusterName in $ClusterNames) { 93 | #region: Get Cluster Objects 94 | Write-Verbose "$(Get-Date -Format G) Collect $ClusterName Cluster Objects..." 95 | $Cluster = Get-Cluster -Name $ClusterName -Verbose:$False 96 | $ClusterVMs = $Cluster | Get-VM -Verbose:$False 97 | $ClusterVMsPoweredOn = $ClusterVMs | where {$_.PowerState -eq "PoweredOn"} 98 | $ClusterDatastores = $Cluster | Get-Datastore -Verbose:$False 99 | $ClusterHosts = $Cluster | Get-VMHost -Verbose:$False 100 | $HostsAverageMemoryUsageGB = [math]::round( ($ClusterHosts | Measure-Object -Average -Property MemoryUsageGB).Average,1 ) 101 | $HostsAverageMemoryUsage = $([math]::round( (($ClusterHosts | Measure-Object -Average -Property MemoryUsageGB).Average / ($ClusterHosts | Measure-Object -Average -Property MemoryTotalGB).Average) * 100,1 )) 102 | $HostsAverageCpuUsageMhz = [math]::round( ($ClusterHosts | Measure-Object -Average -Property CpuUsageMhz).Average,1 ) 103 | $HostsAverageCpuUsage = $([math]::round( (($ClusterHosts | Measure-Object -Average -Property CpuUsageMhz).Average / ($ClusterHosts | Measure-Object -Average -Property CpuTotalMhz).Average) * 100,1 )) 104 | Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Cluster Objects completed" 105 | #endregion 106 | 107 | #region: CPU Calculation 108 | Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) CPU Details..." 109 | $VMvCPUs = ($ClusterVMs | Measure-Object -Sum -Property NumCpu).sum 110 | $LogicalThreads = $Cluster.ExtensionData.Summary.NumCpuThreads 111 | $CpuCores = $Cluster.ExtensionData.Summary.NumCpuCores 112 | $vCPUpCPUratio = [math]::round( $VMvCPUs / $LogicalThreads,1 ) 113 | Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) CPU Details completed." 114 | #endregion 115 | 116 | #region: Memory Calculation 117 | Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Memory Details..." 118 | $AllocatedVMMemoryGB = [math]::round( ($ClusterVMs | Measure-Object -Sum -Property MemoryGB).sum ) 119 | $PhysicalMemory = [math]::round( $Cluster.ExtensionData.Summary.TotalMemory / 1073741824,1 ) 120 | $MemoryUsage = [math]::round( ($AllocatedVMMemoryGB / $PhysicalMemory) * 100 ,1 ) 121 | Write-Verbose "$(Get-Date -Format G) Collect $($Cluster.name) Memory Details completed" 122 | #endregion 123 | 124 | if ($Stats) { 125 | #region: Creating VM Stats 126 | Write-Verbose "$(Get-Date -Format G) Create $($Cluster.name) VM Stats..." 127 | $VMMetrics = "disk.numberwrite.summation","disk.numberread.summation","cpu.usage.average", "mem.usage.average" 128 | $Start = (Get-Date).AddMinutes($TimeRange) 129 | $VMStats = Get-Stat -Realtime -Stat $VMMetrics -Entity $ClusterVMsPoweredOn -Start $Start -Verbose:$False 130 | Write-Verbose "$(Get-Date -Format G) Create $($Cluster.name) VM Stats completed" 131 | #endregion 132 | 133 | #region: Creating VM Stats Report 134 | Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) VM Stats Report..." 135 | $ReportVMPerf = @() 136 | $ReportVMPerf = $VMStats | Group-Object -Property {$_.Entity.Name},Instance | %{ 137 | New-Object PSObject -Property @{ 138 | IOPSWriteAvg = ($_.Group | ` 139 | where{$_.MetricId -eq "disk.numberwrite.summation"} | ` 140 | Measure-Object -Property Value -Average).Average 141 | IOPSReadAvg = ($_.Group | ` 142 | where{$_.MetricId -eq "disk.numberread.summation"} | ` 143 | Measure-Object -Property Value -Average).Average 144 | CPUUsageAvg = ($_.Group | ` 145 | where{$_.MetricId -eq "cpu.usage.average"} | ` 146 | Measure-Object -Property Value -Average).Average 147 | MEMUsageAvg = ($_.Group | ` 148 | where{$_.MetricId -eq "mem.usage.average"} | ` 149 | Measure-Object -Property Value -Average).Average 150 | } 151 | } 152 | Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) VM Stats Report completed" 153 | #endregion 154 | } 155 | else { 156 | Write-Verbose "$(Get-Date -Format G) Stats Collection skipped..." 157 | } 158 | 159 | #region: Create VM Disk Space Report 160 | Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) VM Disk Space Report..." 161 | $reportDiskSpace = @() 162 | foreach ($ClusterVM in $ClusterVMs){ 163 | $VMDKs = $ClusterVM | get-HardDisk -Verbose:$False 164 | foreach ($VMDK in $VMDKs) { 165 | if ($VMDK -ne $null){ 166 | [int]$CapacityGB = $VMDK.CapacityKB/1024/1024 167 | $Report = [PSCustomObject] @{ 168 | CapacityGB = $CapacityGB 169 | } 170 | $reportDiskSpace += $Report 171 | } 172 | } 173 | } 174 | Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) VM Disk Space Report completed" 175 | #endregion 176 | 177 | #region: Create Datastore Space Report 178 | Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) Datastore Space Report..." 179 | $DatastoreReport = @($ClusterDatastores | Select-Object @{N="CapacityGB";E={[math]::Round($_.CapacityGB,2)}}, @{N="FreeSpaceGB";E={[math]::Round($_.FreeSpaceGB,2)}}, @{N="UsedSpaceGB";E={[math]::Round($_.CapacityGB - $_.FreeSpaceGB,2)}}) 180 | Write-Verbose "$(Get-Date -Format G) Process $($Cluster.name) Datastore Space Report completed" 181 | #endregion 182 | 183 | #region: Create Global Report 184 | Write-Verbose "$(Get-Date -Format G) Process Global Report..." 185 | $SizingReport = [PSCustomObject] @{ 186 | Cluster = $Cluster.name 187 | HAEnabled = $Cluster.HAEnabled 188 | DrsEnabled = $Cluster.DrsEnabled 189 | Hosts = $Cluster.ExtensionData.Summary.NumHosts 190 | HostsAverageMemoryUsageGB = $HostsAverageMemoryUsageGB 191 | HostsAverageMemoryUsage = "$HostsAverageMemoryUsage %" 192 | HostsAverageCpuUsageMhz = $HostsAverageCpuUsageMhz 193 | HostsAverageCpuUsage = "$HostsAverageCpuUsage %" 194 | PhysicalCPUCores = $CpuCores 195 | LogicalCPUThreads = $LogicalThreads 196 | VMs = $ClusterVMs.count 197 | ActiveVMs = $ClusterVMsPoweredOn.count 198 | VMvCPUs = $VMvCPUs 199 | vCPUpCPUratio = "$vCPUpCPUratio : 1" 200 | PhysicalMemoryGB = $PhysicalMemory 201 | AllocatedVMMemoryGB = $AllocatedVMMemoryGB 202 | ClusterMemoryUsage = "$MemoryUsage %" 203 | SumVMDiskSpaceGB = [math]::round( ($reportDiskSpace | Measure-Object -Sum -Property CapacityGB).sum, 1 ) 204 | SumDatastoreSpaceGB = [math]::round( ($DatastoreReport | Measure-Object -Sum -Property CapacityGB).sum, 1 ) 205 | SumDatastoreUsedSpaceGB = [math]::round( ($DatastoreReport | Measure-Object -Sum -Property UsedSpaceGB).sum, 1 ) 206 | AverageVMIOPSWriteAvg = [math]::round( ($ReportVMPerf | Measure-Object -Average -Property IOPSWriteAvg).Average,1 ) 207 | AverageVMIOPSReadAvg = [math]::round( ($ReportVMPerf | Measure-Object -Average -Property IOPSReadAvg).Average,1 ) 208 | AverageVMCPUUsageAvg = "$([math]::round( ($ReportVMPerf | Measure-Object -Average -Property CPUUsageAvg).Average,1 )) %" 209 | AverageVMMEMUsageAvg = "$([math]::round( ($ReportVMPerf | Measure-Object -Average -Property MEMUsageAvg).Average,1 )) %" 210 | } 211 | $MyView += $SizingReport 212 | Write-Verbose "$(Get-Date -Format G) Process Global Report completed" 213 | #endregion 214 | } 215 | 216 | } 217 | Else { 218 | Write-Error "Validation Failed! Processing Skipped" 219 | } 220 | 221 | } 222 | 223 | End { 224 | $MyView 225 | } 226 | 227 | } -------------------------------------------------------------------------------- /doc/Features/cmd_get.rst: -------------------------------------------------------------------------------- 1 | Get Commands 2 | ========================= 3 | 4 | This page contains details on **Get** commands. 5 | 6 | Get-NewAndRemovedVMs 7 | ------------------------- 8 | 9 | 10 | NAME 11 | Get-NewAndRemovedVMs 12 | 13 | ÜBERSICHT 14 | 15 | 16 | SYNTAX 17 | Get-NewAndRemovedVMs [-ClusterName] [[-Summary]] [[-Days] ] [] 18 | 19 | 20 | BESCHREIBUNG 21 | This Function report newly created and deleted VMs by Cluster. 22 | 23 | 24 | PARAMETER 25 | -ClusterName 26 | Name or Wildcard of your vSphere Cluster Name(s) to report. 27 | 28 | -Summary [] 29 | Displays only a short summary instead of the whole report. 30 | 31 | -Days 32 | 33 | 34 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 35 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 36 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 37 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 38 | 39 | -------------------------- BEISPIEL 1 -------------------------- 40 | 41 | PS C:\>Get-NewAndRemovedVMs -ClusterName Cluster* | ft -AutoSize 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------- BEISPIEL 2 -------------------------- 49 | 50 | PS C:\>Get-NewAndRemovedVMs -ClusterName Cluster01 -Days 90 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------- BEISPIEL 3 -------------------------- 58 | 59 | PS C:\>Get-NewAndRemovedVMs -ClusterName * -Days 90 -Summary 60 | 61 | 62 | 63 | 64 | 65 | 66 | HINWEISE 67 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Get-NewAndRemovedVMs -examples". 68 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Get-NewAndRemovedVMs -detailed". 69 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Get-NewAndRemovedVMs -full". 70 | 71 | 72 | Get-NewVMs 73 | ------------------------- 74 | 75 | NAME 76 | Get-NewVMs 77 | 78 | ÜBERSICHT 79 | 80 | 81 | SYNTAX 82 | Get-NewVMs [-ClusterName] [[-Days] ] [] 83 | 84 | 85 | BESCHREIBUNG 86 | This Function report newly created VMs by Cluster. 87 | 88 | 89 | PARAMETER 90 | -ClusterName 91 | List or Wildcard of your vSphere Cluser Names to process. 92 | 93 | -Days 94 | 95 | 96 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 97 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 98 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 99 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 100 | 101 | -------------------------- BEISPIEL 1 -------------------------- 102 | 103 | PS C:\>Get-NewVMs -ClusterName Cluster* | ft -AutoSize 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------- BEISPIEL 2 -------------------------- 111 | 112 | PS C:\>Get-NewVMs -ClusterName Cluster01 113 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------- BEISPIEL 3 -------------------------- 120 | 121 | PS C:\>Get-NewVMs -ClusterName Cluster01, Cluster02 -Days 60 | ft -AutoSize 122 | 123 | 124 | 125 | 126 | 127 | 128 | HINWEISE 129 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Get-NewVMs -examples". 130 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Get-NewVMs -detailed". 131 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Get-NewVMs -full". 132 | 133 | 134 | Get-NICDetails 135 | ------------------------- 136 | 137 | NAME 138 | Get-NICDetails 139 | 140 | ÜBERSICHT 141 | 142 | 143 | SYNTAX 144 | Get-NICDetails [-Clustername] [] 145 | 146 | 147 | BESCHREIBUNG 148 | Reports Firmware and Driver Details for your ESXi vmnics. 149 | 150 | 151 | PARAMETER 152 | -Clustername 153 | Name or Wildcard of your vSphere Cluster Name to process. 154 | 155 | 156 | #Requires PS -Version 4.0 157 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 158 | 159 | 160 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 161 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 162 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 163 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 164 | 165 | -------------------------- BEISPIEL 1 -------------------------- 166 | 167 | PS C:\>Get-NICDetails -Clustername * 168 | 169 | 170 | 171 | 172 | 173 | 174 | HINWEISE 175 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Get-NICDetails -examples". 176 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Get-NICDetails -detailed". 177 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Get-NICDetails -full". 178 | 179 | 180 | Get-UplinkDetails 181 | ------------------------- 182 | 183 | NAME 184 | Get-UplinkDetails 185 | 186 | ÜBERSICHT 187 | 188 | 189 | SYNTAX 190 | Get-UplinkDetails [-Clustername] [] 191 | 192 | 193 | BESCHREIBUNG 194 | This Function collects detailed informations about your ESXi Host connections to pSwitch and DVS / vSwitch 195 | 196 | 197 | PARAMETER 198 | -Clustername 199 | Your vSphere Cluster Name or Wildcard 200 | 201 | 202 | #Requires PS -Version 4.0 203 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 204 | 205 | 206 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 207 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 208 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 209 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 210 | 211 | -------------------------- BEISPIEL 1 -------------------------- 212 | 213 | PS C:\>Get-UplinkDetails -Clustername * | ft -AutoSize 214 | 215 | 216 | 217 | 218 | 219 | 220 | -------------------------- BEISPIEL 2 -------------------------- 221 | 222 | PS C:\>Get-UplinkDetails -Clustername MyCluster001 | ft -AutoSize 223 | 224 | 225 | 226 | 227 | 228 | 229 | -------------------------- BEISPIEL 3 -------------------------- 230 | 231 | PS C:\>Get-UplinkDetails -Clustername MyCluster* | Sort Clustername, Hostname, DVS | ft -AutoSize 232 | 233 | 234 | 235 | 236 | 237 | 238 | HINWEISE 239 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Get-UplinkDetails -examples". 240 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Get-UplinkDetails -detailed". 241 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Get-UplinkDetails -full". 242 | 243 | 244 | Get-VMDisk 245 | ------------------------- 246 | 247 | NAME 248 | Get-VMDisk 249 | 250 | ÜBERSICHT 251 | 252 | 253 | SYNTAX 254 | Get-VMDisk [-myVMs] [] 255 | 256 | 257 | BESCHREIBUNG 258 | This Function reports VM vDisks and Datastores: 259 | 260 | Get-VM MyTest | Get-VMDisk | Format-Table -AutoSize 261 | 262 | Name PowerState Datastore Path Disk StorageFormat CapacityGB Controller Unit 263 | ---- ---------- --------- ---- ---- ------------- ---------- ---------- ---- 264 | MyTest PoweredOff data01 MyTest/MyTest.vmdk Hard disk 1 Thin 16 0 0 265 | MyTest PoweredOff data02 MyTest/MyTest_1.vmdk Hard disk 2 Thin 20 1 0 266 | MyTest PoweredOff data01 MyTest/MyTest_2.vmdk Hard disk 3 Thick 20 1 1 267 | 268 | 269 | PARAMETER 270 | -myVMs 271 | 272 | 273 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 274 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 275 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 276 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 277 | 278 | -------------------------- BEISPIEL 1 -------------------------- 279 | 280 | PS C:\>Get-VM -Name TST* | Get-VMDisk 281 | 282 | 283 | 284 | 285 | 286 | 287 | -------------------------- BEISPIEL 2 -------------------------- 288 | 289 | PS C:\>Get-Folder -Name TST | Get-VM | Get-VMDisk | ft -AutoSize 290 | 291 | #Requires PS -Version 5.0 292 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 293 | 294 | 295 | 296 | 297 | HINWEISE 298 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Get-VMDisk -examples". 299 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Get-VMDisk -detailed". 300 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Get-VMDisk -full". 301 | 302 | 303 | Get-VMHostUplinkDetails 304 | ------------------------- 305 | 306 | NAME 307 | Get-VMHostUplinkDetails 308 | 309 | ÜBERSICHT 310 | 311 | 312 | SYNTAX 313 | Get-VMHostUplinkDetails [-VMHost] [-Type] [] 314 | 315 | 316 | BESCHREIBUNG 317 | This Function collects detailed informations about your ESXi Host connections to pSwitch and VDS / vSwitch. 318 | LLDP Informations might only be available when uplinks are connected to a VDS. 319 | 320 | 321 | PARAMETER 322 | -VMHost 323 | 324 | -Type 325 | 326 | 327 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 328 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 329 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 330 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 331 | 332 | -------------------------- BEISPIEL 1 -------------------------- 333 | 334 | PS C:\>Get-VMHost -Name MyHost | Get-VMHostUplinkDetails -Type LLDP | Where-Object {$_.VDS -ne "-No Backing-"} | Format-Table -AutoSize 335 | 336 | 337 | 338 | 339 | 340 | 341 | -------------------------- BEISPIEL 2 -------------------------- 342 | 343 | PS C:\>Get-VMHost -Name MyHost | Get-VMHostUplinkDetails -Type CDP | Where-Object {$_.VDS -ne "-No Backing-"} | Sort-Object ClusterName, HostName, vmnic | Format-Table -AutoSize 344 | 345 | 346 | 347 | 348 | 349 | 350 | -------------------------- BEISPIEL 3 -------------------------- 351 | 352 | PS C:\>Get-Cluster -Name MyCluster | Get-VMHost | Get-VMHostUplinkDetails -Type LLDP | Format-Table -AutoSize 353 | 354 | 355 | 356 | 357 | 358 | 359 | -------------------------- BEISPIEL 4 -------------------------- 360 | 361 | PS C:\>Get-Cluster -Name MyCluster | Get-VMHost | Get-VMHostUplinkDetails -Type CDP | Format-Table -AutoSize 362 | 363 | 364 | 365 | 366 | 367 | 368 | HINWEISE 369 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Get-VMHostUplinkDetails -examples". 370 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Get-VMHostUplinkDetails -detailed". 371 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Get-VMHostUplinkDetails -full". 372 | 373 | 374 | Get-VMID 375 | ------------------------- 376 | 377 | NAME 378 | Get-VMID 379 | 380 | ÜBERSICHT 381 | 382 | 383 | SYNTAX 384 | Get-VMID [-myVMs] [] 385 | 386 | 387 | BESCHREIBUNG 388 | This Function reports all VM IDs 389 | 390 | 391 | PARAMETER 392 | -myVMs 393 | 394 | 395 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 396 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 397 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 398 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 399 | 400 | -------------------------- BEISPIEL 1 -------------------------- 401 | 402 | PS C:\>Get-VM -Name TST* | Get-VMID 403 | 404 | 405 | 406 | 407 | 408 | 409 | -------------------------- BEISPIEL 2 -------------------------- 410 | 411 | PS C:\>Get-Folder -Name TST | Get-VM | Get-VMID | ft -AutoSize 412 | 413 | #Requires PS -Version 4.0 414 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 415 | 416 | 417 | 418 | 419 | HINWEISE 420 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Get-VMID -examples". 421 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Get-VMID -detailed". 422 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Get-VMID -full". 423 | 424 | 425 | Get-VMmaxIOPS 426 | ------------------------- 427 | 428 | NAME 429 | Get-VMmaxIOPS 430 | 431 | ÜBERSICHT 432 | 433 | 434 | SYNTAX 435 | Get-VMmaxIOPS [-VMs] [[-Minutes] ] [] 436 | 437 | 438 | BESCHREIBUNG 439 | This Function will Create a VM Disk IOPS Report 440 | 441 | 442 | PARAMETER 443 | -VMs 444 | Specify the VMs 445 | 446 | -Minutes 447 | Time Range in Minutes for the Stats Collection. 448 | Default is 30 Minutes. 449 | 450 | #Requires PS -Version 4.0 451 | #Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"} 452 | 453 | 454 | Dieses Cmdlet unterstützt folgende allgemeine Parameter: Verbose, Debug, 455 | ErrorAction, ErrorVariable, WarningAction, WarningVariable, 456 | OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter 457 | "about_CommonParameters" (https:/go.microsoft.com/fwlink/?LinkID=113216). 458 | 459 | -------------------------- BEISPIEL 1 -------------------------- 460 | 461 | PS C:\>Get-Folder -Name TST | Get-VM | where {$_.PowerState -eq "PoweredOn"} | Get-VMmaxIOPS -Minutes 120 | ft -AutoSize 462 | 463 | 464 | 465 | 466 | 467 | 468 | -------------------------- BEISPIEL 2 -------------------------- 469 | 470 | PS C:\>Get-Cluster -Name TST | Get-VM | where {$_.PowerState -eq "PoweredOn"} | Get-VMmaxIOPS 471 | 472 | 473 | 474 | 475 | 476 | 477 | -------------------------- BEISPIEL 3 -------------------------- 478 | 479 | PS C:\>Get-VM -Name TST*| where {$_.PowerState -eq "PoweredOn"} | Get-VMmaxIOPS -Minutes 120 | ft -AutoSize 480 | 481 | 482 | 483 | 484 | 485 | 486 | HINWEISE 487 | Zum Aufrufen der Beispiele geben Sie Folgendes ein: "get-help Get-VMmaxIOPS -examples". 488 | Weitere Informationen erhalten Sie mit folgendem Befehl: "get-help Get-VMmaxIOPS -detailed". 489 | Technische Informationen erhalten Sie mit folgendem Befehl: "get-help Get-VMmaxIOPS -full". 490 | 491 | 492 | 493 | 494 | --------------------------------------------------------------------------------