Merge remote-tracking branch 'vmware/master'
This commit is contained in:
131
Modules/Get-NewAndRemovedVMs.psm1
Normal file
131
Modules/Get-NewAndRemovedVMs.psm1
Normal file
@@ -0,0 +1,131 @@
|
|||||||
|
function Get-NewAndRemovedVMs {
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created by: Markus Kraus
|
||||||
|
Twitter: @VMarkus_K
|
||||||
|
Private Blog: mycloudrevolution.com
|
||||||
|
===========================================================================
|
||||||
|
Changelog:
|
||||||
|
2016.12 ver 1.0 Base Release
|
||||||
|
===========================================================================
|
||||||
|
External Code Sources:
|
||||||
|
https://github.com/alanrenouf/vCheck-vSphere
|
||||||
|
===========================================================================
|
||||||
|
Tested Against Environment:
|
||||||
|
vSphere Version: 5.5 U2
|
||||||
|
PowerCLI Version: PowerCLI 6.3 R1, PowerCLI 6.5 R1
|
||||||
|
PowerShell Version: 4.0, 5.0
|
||||||
|
OS Version: Windows 8.1, Server 2012 R2
|
||||||
|
===========================================================================
|
||||||
|
Keywords vSphere, VM
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
This Function report newly created and deleted VMs by Cluster.
|
||||||
|
|
||||||
|
.Example
|
||||||
|
Get-NewAndRemovedVMs -ClusterName Cluster* | ft -AutoSize
|
||||||
|
|
||||||
|
.Example
|
||||||
|
Get-NewAndRemovedVMs -ClusterName Cluster01 -Days 90
|
||||||
|
|
||||||
|
.PARAMETER ClusterName
|
||||||
|
Name or Wildcard of your vSphere Cluster Name(s) to report.
|
||||||
|
|
||||||
|
.PARAMETER Day
|
||||||
|
Range in Days to report.
|
||||||
|
|
||||||
|
|
||||||
|
#Requires PS -Version 4.0
|
||||||
|
#Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"}
|
||||||
|
#>
|
||||||
|
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0, HelpMessage = "Name or Wildcard of your vSphere Cluster Name to report")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String]$ClusterName,
|
||||||
|
[Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=1, HelpMessage = "Range in Days to report")]
|
||||||
|
[ValidateNotNullorEmpty()]
|
||||||
|
[String]$Days = "30"
|
||||||
|
)
|
||||||
|
Begin {
|
||||||
|
function Get-VIEventPlus {
|
||||||
|
|
||||||
|
param(
|
||||||
|
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.InventoryItemImpl[]]$Entity,
|
||||||
|
[string[]]$EventType,
|
||||||
|
[DateTime]$Start,
|
||||||
|
[DateTime]$Finish = (Get-Date),
|
||||||
|
[switch]$Recurse,
|
||||||
|
[string[]]$User,
|
||||||
|
[Switch]$System,
|
||||||
|
[string]$ScheduledTask,
|
||||||
|
[switch]$FullMessage = $false,
|
||||||
|
[switch]$UseUTC = $false
|
||||||
|
)
|
||||||
|
|
||||||
|
process {
|
||||||
|
$eventnumber = 100
|
||||||
|
$events = @()
|
||||||
|
$eventMgr = Get-View EventManager
|
||||||
|
$eventFilter = New-Object VMware.Vim.EventFilterSpec
|
||||||
|
$eventFilter.disableFullMessage = ! $FullMessage
|
||||||
|
$eventFilter.entity = New-Object VMware.Vim.EventFilterSpecByEntity
|
||||||
|
$eventFilter.entity.recursion = &{if($Recurse){"all"}else{"self"}}
|
||||||
|
$eventFilter.eventTypeId = $EventType
|
||||||
|
if($Start -or $Finish){
|
||||||
|
$eventFilter.time = New-Object VMware.Vim.EventFilterSpecByTime
|
||||||
|
if($Start){
|
||||||
|
$eventFilter.time.beginTime = $Start
|
||||||
|
}
|
||||||
|
if($Finish){
|
||||||
|
$eventFilter.time.endTime = $Finish
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($User -or $System){
|
||||||
|
$eventFilter.UserName = New-Object VMware.Vim.EventFilterSpecByUsername
|
||||||
|
if($User){
|
||||||
|
$eventFilter.UserName.userList = $User
|
||||||
|
}
|
||||||
|
if($System){
|
||||||
|
$eventFilter.UserName.systemUser = $System
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($ScheduledTask){
|
||||||
|
$si = Get-View ServiceInstance
|
||||||
|
$schTskMgr = Get-View $si.Content.ScheduledTaskManager
|
||||||
|
$eventFilter.ScheduledTask = Get-View $schTskMgr.ScheduledTask |
|
||||||
|
where {$_.Info.Name -match $ScheduledTask} |
|
||||||
|
Select -First 1 |
|
||||||
|
Select -ExpandProperty MoRef
|
||||||
|
}
|
||||||
|
if(!$Entity){
|
||||||
|
$Entity = @(Get-Folder -NoRecursion)
|
||||||
|
}
|
||||||
|
$entity | %{
|
||||||
|
$eventFilter.entity.entity = $_.ExtensionData.MoRef
|
||||||
|
$eventCollector = Get-View ($eventMgr.CreateCollectorForEvents($eventFilter))
|
||||||
|
$eventsBuffer = $eventCollector.ReadNextEvents($eventnumber)
|
||||||
|
while($eventsBuffer){
|
||||||
|
$events += $eventsBuffer
|
||||||
|
$eventsBuffer = $eventCollector.ReadNextEvents($eventnumber)
|
||||||
|
}
|
||||||
|
$eventCollector.DestroyCollector()
|
||||||
|
}
|
||||||
|
if (-not $UseUTC)
|
||||||
|
{
|
||||||
|
$events | % { $_.createdTime = $_.createdTime.ToLocalTime() }
|
||||||
|
}
|
||||||
|
|
||||||
|
$events
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
process {
|
||||||
|
$result = Get-VIEventPlus -Start ((get-date).adddays(-$Days)) -EventType @("VmCreatedEvent", "VmBeingClonedEvent", "VmBeingDeployedEvent","VmRemovedEvent")
|
||||||
|
$sortedResult = $result | Select CreatedTime, @{N='Cluster';E={$_.ComputeResource.Name}}, @{Name="VMName";Expression={$_.vm.name}}, UserName, @{N='Type';E={$_.GetType().Name}}, FullFormattedMessage | Sort CreatedTime
|
||||||
|
$sortedResult | where {$_.Cluster -like $ClusterName}
|
||||||
|
}
|
||||||
|
}
|
||||||
234
Modules/Konfig-ESXi.psm1
Normal file
234
Modules/Konfig-ESXi.psm1
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
function Konfig-ESXi {
|
||||||
|
<#
|
||||||
|
.NOTES
|
||||||
|
===========================================================================
|
||||||
|
Created by: Markus Kraus
|
||||||
|
Twitter: @VMarkus_K
|
||||||
|
Private Blog: mycloudrevolution.com
|
||||||
|
===========================================================================
|
||||||
|
Changelog:
|
||||||
|
2016.12 ver 1.0 Base Release
|
||||||
|
2016.12 ver 1.1 ESXi 6.5 Tests, Minor enhancements
|
||||||
|
===========================================================================
|
||||||
|
External Code Sources:
|
||||||
|
Function My-Logger : http://www.virtuallyghetto.com/
|
||||||
|
===========================================================================
|
||||||
|
Tested Against Environment:
|
||||||
|
vSphere Version: ESXi 5.5 U2, ESXi 6.5
|
||||||
|
PowerCLI Version: PowerCLI 6.3 R1, PowerCLI 6.5 R1
|
||||||
|
PowerShell Version: 4.0, 5.0
|
||||||
|
OS Version: Windows 8.1, Server 2012 R2
|
||||||
|
Keyword: ESXi, NTP, SSH, Syslog, SATP,
|
||||||
|
===========================================================================
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
This Function sets the Basic settings for a new ESXi.
|
||||||
|
|
||||||
|
* NTP
|
||||||
|
* SSH
|
||||||
|
* Syslog
|
||||||
|
* Power Management
|
||||||
|
* HP 3PAR SATP/PSP Rule
|
||||||
|
* ...
|
||||||
|
|
||||||
|
.Example
|
||||||
|
Konfig-ESXi -VMHost myesxi.lan.local -NTP 192.168.2.1, 192.168.2.2 -syslog "udp://loginsight.lan.local:514"
|
||||||
|
|
||||||
|
.PARAMETER VMHost
|
||||||
|
Host to configure.
|
||||||
|
|
||||||
|
.PARAMETER NTP
|
||||||
|
NTP Server(s) to set.
|
||||||
|
|
||||||
|
.PARAMETER Syslog
|
||||||
|
Syslog Server to set, e.g. "udp://loginsight.lan.local:514"
|
||||||
|
|
||||||
|
DNS Name must be resolvable!
|
||||||
|
|
||||||
|
|
||||||
|
#Requires PS -Version 4.0
|
||||||
|
#Requires -Modules VMware.VimAutomation.Core, @{ModuleName="VMware.VimAutomation.Core";ModuleVersion="6.3.0.0"}
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)]
|
||||||
|
[String] $VMHost,
|
||||||
|
[Parameter(Mandatory=$true, ValueFromPipeline=$False, Position=1)]
|
||||||
|
[array]$NTP,
|
||||||
|
[Parameter(Mandatory=$true, ValueFromPipeline=$False, Position=2)]
|
||||||
|
[String] $syslog
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
Begin {
|
||||||
|
Function My-Logger {
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$true)]
|
||||||
|
[String]$message
|
||||||
|
)
|
||||||
|
|
||||||
|
$timeStamp = Get-Date -Format "MM-dd-yyyy_hh-mm-ss"
|
||||||
|
|
||||||
|
Write-Host -NoNewline -ForegroundColor White "[$timestamp]"
|
||||||
|
Write-Host -ForegroundColor Green " $message"
|
||||||
|
}
|
||||||
|
function Set-MyESXiOption {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory=$True, ValueFromPipeline=$False, Position=0)]
|
||||||
|
[String] $Name,
|
||||||
|
[Parameter(Mandatory=$False, ValueFromPipeline=$False, Position=1)]
|
||||||
|
[String] $Value
|
||||||
|
)
|
||||||
|
process {
|
||||||
|
$myESXiOption = Get-AdvancedSetting -Entity $ESXiHost -Name $Name
|
||||||
|
if ($myESXiOption.Value -ne $Value) {
|
||||||
|
My-Logger " Setting ESXi Option $Name to Value $Value"
|
||||||
|
$myESXiOption | Set-AdvancedSetting -Value $Value -Confirm:$false | Out-Null
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
My-Logger " ESXi Option $Name already has Value $Value"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
$Validate = $True
|
||||||
|
|
||||||
|
#region: Start vCenter Connection
|
||||||
|
My-Logger "Starting to Process ESXi Server Connection to $VMHost ..."
|
||||||
|
if (($global:DefaultVIServers).count -gt 0) {
|
||||||
|
Disconnect-VIServer -Force -Confirm:$False -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
$VIConnection = Connect-VIServer -Server $VMHost
|
||||||
|
if (-not $VIConnection.IsConnected) {
|
||||||
|
Write-Error "ESXi Connection Failed."
|
||||||
|
$Validate = $False
|
||||||
|
}
|
||||||
|
elseif ($VIConnection.ProductLine -ne "EmbeddedEsx") {
|
||||||
|
Write-Error "Connencted System is not an ESXi."
|
||||||
|
$Validate = $False
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$ESXiHost = Get-VMHost
|
||||||
|
My-Logger "Connected ESXi Version: $($ESXiHost.Version) $($ESXiHost.Build) "
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
if ($Validate -eq $True) {
|
||||||
|
|
||||||
|
#region: Enable SSH and disable SSH Warning
|
||||||
|
$SSHService = $ESXiHost | Get-VMHostService | where {$_.Key -eq 'TSM-SSH'}
|
||||||
|
My-Logger "Starting SSH Service..."
|
||||||
|
if($SSHService.Running -ne $True){
|
||||||
|
Start-VMHostService -HostService $SSHService -Confirm:$false | Out-Null
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
My-Logger " SSH Service is already running"
|
||||||
|
}
|
||||||
|
My-Logger "Setting SSH Service to Automatic Start..."
|
||||||
|
if($SSHService.Policy -ne "automatic"){
|
||||||
|
Set-VMHostService -HostService $SSHService -Policy "Automatic" | Out-Null
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
My-Logger " SSH Service is already set to Automatic Start"
|
||||||
|
}
|
||||||
|
My-Logger "Disabling SSH Warning..."
|
||||||
|
Set-MyESXiOption -Name "UserVars.SuppressShellWarning" -Value "1"
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region: Config NTP
|
||||||
|
My-Logger "Removing existing NTP Server..."
|
||||||
|
try {
|
||||||
|
$ESXiHost | Remove-VMHostNtpServer -NtpServer (Get-VMHostNtpServer) -Confirm:$false
|
||||||
|
}
|
||||||
|
catch [System.Exception] {
|
||||||
|
Write-Warning "Error during removing existing NTP Servers."
|
||||||
|
}
|
||||||
|
My-Logger "Setting new NTP Servers..."
|
||||||
|
foreach ($myNTP in $NTP) {
|
||||||
|
$ESXiHost | Add-VMHostNtpServer -ntpserver $myNTP -confirm:$False | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
My-Logger "Configure NTP Service..."
|
||||||
|
$NTPService = $ESXiHost | Get-VMHostService| Where-Object {$_.key -eq "ntpd"}
|
||||||
|
if($NTPService.Running -eq $True){
|
||||||
|
Stop-VMHostService -HostService $NTPService -Confirm:$false | Out-Null
|
||||||
|
}
|
||||||
|
if($NTPService.Policy -ne "on"){
|
||||||
|
Set-VMHostService -HostService $NTPService -Policy "on" -confirm:$False | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
My-Logger "Configure Local Time..."
|
||||||
|
$HostTimeSystem = Get-View $ESXiHost.ExtensionData.ConfigManager.DateTimeSystem
|
||||||
|
$HostTimeSystem.UpdateDateTime([DateTime]::UtcNow)
|
||||||
|
|
||||||
|
My-Logger "Start NTP Service..."
|
||||||
|
Start-VMHostService -HostService $NTPService -confirm:$False | Out-Null
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region: Remove default PG
|
||||||
|
My-Logger "Checking for Default Port Group ..."
|
||||||
|
if ($defaultPG = $ESXiHost | Get-VirtualSwitch -Name vSwitch0 | Get-VirtualPortGroup -Name "VM Network" -ErrorAction SilentlyContinue ){
|
||||||
|
Remove-VirtualPortGroup -VirtualPortGroup $defaultPG -confirm:$False | Out-Null
|
||||||
|
My-Logger " Default PG Removed"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
My-Logger " No Default PG found"
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region: Configure Static HighPower
|
||||||
|
My-Logger "Setting PowerProfile to Static HighPower..."
|
||||||
|
try {
|
||||||
|
$HostView = ($ESXiHost | Get-View)
|
||||||
|
(Get-View $HostView.ConfigManager.PowerSystem).ConfigurePowerPolicy(1)
|
||||||
|
}
|
||||||
|
catch [System.Exception] {
|
||||||
|
Write-Warning "Error during Configure Static HighPower. See latest errors..."
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region: Conf Syslog
|
||||||
|
My-Logger "Setting Syslog Firewall Rule ..."
|
||||||
|
$SyslogFW = ($ESXiHost | Get-VMHostFirewallException | where {$_.Name -eq 'syslog'})
|
||||||
|
if ($SyslogFW.Enabled -eq $False ){
|
||||||
|
$SyslogFW | Set-VMHostFirewallException -Enabled:$true -Confirm:$false | Out-Null
|
||||||
|
My-Logger " Syslog Firewall Rule enabled"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
My-Logger " Syslog Firewall Rule already enabled"
|
||||||
|
}
|
||||||
|
My-Logger "Setting Syslog Server..."
|
||||||
|
Set-MyESXiOption -Name "Syslog.global.logHost" -Value $syslog
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region: Change Disk Scheduler
|
||||||
|
My-Logger "Changing Disk Scheduler..."
|
||||||
|
Set-MyESXiOption -Name "Disk.SchedulerWithReservation" -Value "0"
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region: Configure HP 3PAR SATP/PSP Rule
|
||||||
|
My-Logger "Configure HP 3PAR SATP/PSP Rule"
|
||||||
|
$esxcli2 = Get-ESXCLI -VMHost $ESXiHost -V2
|
||||||
|
$arguments = $esxcli2.storage.nmp.satp.rule.add.CreateArgs()
|
||||||
|
$arguments.satp = "VMW_SATP_ALUA"
|
||||||
|
$arguments.psp = "VMW_PSP_RR"
|
||||||
|
$arguments.pspoption = "iops=100"
|
||||||
|
$arguments.claimoption = "tpgs_on"
|
||||||
|
$arguments.vendor = "3PARdata"
|
||||||
|
$arguments.model = "VV"
|
||||||
|
$arguments.description = "HP 3PAR custom SATP Claimrule"
|
||||||
|
try {
|
||||||
|
$esxcli2.storage.nmp.satp.rule.add.Invoke($arguments)
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
Write-Warning "Error during Configure HP 3PAR SATP/PSP Rule. See latest errors..."
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
<Label>User Assignment</Label>
|
<Label>User Assignment</Label>
|
||||||
</TableColumnHeader>
|
</TableColumnHeader>
|
||||||
<TableColumnHeader>
|
<TableColumnHeader>
|
||||||
<Width>8</Width>
|
<Width>7</Width>
|
||||||
<Label>Enabled</Label>
|
<Label>Enabled</Label>
|
||||||
</TableColumnHeader>
|
</TableColumnHeader>
|
||||||
<TableColumnHeader>
|
<TableColumnHeader>
|
||||||
@@ -117,27 +117,27 @@
|
|||||||
<TableControl>
|
<TableControl>
|
||||||
<TableHeaders>
|
<TableHeaders>
|
||||||
<TableColumnHeader>
|
<TableColumnHeader>
|
||||||
<Width>16</Width>
|
<Width>15</Width>
|
||||||
<Label>Machine</Label>
|
<Label>Machine</Label>
|
||||||
</TableColumnHeader>
|
</TableColumnHeader>
|
||||||
<TableColumnHeader>
|
<TableColumnHeader>
|
||||||
<Width>16</Width>
|
<Width>12</Width>
|
||||||
<Label>DesktopPool</Label>
|
<Label>DesktopPool</Label>
|
||||||
</TableColumnHeader>
|
</TableColumnHeader>
|
||||||
<TableColumnHeader>
|
<TableColumnHeader>
|
||||||
<Width>16</Width>
|
<Width>12</Width>
|
||||||
<Label>DNS Name</Label>
|
<Label>DNS Name</Label>
|
||||||
</TableColumnHeader>
|
</TableColumnHeader>
|
||||||
<TableColumnHeader>
|
<TableColumnHeader>
|
||||||
<Width>16</Width>
|
<Width>8</Width>
|
||||||
<Label>User</Label>
|
<Label>User</Label>
|
||||||
</TableColumnHeader>
|
</TableColumnHeader>
|
||||||
<TableColumnHeader>
|
<TableColumnHeader>
|
||||||
<Width>16</Width>
|
<Width>15</Width>
|
||||||
<Label>Host</Label>
|
<Label>Host</Label>
|
||||||
</TableColumnHeader>
|
</TableColumnHeader>
|
||||||
<TableColumnHeader>
|
<TableColumnHeader>
|
||||||
<Width>8</Width>
|
<Width>5</Width>
|
||||||
<Label>Agent</Label>
|
<Label>Agent</Label>
|
||||||
</TableColumnHeader>
|
</TableColumnHeader>
|
||||||
<TableColumnHeader>
|
<TableColumnHeader>
|
||||||
@@ -145,9 +145,8 @@
|
|||||||
<Label>Datastore</Label>
|
<Label>Datastore</Label>
|
||||||
</TableColumnHeader>
|
</TableColumnHeader>
|
||||||
<TableColumnHeader>
|
<TableColumnHeader>
|
||||||
<Width>10</Width>
|
<Width>15</Width>
|
||||||
<Label>Status</Label>
|
<Label>Status</Label>
|
||||||
<Alignment>Right</Alignment>
|
|
||||||
</TableColumnHeader>
|
</TableColumnHeader>
|
||||||
</TableHeaders>
|
</TableHeaders>
|
||||||
<TableRowEntries>
|
<TableRowEntries>
|
||||||
@@ -169,13 +168,13 @@
|
|||||||
<ScriptBlock>$_.ManagedMachineNamesData.HostName</ScriptBlock>
|
<ScriptBlock>$_.ManagedMachineNamesData.HostName</ScriptBlock>
|
||||||
</TableColumnItem>
|
</TableColumnItem>
|
||||||
<TableColumnItem>
|
<TableColumnItem>
|
||||||
<ScriptBlock>$_.Data.AgentVersion</ScriptBlock>
|
<ScriptBlock>$_.Base.AgentVersion</ScriptBlock>
|
||||||
</TableColumnItem>
|
</TableColumnItem>
|
||||||
<TableColumnItem>
|
<TableColumnItem>
|
||||||
<ScriptBlock>$_.ManagedMachineNamesData.DatastorePaths</ScriptBlock>
|
<ScriptBlock>$_.ManagedMachineNamesData.DatastorePaths</ScriptBlock>
|
||||||
</TableColumnItem>
|
</TableColumnItem>
|
||||||
<TableColumnItem>
|
<TableColumnItem>
|
||||||
<ScriptBlock>$_.Data.BasicState</ScriptBlock>
|
<ScriptBlock>$_.Base.BasicState</ScriptBlock>
|
||||||
</TableColumnItem>
|
</TableColumnItem>
|
||||||
</TableColumnItems>
|
</TableColumnItems>
|
||||||
</TableRowEntry>
|
</TableRowEntry>
|
||||||
@@ -212,12 +211,16 @@
|
|||||||
<ScriptBlock>$_.ManagedMachineNamesData.HostName</ScriptBlock>
|
<ScriptBlock>$_.ManagedMachineNamesData.HostName</ScriptBlock>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<Label>Enabled</Label>
|
<Label>Agent</Label>
|
||||||
|
<ScriptBlock>$_.Base.AgentVersion</ScriptBlock>
|
||||||
|
</ListItem>
|
||||||
|
<ListItem>
|
||||||
|
<Label>Datastore</Label>
|
||||||
<ScriptBlock>$_.ManagedMachineNamesData.DatastorePaths</ScriptBlock>
|
<ScriptBlock>$_.ManagedMachineNamesData.DatastorePaths</ScriptBlock>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<Label>Sessions</Label>
|
<Label>Status</Label>
|
||||||
<ScriptBlock>$_.Data.BasicState</ScriptBlock>
|
<ScriptBlock>$_.Base.BasicState</ScriptBlock>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</ListItems>
|
</ListItems>
|
||||||
</ListEntry>
|
</ListEntry>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#Script Module : VMware.Hv.Helper
|
#Script Module : VMware.Hv.Helper
|
||||||
#Version : 1.0
|
#Version : 1.0
|
||||||
|
|
||||||
#Copyright © 2016 VMware, Inc. All Rights Reserved.
|
#Copyright © 2016 VMware, Inc. All Rights Reserved.
|
||||||
|
|
||||||
#Permission is hereby granted, free of charge, to any person obtaining a copy of
|
#Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
#this software and associated documentation files (the "Software"), to deal in
|
#this software and associated documentation files (the "Software"), to deal in
|
||||||
@@ -242,7 +242,7 @@ The Add-HVDesktop adds virtual machines to already exiting pools by using view A
|
|||||||
try {
|
try {
|
||||||
$desktopPool = Get-HVPoolSummary -poolName $poolName -hvServer $hvServer
|
$desktopPool = Get-HVPoolSummary -poolName $poolName -hvServer $hvServer
|
||||||
} catch {
|
} catch {
|
||||||
Write-Error "Make sure Get-HVPool advanced function is loaded, $_"
|
Write-Error "Make sure Get-HVPoolSummary advanced function is loaded, $_"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if ($desktopPool) {
|
if ($desktopPool) {
|
||||||
@@ -1087,7 +1087,7 @@ function Find-HVFarm {
|
|||||||
'farmType' = 'data.type';
|
'farmType' = 'data.type';
|
||||||
}
|
}
|
||||||
|
|
||||||
$parms = $Param
|
$params = $Param
|
||||||
|
|
||||||
$query_service_helper = New-Object VMware.Hv.QueryServiceService
|
$query_service_helper = New-Object VMware.Hv.QueryServiceService
|
||||||
$query = New-Object VMware.Hv.QueryDefinition
|
$query = New-Object VMware.Hv.QueryDefinition
|
||||||
@@ -1097,10 +1097,10 @@ function Find-HVFarm {
|
|||||||
$query.queryEntityType = 'FarmSummaryView'
|
$query.queryEntityType = 'FarmSummaryView'
|
||||||
[VMware.Hv.queryfilter[]]$filterSet = @()
|
[VMware.Hv.queryfilter[]]$filterSet = @()
|
||||||
foreach ($setting in $farmSelectors.Keys) {
|
foreach ($setting in $farmSelectors.Keys) {
|
||||||
if ($null -ne $parms[$setting]) {
|
if ($null -ne $params[$setting]) {
|
||||||
$equalsFilter = New-Object VMware.Hv.QueryFilterEquals
|
$equalsFilter = New-Object VMware.Hv.QueryFilterEquals
|
||||||
$equalsFilter.memberName = $farmSelectors[$setting]
|
$equalsFilter.memberName = $farmSelectors[$setting]
|
||||||
$equalsFilter.value = $parms[$setting]
|
$equalsFilter.value = $params[$setting]
|
||||||
$filterSet += $equalsFilter
|
$filterSet += $equalsFilter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1370,17 +1370,17 @@ function Find-HVPool {
|
|||||||
'provisioningEnabled' = 'desktopSummaryData.provisioningEnabled'
|
'provisioningEnabled' = 'desktopSummaryData.provisioningEnabled'
|
||||||
}
|
}
|
||||||
|
|
||||||
$parms = $Param
|
$params = $Param
|
||||||
|
|
||||||
$query_service_helper = New-Object VMware.Hv.QueryServiceService
|
$query_service_helper = New-Object VMware.Hv.QueryServiceService
|
||||||
$query = New-Object VMware.Hv.QueryDefinition
|
$query = New-Object VMware.Hv.QueryDefinition
|
||||||
|
|
||||||
$wildCard = $false
|
$wildCard = $false
|
||||||
#Only supports wild card '*'
|
#Only supports wild card '*'
|
||||||
if ($parms['PoolName'] -and $parms['PoolName'].contains('*')) {
|
if ($params['PoolName'] -and $params['PoolName'].contains('*')) {
|
||||||
$wildcard = $true
|
$wildcard = $true
|
||||||
}
|
}
|
||||||
if ($parms['PoolDisplayName'] -and $parms['PoolDisplayName'].contains('*')) {
|
if ($params['PoolDisplayName'] -and $params['PoolDisplayName'].contains('*')) {
|
||||||
$wildcard = $true
|
$wildcard = $true
|
||||||
}
|
}
|
||||||
# build the query values
|
# build the query values
|
||||||
@@ -1388,10 +1388,10 @@ function Find-HVPool {
|
|||||||
if (! $wildcard) {
|
if (! $wildcard) {
|
||||||
[VMware.Hv.queryfilter[]]$filterSet = @()
|
[VMware.Hv.queryfilter[]]$filterSet = @()
|
||||||
foreach ($setting in $poolSelectors.Keys) {
|
foreach ($setting in $poolSelectors.Keys) {
|
||||||
if ($null -ne $parms[$setting]) {
|
if ($null -ne $params[$setting]) {
|
||||||
$equalsFilter = New-Object VMware.Hv.QueryFilterEquals
|
$equalsFilter = New-Object VMware.Hv.QueryFilterEquals
|
||||||
$equalsFilter.memberName = $poolSelectors[$setting]
|
$equalsFilter.memberName = $poolSelectors[$setting]
|
||||||
$equalsFilter.value = $parms[$setting]
|
$equalsFilter.value = $params[$setting]
|
||||||
$filterSet += $equalsFilter
|
$filterSet += $equalsFilter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1408,11 +1408,11 @@ function Find-HVPool {
|
|||||||
$queryResults = $query_service_helper.QueryService_Query($services,$query)
|
$queryResults = $query_service_helper.QueryService_Query($services,$query)
|
||||||
$strFilterSet = @()
|
$strFilterSet = @()
|
||||||
foreach ($setting in $poolSelectors.Keys) {
|
foreach ($setting in $poolSelectors.Keys) {
|
||||||
if ($null -ne $parms[$setting]) {
|
if ($null -ne $params[$setting]) {
|
||||||
if ($wildcard -and (($setting -eq 'PoolName') -or ($setting -eq 'PoolDisplayName')) ) {
|
if ($wildcard -and (($setting -eq 'PoolName') -or ($setting -eq 'PoolDisplayName')) ) {
|
||||||
$strFilterSet += '($_.' + $poolSelectors[$setting] + ' -like "' + $parms[$setting] + '")'
|
$strFilterSet += '($_.' + $poolSelectors[$setting] + ' -like "' + $params[$setting] + '")'
|
||||||
} else {
|
} else {
|
||||||
$strFilterSet += '($_.' + $poolSelectors[$setting] + ' -eq "' + $parms[$setting] + '")'
|
$strFilterSet += '($_.' + $poolSelectors[$setting] + ' -eq "' + $params[$setting] + '")'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1844,7 +1844,7 @@ function New-HVFarm {
|
|||||||
Reference to Horizon View Server to query the farms from. If the value is not passed or null then first element from global:DefaultHVServers would be considered inplace of hvServer.
|
Reference to Horizon View Server to query the farms from. If the value is not passed or null then first element from global:DefaultHVServers would be considered inplace of hvServer.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
New-HVFarm -LinkedClone -FarmName 'LCFarmTest' -ParentVM 'Win_Server_2012_R2' -SnapshotVM 'Snap_RDS' -VmFolder 'PoolVM' -HostOrCluster 'cls' -ResourcePool 'cls' -Datastores 'datastore1 (5)' -FarmDisplayName 'LC Farm Test' -Description 'created LC Farm from PS' -EnableProvisioning $true -StopOnProvisioningError $false -NamingPattern "LCFarmVM_PS" -MinReady 1 -MaximumCount 1 -SysPrepName "RDSH_Cust2" -NetBiosName "adviewdev"
|
New-HVFarm -LinkedClone -FarmName 'LCFarmTest' -ParentVM 'Win_Server_2012_R2' -SnapshotVM 'Snap_RDS' -VmFolder 'PoolVM' -HostOrCluster 'cls' -ResourcePool 'cls' -Datastores 'datastore1 (5)' -FarmDisplayName 'LC Farm Test' -Description 'created LC Farm from PS' -EnableProvisioning $true -StopOnProvisioningError $false -NamingPattern "LCFarmVM_PS" -MinReady 1 -MaximumCount 1 -SysPrepName "RDSH_Cust2" -NetBiosName "adviewdev"
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
New-HVFarm -Spec C:\VMWare\Specs\LinkedClone.json
|
New-HVFarm -Spec C:\VMWare\Specs\LinkedClone.json
|
||||||
@@ -3062,7 +3062,7 @@ function New-HVPool {
|
|||||||
try {
|
try {
|
||||||
$sourcePool = Get-HVPoolSummary -poolName $poolName -hvServer $hvServer
|
$sourcePool = Get-HVPoolSummary -poolName $poolName -hvServer $hvServer
|
||||||
} catch {
|
} catch {
|
||||||
Write-Error "Make sure Get-HVPool advanced function is loaded, $_"
|
Write-Error "Make sure Get-HVPoolSummary advanced function is loaded, $_"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if ($sourcePool) {
|
if ($sourcePool) {
|
||||||
@@ -3888,7 +3888,7 @@ function Remove-HVPool {
|
|||||||
try {
|
try {
|
||||||
$myPools = Get-HVPoolSummary -poolName $poolName -hvServer $hvServer
|
$myPools = Get-HVPoolSummary -poolName $poolName -hvServer $hvServer
|
||||||
} catch {
|
} catch {
|
||||||
Write-Error "Make sure Get-HVPool advanced function is loaded, $_"
|
Write-Error "Make sure Get-HVPoolSummary advanced function is loaded, $_"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if ($myPools) {
|
if ($myPools) {
|
||||||
@@ -4258,7 +4258,7 @@ function Set-HVPool {
|
|||||||
try {
|
try {
|
||||||
$desktopPools = Get-HVPoolSummary -poolName $poolName -hvServer $hvServer
|
$desktopPools = Get-HVPoolSummary -poolName $poolName -hvServer $hvServer
|
||||||
} catch {
|
} catch {
|
||||||
Write-Error "Make sure Get-HVPool advanced function is loaded, $_"
|
Write-Error "Make sure Get-HVPoolSummary advanced function is loaded, $_"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if ($desktopPools) {
|
if ($desktopPools) {
|
||||||
@@ -4767,7 +4767,7 @@ function Start-HVPool {
|
|||||||
try {
|
try {
|
||||||
$poolObj = Get-HVPoolSummary -poolName $item -hvServer $hvServer
|
$poolObj = Get-HVPoolSummary -poolName $item -hvServer $hvServer
|
||||||
} catch {
|
} catch {
|
||||||
Write-Error "Make sure Get-HVPool advanced function is loaded, $_"
|
Write-Error "Make sure Get-HVPoolSummary advanced function is loaded, $_"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if ($poolObj) {
|
if ($poolObj) {
|
||||||
@@ -4943,4 +4943,322 @@ function Get-HVTaskSpec {
|
|||||||
return $spec
|
return $spec
|
||||||
}
|
}
|
||||||
|
|
||||||
Export-ModuleMember Add-HVDesktop,Add-HVRDSServer,Connect-HVEvent,Disconnect-HVEvent,Get-HVEvent,Get-HVFarm,Get-HVFarmSummary,Get-HVPool,Get-HVPoolSummary,Get-HVQueryResult,Get-HVQueryFilter,New-HVFarm,New-HVPool,Remove-HVFarm,Remove-HVPool,Set-HVFarm,Set-HVPool,Start-HVFarm,Start-HVPool
|
function Find-HVMachine {
|
||||||
|
[CmdletBinding()]
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $true)]
|
||||||
|
$Param
|
||||||
|
)
|
||||||
|
|
||||||
|
$params = $Param
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($params['PoolName']) {
|
||||||
|
$poolObj = Get-HVPoolSummary -poolName $params['PoolName'] -hvServer $params['HvServer']
|
||||||
|
if ($poolObj.Length -ne 1) {
|
||||||
|
Write-Host "Failed to retrieve specific pool object with given PoolName : "$params['PoolName']
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
$desktopId = $poolObj.Id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Write-Error "Make sure Get-HVPoolSummary advanced function is loaded, $_"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
#
|
||||||
|
# This translates the function arguments into the View API properties that must be queried
|
||||||
|
$machineSelectors = @{
|
||||||
|
'PoolName' = 'base.desktop';
|
||||||
|
'MachineName' = 'base.name';
|
||||||
|
'DnsName' = 'base.dnsName';
|
||||||
|
'State' = 'base.basicState';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$query_service_helper = New-Object VMware.Hv.QueryServiceService
|
||||||
|
$query = New-Object VMware.Hv.QueryDefinition
|
||||||
|
|
||||||
|
$wildCard = $false
|
||||||
|
#Only supports wild card '*'
|
||||||
|
if ($params['MachineName'] -and $params['MachineName'].contains('*')) {
|
||||||
|
$wildcard = $true
|
||||||
|
}
|
||||||
|
if ($params['DnsName'] -and $params['DnsName'].contains('*')) {
|
||||||
|
$wildcard = $true
|
||||||
|
}
|
||||||
|
# build the query values, MachineNamesView is having more info than
|
||||||
|
# MachineSummaryView
|
||||||
|
$query.queryEntityType = 'MachineNamesView'
|
||||||
|
if (! $wildcard) {
|
||||||
|
[VMware.Hv.queryfilter[]]$filterSet = @()
|
||||||
|
foreach ($setting in $machineSelectors.Keys) {
|
||||||
|
if ($null -ne $params[$setting]) {
|
||||||
|
$equalsFilter = New-Object VMware.Hv.QueryFilterEquals
|
||||||
|
$equalsFilter.memberName = $machineSelectors[$setting]
|
||||||
|
if ($equalsFilter.memberName -eq 'base.desktop') {
|
||||||
|
$equalsFilter.value = $desktopId
|
||||||
|
} else {
|
||||||
|
$equalsFilter.value = $params[$setting]
|
||||||
|
}
|
||||||
|
$filterSet += $equalsFilter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($filterSet.Count -gt 0) {
|
||||||
|
$andFilter = New-Object VMware.Hv.QueryFilterAnd
|
||||||
|
$andFilter.Filters = $filterset
|
||||||
|
$query.Filter = $andFilter
|
||||||
|
}
|
||||||
|
$queryResults = $query_service_helper.QueryService_Query($services,$query)
|
||||||
|
$machineList = $queryResults.results
|
||||||
|
}
|
||||||
|
if ($wildcard -or [string]::IsNullOrEmpty($machineList)) {
|
||||||
|
$query.Filter = $null
|
||||||
|
$queryResults = $query_service_helper.QueryService_Query($services,$query)
|
||||||
|
$strFilterSet = @()
|
||||||
|
foreach ($setting in $machineSelectors.Keys) {
|
||||||
|
if ($null -ne $params[$setting]) {
|
||||||
|
if ($wildcard -and (($setting -eq 'MachineName') -or ($setting -eq 'DnsName')) ) {
|
||||||
|
$strFilterSet += '($_.' + $machineSelectors[$setting] + ' -like "' + $params[$setting] + '")'
|
||||||
|
} else {
|
||||||
|
$strFilterSet += '($_.' + $machineSelectors[$setting] + ' -eq "' + $params[$setting] + '")'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$whereClause = [string]::Join(' -and ', $strFilterSet)
|
||||||
|
$scriptBlock = [Scriptblock]::Create($whereClause)
|
||||||
|
$machineList = $queryResults.results | where $scriptBlock
|
||||||
|
}
|
||||||
|
return $machineList
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function Get-HVMachine {
|
||||||
|
<#
|
||||||
|
.Synopsis
|
||||||
|
Gets virtual Machine(s) information with given search parameters.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Queries and returns virtual machines information, the machines list would be determined
|
||||||
|
based on queryable fields poolName, dnsName, machineName, state. When more than one
|
||||||
|
fields are used for query the virtual machines which satisfy all fields criteria would be returned.
|
||||||
|
|
||||||
|
.PARAMETER PoolName
|
||||||
|
Pool name to query for.
|
||||||
|
If the value is null or not provided then filter will not be applied,
|
||||||
|
otherwise the virtual machines which has name same as value will be returned.
|
||||||
|
|
||||||
|
.PARAMETER MachineName
|
||||||
|
The name of the Machine to query for.
|
||||||
|
If the value is null or not provided then filter will not be applied,
|
||||||
|
otherwise the virtual machines which has display name same as value will be returned.
|
||||||
|
|
||||||
|
.PARAMETER DnsName
|
||||||
|
DNS name for the Machine to filter with.
|
||||||
|
If the value is null or not provided then filter will not be applied,
|
||||||
|
otherwise the virtual machines which has display name same as value will be returned.
|
||||||
|
|
||||||
|
.PARAMETER State
|
||||||
|
The basic state of the Machine to filter with.
|
||||||
|
If the value is null or not provided then filter will not be applied,
|
||||||
|
otherwise the virtual machines which has display name same as value will be returned.
|
||||||
|
|
||||||
|
.PARAMETER HvServer
|
||||||
|
Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then
|
||||||
|
first element from global:DefaultHVServers would be considered inplace of hvServer
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-HVDesktop -PoolName 'ManualPool'
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-HVDesktop -MachineName 'PowerCLIVM'
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-HVDesktop -State CUSTOMIZING
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-HVDesktop -DnsName 'powercli-*' -State CUSTOMIZING
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
Returns list of objects of type MachineInfo
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Author : Praveen Mathamsetty.
|
||||||
|
Author email : pmathamsetty@vmware.com
|
||||||
|
Version : 1.1
|
||||||
|
|
||||||
|
===Tested Against Environment====
|
||||||
|
Horizon View Server Version : 7.0.2, 7.0.3
|
||||||
|
PowerCLI Version : PowerCLI 6.5
|
||||||
|
PowerShell Version : 5.0
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = 'High'
|
||||||
|
)]
|
||||||
|
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[string]
|
||||||
|
$PoolName,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[string]
|
||||||
|
$MachineName,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[string]
|
||||||
|
$DnsName,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateSet('PROVISIONING','PROVISIONING_ERROR','WAIT_FOR_AGENT','CUSTOMIZING',
|
||||||
|
'DELETING','MAINTENANCE','ERROR','PROVISIONED','AGENT_UNREACHABLE','UNASSIGNED_USER_CONNECTED',
|
||||||
|
'CONNECTED','UNASSIGNED_USER_DISCONNECTED','DISCONNECTED','AGENT_ERR_STARTUP_IN_PROGRESS',
|
||||||
|
'AGENT_ERR_DISABLED','AGENT_ERR_INVALID_IP','AGENT_ERR_NEED_REBOOT','AGENT_ERR_PROTOCOL_FAILURE',
|
||||||
|
'AGENT_ERR_DOMAIN_FAILURE','AGENT_CONFIG_ERROR','ALREADY_USED','AVAILABLE','IN_PROGRESS','DISABLED',
|
||||||
|
'DISABLE_IN_PROGRESS','VALIDATING','UNKNOWN')]
|
||||||
|
[string]
|
||||||
|
$State,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[string]
|
||||||
|
$JsonFilePath,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
$HvServer = $null
|
||||||
|
)
|
||||||
|
|
||||||
|
$services = Get-ViewAPIService -hvServer $hvServer
|
||||||
|
if ($null -eq $services) {
|
||||||
|
Write-Error "Could not retrieve ViewApi services from connection object"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
$machineList = Find-HVMachine -Param $PSBoundParameters
|
||||||
|
if (!$machineList) {
|
||||||
|
Write-Host "No Virtual Machine(s) Found with given search parameters"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
$queryResults = @()
|
||||||
|
$desktop_helper = New-Object VMware.Hv.MachineService
|
||||||
|
foreach ($id in $machineList.id) {
|
||||||
|
$info = $desktop_helper.Machine_Get($services,$id)
|
||||||
|
$queryResults += $info
|
||||||
|
}
|
||||||
|
$machineList = $queryResults
|
||||||
|
return $machineList
|
||||||
|
}
|
||||||
|
|
||||||
|
function Get-HVMachineSummary {
|
||||||
|
<#
|
||||||
|
.Synopsis
|
||||||
|
Gets virtual Machine(s) summary with given search parameters.
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Queries and returns virtual machines information, the machines list would be determined
|
||||||
|
based on queryable fields poolName, dnsName, machineName, state. When more than one
|
||||||
|
fields are used for query the virtual machines which satisfy all fields criteria would be returned.
|
||||||
|
|
||||||
|
.PARAMETER PoolName
|
||||||
|
Pool name to query for.
|
||||||
|
If the value is null or not provided then filter will not be applied,
|
||||||
|
otherwise the virtual machines which has name same as value will be returned.
|
||||||
|
|
||||||
|
.PARAMETER MachineName
|
||||||
|
The name of the Machine to query for.
|
||||||
|
If the value is null or not provided then filter will not be applied,
|
||||||
|
otherwise the virtual machines which has display name same as value will be returned.
|
||||||
|
|
||||||
|
.PARAMETER DnsName
|
||||||
|
DNS name for the Machine to filter with.
|
||||||
|
If the value is null or not provided then filter will not be applied,
|
||||||
|
otherwise the virtual machines which has display name same as value will be returned.
|
||||||
|
|
||||||
|
.PARAMETER State
|
||||||
|
The basic state of the Machine to filter with.
|
||||||
|
If the value is null or not provided then filter will not be applied,
|
||||||
|
otherwise the virtual machines which has display name same as value will be returned.
|
||||||
|
|
||||||
|
.PARAMETER HvServer
|
||||||
|
Reference to Horizon View Server to query the virtual machines from. If the value is not passed or null then
|
||||||
|
first element from global:DefaultHVServers would be considered inplace of hvServer
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-HVDesktopSummary -PoolName 'ManualPool'
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-HVDesktopSummary -MachineName 'PowerCLIVM'
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-HVDesktopSummary -State CUSTOMIZING
|
||||||
|
|
||||||
|
.EXAMPLE
|
||||||
|
Get-HVDesktopSummary -DnsName 'powercli-*' -State CUSTOMIZING
|
||||||
|
|
||||||
|
.OUTPUTS
|
||||||
|
Returns list of objects of type MachineNamesView
|
||||||
|
|
||||||
|
.NOTES
|
||||||
|
Author : Praveen Mathamsetty.
|
||||||
|
Author email : pmathamsetty@vmware.com
|
||||||
|
Version : 1.1
|
||||||
|
|
||||||
|
===Tested Against Environment====
|
||||||
|
Horizon View Server Version : 7.0.2, 7.0.3
|
||||||
|
PowerCLI Version : PowerCLI 6.5
|
||||||
|
PowerShell Version : 5.0
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(
|
||||||
|
SupportsShouldProcess = $true,
|
||||||
|
ConfirmImpact = 'High'
|
||||||
|
)]
|
||||||
|
|
||||||
|
param(
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[string]
|
||||||
|
$PoolName,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[string]
|
||||||
|
$MachineName,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[string]
|
||||||
|
$DnsName,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[ValidateSet('PROVISIONING','PROVISIONING_ERROR','WAIT_FOR_AGENT','CUSTOMIZING',
|
||||||
|
'DELETING','MAINTENANCE','ERROR','PROVISIONED','AGENT_UNREACHABLE','UNASSIGNED_USER_CONNECTED',
|
||||||
|
'CONNECTED','UNASSIGNED_USER_DISCONNECTED','DISCONNECTED','AGENT_ERR_STARTUP_IN_PROGRESS',
|
||||||
|
'AGENT_ERR_DISABLED','AGENT_ERR_INVALID_IP','AGENT_ERR_NEED_REBOOT','AGENT_ERR_PROTOCOL_FAILURE',
|
||||||
|
'AGENT_ERR_DOMAIN_FAILURE','AGENT_CONFIG_ERROR','ALREADY_USED','AVAILABLE','IN_PROGRESS','DISABLED',
|
||||||
|
'DISABLE_IN_PROGRESS','VALIDATING','UNKNOWN')]
|
||||||
|
[string]
|
||||||
|
$State,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
[string]
|
||||||
|
$JsonFilePath,
|
||||||
|
|
||||||
|
[Parameter(Mandatory = $false)]
|
||||||
|
$HvServer = $null
|
||||||
|
)
|
||||||
|
|
||||||
|
$services = Get-ViewAPIService -hvServer $hvServer
|
||||||
|
if ($null -eq $services) {
|
||||||
|
Write-Error "Could not retrieve ViewApi services from connection object"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
$machineList = Find-HVMachine -Param $PSBoundParameters
|
||||||
|
if (!$machineList) {
|
||||||
|
Write-Host "No Virtual Machine(s) Found with given search parameters"
|
||||||
|
break
|
||||||
|
}
|
||||||
|
return $machineList
|
||||||
|
}
|
||||||
|
|
||||||
|
Export-ModuleMember Add-HVDesktop,Add-HVRDSServer,Connect-HVEvent,Disconnect-HVEvent,Get-HVEvent,Get-HVFarm,Get-HVFarmSummary,Get-HVPool,Get-HVPoolSummary,Get-HVMachine,Get-HVMachineSummary,Get-HVQueryResult,Get-HVQueryFilter,New-HVFarm,New-HVPool,Remove-HVFarm,Remove-HVPool,Set-HVFarm,Set-HVPool,Start-HVFarm,Start-HVPool
|
||||||
|
|
||||||
|
|||||||
7
Modules/VMware.VMEncryption/README.md
Normal file
7
Modules/VMware.VMEncryption/README.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Prerequisites/Steps to use this module:
|
||||||
|
|
||||||
|
1. This module only works for vSphere products that support VM Encryption. E.g. vSphere 6.5 and later.
|
||||||
|
2. All the functions in this module only work for KMIP Servers.
|
||||||
|
3. Install the latest version of Powershell and PowerCLI(6.5).
|
||||||
|
4. Import this module by running: Import-Module -Name "location of this module"
|
||||||
|
5. Get-Command -Module "This module Name" to list all available functions.
|
||||||
BIN
Modules/VMware.VMEncryption/VMware.VMEncryption.psd1
Normal file
BIN
Modules/VMware.VMEncryption/VMware.VMEncryption.psd1
Normal file
Binary file not shown.
2107
Modules/VMware.VMEncryption/VMware.VMEncryption.psm1
Normal file
2107
Modules/VMware.VMEncryption/VMware.VMEncryption.psm1
Normal file
File diff suppressed because it is too large
Load Diff
@@ -58,7 +58,7 @@ function Set-DatastoreSIOCStatCollection {
|
|||||||
.PARAMETER Datastore
|
.PARAMETER Datastore
|
||||||
Datastore to be ran against
|
Datastore to be ran against
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Set-DatastoreSIOCStatCollection -Datastore ExampleDatastore -Enable $true
|
Set-DatastoreSIOCStatCollection -Datastore ExampleDatastore -Enable
|
||||||
Enables SIOC statistics collection for the provided datastore
|
Enables SIOC statistics collection for the provided datastore
|
||||||
#>
|
#>
|
||||||
[CmdletBinding(SupportsShouldProcess)]
|
[CmdletBinding(SupportsShouldProcess)]
|
||||||
@@ -105,4 +105,4 @@ function Set-DatastoreSIOCStatCollection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user