├── .vscode └── settings.json ├── CloneTemplateToClusters.ps1 ├── CloneVMs.ps1 ├── ConfigvCenter ├── ConfigvCenter.ps1 ├── README.md ├── applyhostprofile.csv ├── createcluster.csv ├── createdatacenter.csv ├── createdatastores.csv └── createhosts.csv ├── Deploy-ContentLibraryVM.ps1 ├── Detach-SCSILun.ps1 ├── Disable-MigrateSdpsEnabled.ps1 ├── ExtendVMDKandGuest.ps1 ├── Get-CPUMemHDD.ps1 ├── Get-ClusterCapacityCheck.ps1 ├── Get-ENICandFNIC.ps1 ├── Get-FibreChannelPaths.ps1 ├── Get-HostiSCSIIQN.ps1 ├── Get-IScsiPaths.ps1 ├── Get-LLDPCDPInfo.ps1 ├── Get-LastViewLogon.ps1 ├── Get-NICAndFirmware.ps1 ├── Get-VMSnapshots.ps1 ├── Get-VMwareTrafficShapingSettings.ps1 ├── GetHostPathStatus.ps1 ├── GetPathStatus.ps1 ├── Install-HostVIB.ps1 ├── InstallVMSoftware.ps1 ├── ReloadSyslog.ps1 ├── Set-MaxDiskIO.ps1 ├── Set-VMwareTrafficShapingSettings.ps1 ├── Set-vCenterPermissions.ps1 ├── SetNTP.ps1 ├── SetSyslog.ps1 ├── UpgradeVDS.ps1 ├── deploy-pureova.ps1 ├── deploy-srm83.ps1 ├── permissions.csv ├── powercli_purestorage └── configurestorage.ps1 └── publish_code_to_github.sh /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.fontFamily": "Menlo, Monaco, 'Courier New', monospace", 3 | "editor.fontSize": 12, 4 | "editor.fontWeight": "normal", 5 | "editor.formatOnSave": false, 6 | "workbench.colorTheme": "GitHub Dark" 7 | } -------------------------------------------------------------------------------- /CloneTemplateToClusters.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script For Cloning Templates to Multiple Datastores 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | #Import PowerCLI Module 6 | Add-PSSnapin VMware.VimAutomation.Core 7 | 8 | #Define Variables 9 | $Credential = Get-Credential 10 | $vCenter = "vcenter.lab.local" 11 | $clusters = "Cluster01","Cluster02" 12 | $location = "Templates" 13 | $templates = "Template1","Template2" 14 | 15 | #Connect to vCenter 16 | Connect-VIServer $vCenter -Credential $Credential 17 | 18 | foreach ($template in $templates){ 19 | foreach ($cluster in $clusters){ 20 | #Check if Template exists 21 | Try{Get-Template $template-$cluster -ErrorAction Stop;$TemplateExists = $true}Catch {$TemplateExists = $false} 22 | #Create VM 23 | If($TemplateExists -eq $true){ 24 | #Remove Old Template 25 | Get-Template -Name $template-$cluster |Remove-Template -DeletePermanently -Confirm:$false 26 | #Clone the Template 27 | New-VM -Name $template-$cluster -Template $template -ResourcePool $cluster -Datastore $cluster-DSC -Location $location 28 | #Convert to Template 29 | Set-VM -VM $template-$cluster -ToTemplate -Confirm:$false 30 | } 31 | ElseIf($TemplateExists -eq $false){ 32 | #Clone the Template 33 | New-VM -Name $template-$cluster -Template $template -ResourcePool $cluster -Datastore $cluster-DSC -Location $location 34 | #Convert to Template 35 | Set-VM -VM $template-$cluster -ToTemplate -Confirm:$false 36 | } 37 | } 38 | } 39 | #Disconnect from vCenter 40 | Disconnect-VIServer $vCenter -Force -Confirm:$false 41 | -------------------------------------------------------------------------------- /CloneVMs.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for cloning VMs and customizing disk, cpu and memory 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | $vmlist = Import-CSV '.\VMs.csv' 6 | 7 | foreach ($item in $vmlist) { 8 | $basevm = $item.basevm 9 | $datastore = $item.datastore 10 | $vmcluster = $item.vmcluster 11 | $custspec = $item.custspec 12 | $vmname = $item.vmname 13 | $ipaddr = $item.ipaddress 14 | $subnet = $item.subnet 15 | $gateway = $item.gateway 16 | $pdns = $item.pdns 17 | $sdns = $item.sdns 18 | $vlan = $item.vlan 19 | $sdisk = $item.sdisk 20 | $folder = $item.folder 21 | $totalcpu = $item.totalcpu 22 | $corespersocket = $item.corespersocket 23 | $memorygb = $item.memorygb 24 | 25 | #Get the Specification and set the Nic Mapping 26 | Get-OSCustomizationSpec $custspec | Get-OSCustomizationNicMapping | Set-OSCustomizationNicMapping -IpMode UseStaticIp -IpAddress $ipaddr -SubnetMask $subnet -DefaultGateway $gateway -Dns $pdns,$sdns 27 | 28 | #Clone the BaseVM with the adjusted Customization Specification 29 | New-VM -Name $vmname -Location $folder -VM $basevm -Datastore $datastore -ResourcePool $vmcluster -OSCustomizationSpec $custspec 30 | Get-NetworkAdapter -VM $vmname|Set-NetworkAdapter -NetworkName $vlan -confirm:$false 31 | #Add second disk if one is listed 32 | if ($sdisk -gt "1") { 33 | New-HardDisk -vm $vmname -CapacityGB $sdisk -Datastore $datastore -StorageFormat "EagerZeroedThick" 34 | } 35 | #adjust number of cpu's and sockets 36 | $spec = new-object -typename VMware.VIM.virtualmachineconfigspec -property @{'numcorespersocket'=$corespersocket;'numCPUs'=$totalcpu} 37 | (Get-VM $vmname).ExtensionData.ReconfigVM_Task($spec) 38 | 39 | #adjust memory allocation 40 | Set-VM -VM $vmname -MemoryGB $memorygb -confirm:$false 41 | } 42 | -------------------------------------------------------------------------------- /ConfigvCenter/ConfigvCenter.ps1: -------------------------------------------------------------------------------- 1 | # Variables 2 | $vcenter = "vc.lab.local" 3 | $esxusername = "root" 4 | $esxpassword = "password" 5 | $DSC = "DSC01" 6 | $Datacenter = "Lab" 7 | 8 | #Connect to vCenter 9 | #Connect-VIServer -Server $vCenter 10 | 11 | # Create Datacenters 12 | Write-Host "Creating Datacenter" -ForegroundColor "Green" 13 | $csv = Import-CSV .\createdatacenter.csv 14 | foreach ($datacenter in $csv) { 15 | New-Datacenter -Location (Get-Folder -NoRecursion) -Name $datacenter.Name 16 | } 17 | 18 | # Create Clusters 19 | Write-Host "Creating Clusters" -ForegroundColor "Green" 20 | $csv = Import-CSV .\createcluster.csv 21 | foreach ($cluster in $csv) { 22 | New-Cluster -Name $cluster.Name -Location $cluster.Datacenter -DRSEnabled -DrsAutomationLevel FullyAutomated -HAEnabled 23 | } 24 | 25 | # Create Clusters 26 | Write-Host "Adding Hosts" -ForegroundColor "Green" 27 | $csv = Import-CSV .\createhosts.csv 28 | foreach ($vmhost in $csv) { 29 | Add-VMHost -Name $vmhost.Name -Location $vmhost.Cluster -User $esxusername -Password $esxpassword 30 | Set-VMHost -VMHost $vmhost.Name -State Maintenance 31 | } 32 | 33 | # Create Datastores 34 | Write-Host "Creating Datastores" -ForegroundColor "Green" 35 | $csv = Import-CSV .\createdatastores.csv 36 | foreach ($datastore in $csv) { 37 | New-Datastore -VMHost $datastore.host -Name $datastore.Name -Path $datastore.NAAID -VMFS 38 | } 39 | 40 | # Create Datastore Cluster and Move Datastores In 41 | Write-Host "Creating Datastore Cluster and Adding Datastores" -ForegroundColor "Green" 42 | $csv = Import-CSV .\createdatastores.csv 43 | New-DatastoreCluster -Name $DSC -Location $Datacenter 44 | foreach ($datastore in $csv) { 45 | Move-Datastore $datastore.Name -Destination $datastore.DatastoreCluster 46 | } 47 | 48 | # Apply HostProfile 49 | Write-Host "Applying HostProfiles" -ForegroundColor "Green" 50 | $csv = Import-CSV .\applyhostprofile.csv 51 | foreach ($hostprofile in $csv) { 52 | Apply-VMHostProfile -Entity $hostprofile.Entity -Profile $hostprofile.Profile -Confirm:$false 53 | } 54 | 55 | Write-Host "Complete!" -ForegroundColor "Green" 56 | -------------------------------------------------------------------------------- /ConfigvCenter/README.md: -------------------------------------------------------------------------------- 1 | Purpose 2 | ======= 3 | The script and CSV files will build out a new vCenter and ESXi Hosts. 4 | 5 | It will create the Datacenter, Create Cluster, Add Hosts, Create Datastores, Move them to a Datastore Cluster and then apply the appropriate host profile to the host. 6 | 7 | Author Information 8 | ================== 9 | 10 | David Stamen 11 | - @davidstamen 12 | - http://davidstamen.com 13 | - dstamen[at]gmail.com 14 | -------------------------------------------------------------------------------- /ConfigvCenter/applyhostprofile.csv: -------------------------------------------------------------------------------- 1 | Entity,Profile 2 | esxi01.lab.local,HostProfile 3 | esxi02.lab.local,HostProfile 4 | esxi03.lab.local,HostProfile -------------------------------------------------------------------------------- /ConfigvCenter/createcluster.csv: -------------------------------------------------------------------------------- 1 | Name,Datacenter 2 | Cluster,Lab -------------------------------------------------------------------------------- /ConfigvCenter/createdatacenter.csv: -------------------------------------------------------------------------------- 1 | Name 2 | Lab -------------------------------------------------------------------------------- /ConfigvCenter/createdatastores.csv: -------------------------------------------------------------------------------- 1 | Name,Host,NAAID,DatastoreCluster 2 | DS01,esxi01.lab.local,t10.9454450000000000D7C22799B6C60708819E432EB8AF1B11,DSC01 3 | DS02,esxi01.lab.local,t10.9454450000000000AE73E392BFE973582F762F73E63A6522,DSC01 4 | DS03,esxi01.lab.local,t10.9454450000000000E0FC43437E8BD3386479F5E3C0033433,DSC01 5 | -------------------------------------------------------------------------------- /ConfigvCenter/createhosts.csv: -------------------------------------------------------------------------------- 1 | Name,Cluster 2 | ESXI01.lab.local,Cluster 3 | ESXI02.lab.local,Cluster 4 | ESXI03.lab.local,Cluster -------------------------------------------------------------------------------- /Deploy-ContentLibraryVM.ps1: -------------------------------------------------------------------------------- 1 | $TemplateName = "template-windows2016" 2 | $VMName = "ContentLibraryVM" 3 | $Datastore = Get-DatastoreCluster "DatastoreCluster" 4 | $Cluster = Get-Cluster "Cluster" 5 | $custspec = Get-OSCustomizationSpec "windows_workgroup" 6 | $ContentLibraryVM = Get-ContentLibraryItem -name $TemplateName |Where-Object {$_.ContentLibrary -like "*$Cluster*"} 7 | New-VM -Datastore $Datastore -ResourcePool $Cluster -Name $VMName -ContentLibraryItem $ContentLibraryVM 8 | if ($TemplateName -eq "template-windows2016") { 9 | Write-Host "Changing GuestId for Windows 2016" -ForegroundColor Green 10 | Set-VM -VM $VMName -GuestId windows9Server64Guest -Confirm:$false 11 | } 12 | Set-VM -VM $VMName -OSCustomizationSpec $custspec -Confirm:$false 13 | Start-VM $VMName -Confirm:$false 14 | -------------------------------------------------------------------------------- /Detach-SCSILun.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for detaching luns from a cluster 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | $LunIDs = "naa.6000000001","naa.600000002" 6 | $Clustername = "MyCluster" 7 | 8 | function Detach-Disk{ 9 | param( 10 | [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl]$VMHost, 11 | [string]$CanonicalName ) 12 | 13 | $storSys = Get-View $VMHost.Extensiondata.ConfigManager.StorageSystem 14 | $lunUuid = (Get-ScsiLun -VmHost $VMHost | where {$_.CanonicalName -eq $CanonicalName}).ExtensionData.Uuid 15 | 16 | $storSys.DetachScsiLun($lunUuid) 17 | } 18 | 19 | ######################################################################################## 20 | 21 | 22 | $ClusterHosts = Get-Cluster $Clustername | Get-VMHost 23 | 24 | Foreach($VMHost in $ClusterHosts) 25 | { 26 | Foreach($LUNid in $LunIDs) 27 | { 28 | Write-Host "Detaching" $LUNid "from" $VMHost -ForegroundColor "Yellow" 29 | Detach-Disk -VMHost $VMHost -CanonicalName $LUNid 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Disable-MigrateSdpsEnabled.ps1: -------------------------------------------------------------------------------- 1 | #Add Snapin 2 | Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue 3 | 4 | #Define Variables 5 | $cred = Get-Credential 6 | $vCenter = "vc.lab.local" 7 | 8 | Connect-VIServer $vCenter -Credential $cred 9 | 10 | Foreach ($hostname in (Get-VMhost)) { 11 | Get-VMhost $hostname | Get-AdvancedSetting -name "Migrate.SdpsEnabled" | Set-AdvancedSetting -Value "0" -confirm:$false 12 | } 13 | Disconnect-VIServer * -Confirm:$false 14 | -------------------------------------------------------------------------------- /ExtendVMDKandGuest.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for adding vmdk to VM and extending disk in windows 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | param( 6 | [string]$VM 7 | ) 8 | $VM = Get-VM $VM 9 | Get-VM $VM|Get-HardDisk|FT Parent, Name, CapacityGB -Autosize 10 | $HardDisk = Read-Host "Enter VMware Hard Disk (Ex. 1)" 11 | $HardDisk = "Hard Disk " + $HardDisk 12 | $HardDiskSize = Read-Host "Enter the new Hard Disk size in GB (Ex. 50)" 13 | $VolumeLetter = Read-Host "Enter the volume letter (Ex. c,d,e,f)" 14 | Get-HardDisk -vm $VM | where {$_.Name -eq $HardDisk} | Set-HardDisk -CapacityGB $HardDiskSize -Confirm:$false 15 | Invoke-VMScript -vm $VM -ScriptText "echo rescan > c:\diskpart.txt && echo select vol $VolumeLetter >> c:\diskpart.txt && echo extend >> c:\diskpart.txt && diskpart.exe /s c:\diskpart.txt" -ScriptType BAT 16 | -------------------------------------------------------------------------------- /Get-CPUMemHDD.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for getting total amount of resouces within a vCenter 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | #Define Variables 6 | $cred = Get-Credential 7 | $VC = "vc.lab.local" 8 | $Location = "Production" 9 | 10 | #Connect to vCenter 11 | Connect-VIServer $VC -Credential $cred 12 | 13 | #Populate VM's based on Location (Cluster, ResourcePool, Host) 14 | $VMs = Get-VM -Location $Location 15 | 16 | $TotalVMs = $VMs | Measure-Object 17 | $TotalCPU = $VMs | Measure-Object -Sum -Property NumCPU | Select Sum 18 | $TotalMem = $VMs | Measure-Object -Sum -Property MemoryGB | Select Sum 19 | $TotalHDD = $VMs | Measure-Object -Sum -Property ProvisionedSpaceGB 20 | 21 | #Write results to screen 22 | Write-Host "In" $VC $Location "has" $TotalVMs.Count "VM's," $TotalCPU.Sum "CPU's," $TotalMem.Sum "GB of RAM," and $TotalHDD.Sum "GB of HDD allocated" 23 | -------------------------------------------------------------------------------- /Get-ClusterCapacityCheck.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Retrieves basic capacity info for VMware clusters 4 | 5 | .DESCRIPTION 6 | Retrieves basic capacity info for VMware clusters 7 | 8 | .PARAMETER ClusterName 9 | Name of the computer to test the services for 10 | 11 | .EXAMPLE 12 | PS C:\> Get-ClusterCapacityCheck -ClusterName Cluster01 13 | 14 | .EXAMPLE 15 | PS C:\> Get-Cluster | Get-ClusterCapacityCheck 16 | 17 | .NOTES 18 | Author: Jonathan Medd 19 | Date: 18/01/2012 20 | #> 21 | 22 | [CmdletBinding()] 23 | param( 24 | [Parameter(Position=0,Mandatory=$true,HelpMessage="Name of the cluster to test", 25 | ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$true)] 26 | [System.String] 27 | $ClusterName 28 | ) 29 | 30 | begin { 31 | $Finish = (Get-Date -Hour 0 -Minute 0 -Second 0) 32 | $Start = $Finish.AddDays(-1).AddSeconds(1) 33 | } 34 | 35 | process { 36 | 37 | $Cluster = Get-Cluster $ClusterName 38 | 39 | $ClusterCPUCores = $Cluster.ExtensionData.Summary.NumCpuCores 40 | $ClusterEffectiveMemoryGB = [math]::round(($Cluster.ExtensionData.Summary.EffectiveMemory / 1KB),0) 41 | 42 | $ClusterVMs = $Cluster | Get-VM 43 | 44 | $ClusterAllocatedvCPUs = ($ClusterVMs | Measure-Object -Property NumCPu -Sum).Sum 45 | $ClusterAllocatedMemoryGB = [math]::round(($ClusterVMs | Measure-Object -Property MemoryMB -Sum).Sum / 1KB) 46 | 47 | $ClustervCPUpCPURatio = [math]::round($ClusterAllocatedvCPUs / $ClusterCPUCores,2) 48 | $ClusterActiveMemoryPercentage = [math]::round(($Cluster | Get-Stat -Stat mem.usage.average -Start $Start -Finish $Finish | Measure-Object -Property Value -Average).Average,0) 49 | 50 | $VMHost = $Cluster | Get-VMHost | Select-Object -Last 1 51 | 52 | New-Object -TypeName PSObject -Property @{ 53 | Cluster = $Cluster.Name 54 | ClusterCPUCores = $ClusterCPUCores 55 | ClusterAllocatedvCPUs = $ClusterAllocatedvCPUs 56 | ClustervCPUpCPURatio = $ClustervCPUpCPURatio 57 | ClusterEffectiveMemoryGB = $ClusterEffectiveMemoryGB 58 | ClusterAllocatedMemoryGB = $ClusterAllocatedMemoryGB 59 | ClusterActiveMemoryPercentage = $ClusterActiveMemoryPercentage 60 | ClusterFreeDiskspaceGB = $ClusterFreeDiskspaceGB 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Get-ENICandFNIC.ps1: -------------------------------------------------------------------------------- 1 | $vmhs = Get-Cluster | Get-VMHost | sort Name 2 | foreach ($vmh in $vmhs){ 3 | Write-Host $vmh.Name " - " $vmh.build -ForegroundColor Green 4 | $esxcli = Get-EsxCli -VMHost $vmh 5 | $face = $esxcli.software.vib.list() 6 | $esxcli.system.module.get("enic").version 7 | $esxcli.system.module.get("fnic").version 8 | Write-Host "" 9 | } 10 | -------------------------------------------------------------------------------- /Get-FibreChannelPaths.ps1: -------------------------------------------------------------------------------- 1 | $VMHosts = Get-VMHost | ? { $_.ConnectionState -eq "Connected" } | Sort-Object -Property Name 2 | $results= @() 3 | 4 | foreach ($VMHost in $VMHosts) { 5 | [ARRAY]$HBAs = $VMHost | Get-VMHostHba -Type "FibreChannel" 6 | 7 | foreach ($HBA in $HBAs) { 8 | $pathState = $HBA | Get-ScsiLun | Get-ScsiLunPath | Group-Object -Property state 9 | $pathStateActive = $pathState | ? { $_.Name -eq "Active"} 10 | $pathStateDead = $pathState | ? { $_.Name -eq "Dead"} 11 | $pathStateStandby = $pathState | ? { $_.Name -eq "Standby"} 12 | $results += "{0},{1},{2},{3},{4},{5}" -f $VMHost.Name, $HBA.Device, $VMHost.Parent, [INT]$pathStateActive.Count, [INT]$pathStateDead.Count, [INT]$pathStateStandby.Count 13 | } 14 | 15 | } 16 | ConvertFrom-Csv -Header "VMHost","HBA","Cluster","Active","Dead","Standby" -InputObject $results | Ft -AutoSize 17 | -------------------------------------------------------------------------------- /Get-HostiSCSIIQN.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for getting the Software iSCSI IQNs 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | # Connect-VIserver your-vcenter-server -user your-user -password your-password 6 | 7 | param($Cluster) ## Input from command line 8 | 9 | if(!($Cluster)) 10 | { 11 | Write-Host -Fore YELLOW "Missing parameter!" 12 | Write-Host -Fore YELLOW "Usage:" 13 | Write-Host -Fore YELLOW ".\Get-HostiSCSIIQN.ps1 " 14 | Write-Host -Fore YELLOW "" 15 | Write-Host -Fore YELLOW "Example: .\Get-HostiSCSIIQN.ps1 LabCluster" 16 | exit 17 | } 18 | if(!(Get-Cluster $Cluster -EA SilentlyContinue)) 19 | { 20 | Write-Host -Fore RED "No cluster found with the name: $Cluster " 21 | Write-Host -Fore YELLOW "These clusters where found in the vCenter you have connected to:" 22 | Get-Cluster | sort Name | Select Name 23 | exit 24 | } 25 | Get-Cluster $Cluster|Get-VMHost|get-VMHostHBA -Type iScsi | Where {$_.Model -eq "iSCSI Software Adapter"}| Select VMhost, IScsiname|Sort-Object VMHost | ft -a 26 | -------------------------------------------------------------------------------- /Get-IScsiPaths.ps1: -------------------------------------------------------------------------------- 1 | $VMHosts = Get-VMHost | ? { $_.ConnectionState -eq "Connected" } | Sort-Object -Property Name 2 | $results= @() 3 | 4 | foreach ($VMHost in $VMHosts) { 5 | [ARRAY]$HBAs = $VMHost | Get-VMHostHba -Type "IScsi" 6 | 7 | foreach ($HBA in $HBAs) { 8 | $pathState = $HBA | Get-ScsiLun | Get-ScsiLunPath | Group-Object -Property state 9 | $pathStateActive = $pathState | ? { $_.Name -eq "Active"} 10 | $pathStateDead = $pathState | ? { $_.Name -eq "Dead"} 11 | $pathStateStandby = $pathState | ? { $_.Name -eq "Standby"} 12 | $results += "{0},{1},{2},{3},{4},{5}" -f $VMHost.Name, $HBA.Device, $VMHost.Parent, [INT]$pathStateActive.Count, [INT]$pathStateDead.Count, [INT]$pathStateStandby.Count 13 | } 14 | 15 | } 16 | ConvertFrom-Csv -Header "VMHost","HBA","Cluster","Active","Dead","Standby" -InputObject $results | Ft -AutoSize 17 | -------------------------------------------------------------------------------- /Get-LLDPCDPInfo.ps1: -------------------------------------------------------------------------------- 1 | ######################################################################################################### 2 | ## LLDP_CDP_Information.ps1 3 | ## Version 1.0 4 | ## Auxilium Technology AS, November 2014 5 | ## http://www.auxilium.no 6 | ## 7 | ## Description: 8 | ## Sometimes it's useful to know which ports your host(s) are connected to. It's also good to know what 9 | ## kind of switch you have to deal with and if possible, get the firmware version. 10 | ## 11 | ## Script created 20.11.2014 12 | ## Bjørn-Ove Kiil (bok@auxilium.no) 13 | ## 14 | ## Requirement: 15 | ## The switches where your host(s) are connected have to support Link Layer Discovery Protocol (LLDP) or 16 | ## Cisco Discovery Protocol (CDP) and this feature must be enabled in order to get any information out 17 | ## of it. 18 | ## PS! LLDP is only available on host(s) which are a member of a Distributed Virtual Switch!! 19 | ## 20 | ## Usage: 21 | ## .\LLDP_CDP_Information.ps1 22 | ## 23 | ## Ex.: .\LLDP_CDP_Information.ps1 LabCluster 24 | ## 25 | ######################################################################################################### 26 | 27 | # Connect-VIserver your-vcenter-server -user your-user -password your-password 28 | 29 | param($Cluster) ## Input from command line 30 | 31 | if(!($Cluster)) 32 | { 33 | Write-Host -Fore YELLOW "Missing parameter!" 34 | Write-Host -Fore YELLOW "Usage:" 35 | Write-Host -Fore YELLOW ".\LLDP_CDP_Information.ps1 " 36 | Write-Host -Fore YELLOW "" 37 | Write-Host -Fore YELLOW "Example: .\LLDP_CDP_Information.ps1 LabCluster" 38 | exit 39 | } 40 | if(!(Get-Cluster $Cluster -EA SilentlyContinue)) 41 | { 42 | Write-Host -Fore RED "No cluster found with the name: $Cluster " 43 | Pause 44 | Write-Host -Fore YELLOW "These clusters where found in the vCenter you have connected to:" 45 | Get-Cluster | sort Name | Select Name 46 | exit 47 | } 48 | 49 | $vmh = Get-Cluster $Cluster | Get-VMHost | sort name 50 | $LLDPResultArray = @() 51 | $CDPResultArray = @() 52 | 53 | If ($vmh.ConnectionState -eq "Connected" -or $vmh.State -eq "Maintenance") 54 | { 55 | Get-View $vmh.ID | ` 56 | % { $esxname = $_.Name; Get-View $_.ConfigManager.NetworkSystem} | ` 57 | % { foreach ($physnic in $_.NetworkInfo.Pnic) { 58 | $pnicInfo = $_.QueryNetworkHint($physnic.Device) 59 | 60 | foreach( $hint in $pnicInfo ) 61 | { 62 | ## If the switch support LLDP, and you're using Distributed Virtual Swicth with LLDP 63 | if ($hint.LLDPInfo) 64 | { 65 | #$hint.LLDPInfo.Parameter 66 | $LLDPResult = "" | select-object VMHost, PhysicalNic, PhysSW_Port, PhysSW_Name, PhysSW_Description, PhysSW_MGMTIP, PhysSW_MTU 67 | 68 | $LLDPResult.VMHost = $esxname 69 | $LLDPResult.PhysicalNic = $physnic.Device 70 | $LLDPResult.PhysSW_Port = ($hint.LLDPInfo.Parameter | ? { $_.Key -eq "Port Description" }).Value 71 | $LLDPResult.PhysSW_Name = ($hint.LLDPInfo.Parameter | ? { $_.Key -eq "System Name" }).Value 72 | $LLDPResult.PhysSW_Description = ($hint.LLDPInfo.Parameter | ? { $_.Key -eq "System Description" }).Value 73 | $LLDPResult.PhysSW_MGMTIP = ($hint.LLDPInfo.Parameter | ? { $_.Key -eq "Management Address" }).Value 74 | $LLDPResult.PhysSW_MTU = ($hint.LLDPInfo.Parameter | ? { $_.Key -eq "MTU" }).Value 75 | 76 | $LLDPResultArray += $LLDPResult 77 | } 78 | 79 | ## If it's a Cisco switch behind the server ;) 80 | if ($hint.ConnectedSwitchPort) 81 | { 82 | #$hint.ConnectedSwitchPort 83 | $CDPResult = "" | select-object VMHost, PhysicalNic, PhysSW_Port, PhysSW_Name, PhysSW_HWPlatform, PhysSW_Software, PhysSW_MGMTIP, PhysSW_MTU 84 | 85 | $CDPResult.VMHost = $esxname 86 | $CDPResult.PhysicalNic = $physnic.Device 87 | $CDPResult.PhysSW_Port = $hint.ConnectedSwitchPort.PortID 88 | $CDPResult.PhysSW_Name = $hint.ConnectedSwitchPort.DevID 89 | $CDPResult.PhysSW_HWPlatform = $hint.ConnectedSwitchPort.HardwarePlatform 90 | $CDPResult.PhysSW_Software = $hint.ConnectedSwitchPort.SoftwareVersion 91 | $CDPResult.PhysSW_MGMTIP = $hint.ConnectedSwitchPort.MgmtAddr 92 | $CDPResult.PhysSW_MTU = $hint.ConnetedSwitchPort.Mtu 93 | 94 | $CDPResultArray += $CDPResult 95 | } 96 | if(!($hint.LLDPInfo) -and (!($hint.ConnectedSwitchPort))) 97 | { 98 | Write-Host -Fore YELLOW "No CDP or LLDP information available! " 99 | Write-Host -Fore YELLOW "Check if your switches support these protocols and if" 100 | Write-Host -Fore YELLOW "the CDP/LLDP features are enabled." 101 | } 102 | } 103 | } 104 | } 105 | } 106 | 107 | else 108 | { 109 | Write-Host "No host(s) found in Connected or Maintenance state!" 110 | exit 111 | } 112 | 113 | ## Output to screen and/or file 114 | if ($CDPResultArray) 115 | { 116 | $CDPResultArray | ft -autosize 117 | $CDPResultArray | Export-Csv .\CDP_Info_$Cluster.txt -useculture -notypeinformation 118 | } 119 | if ($LLDPResultArray) 120 | { 121 | $LLDPResultArray | ft -autosize 122 | $LLDPResultArray | Export-Csv .\LLDP_Info_$Cluster.txt -useculture -notypeinformation 123 | } 124 | 125 | #disconnect-viserver * -Confirm:$false 126 | -------------------------------------------------------------------------------- /Get-LastViewLogon.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for View to Check the Last View Broker logon per User 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | #Define Variables 6 | #$StartDate = "01/01/2016" #uncomment to look by a range of dates 7 | #$EndDate = Get-Date #uncomment to look by a range of dates 8 | $EventType = "BROKER_USERLOGGEDIN" 9 | #$Events = Get-EventReport -ViewName user_events -StartDate $StartDate -EndDate $EndDate|Where-Object {$_.eventtype -eq $EventType}|Select userdisplayname,time #uncomment to look by a range of dates 10 | $Events = Get-EventReport -ViewName user_events|Where-Object {$_.eventtype -eq $EventType}|Select userdisplayname,time 11 | $Users = $Events.userdisplayname|Select-Object -Uniq 12 | 13 | #Find Last Logon 14 | Foreach ($User in $Users){ 15 | $Result = $Events|Where-Object {$_.userdisplayname -eq $User}|Select-Object -Last 1|select userdisplayname,time 16 | if ($Result -eq $null) {Write-Host $User " has no current logon"} 17 | else { 18 | Write-Host $User "had a last logon on" $Result.time} 19 | } 20 | -------------------------------------------------------------------------------- /Get-NICAndFirmware.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .NOTES 3 | =========================================================================== 4 | Created with: SAPIEN Technologies, Inc., PowerShell Studio 2014 v4.1.65 5 | Created on: 10/17/2014 10:43 AM 6 | Created by: Jon Howe 7 | Filename: Get-NICAndFirmware.ps1 8 | =========================================================================== 9 | .SYNOPSIS 10 | Connects to VirtualCenter and lists pertinent NIC driver and version information 11 | .DESCRIPTION 12 | Connects to VirtualCenter and lists pertinent NIC driver and version information 13 | .PARAMETER $VirtualCenterServer 14 | Required String Parameter. The fully qualified domain name of the virtualcenter server 15 | .PARAMETER $cluster 16 | Optional StringParameter. The name of the cluster you want to filter by. 17 | .PARAMETER $asLocalUser 18 | Optional Boolean Parameter. Do you want to connect to vC as you, or do you want to manually 19 | authenticate as a different user 20 | .EXAMPLE 21 | Get-NicDriverAndFirmware -VirtualCenterServer vc-tst-1.test.in 22 | Actions Taken: 23 | This will connect to the specified virtualcenter server and list the driver name, version, 24 | and firmware version for every NIC in every host attached to your vCenter server. The script will 25 | authenticate to vCenter as your locally logged in user. 26 | Results: 27 | Host_Name VMNic_Name DriverName DriverVersion FirmwareVersion 28 | --------- ---------- ---------- ------------- --------------- 29 | ESXi-1.test.in.parata.local vmnic0 bnx2x 1.72.56.v55.2 bc 5.2.7 phy baa0.105 30 | ESXi-1.test.in.parata.local vmnic1 bnx2x 1.72.56.v55.2 bc 5.2.7 phy baa0.105 31 | ESXi-1.test.in.parata.local vmnic2 e1000e 1.1.2-NAPI 5.12-6 32 | ESXi-1.test.in.parata.local vmnic3 e1000e 1.1.2-NAPI 5.12-6 33 | ESXi-1.test.in.parata.local vmnic4 e1000e 1.1.2-NAPI 5.12-6 34 | ESXi-1.test.in.parata.local vmnic5 e1000e 1.1.2-NAPI 5.12-6 35 | .EXAMPLE 36 | Get-NicDriverAndFirmware -VirtualCenterServer vc-tst-1.test.in -ClusterName Production -asLocalUser $False | Format-Table -AutoSize 37 | Actions Taken: 38 | This will connect to the specified virtualcenter server and list the driver name, version, 39 | and firmware version for each NIC in every host in the cluster "Production", and will prompt for a username and password. 40 | Resuts: 41 | Same as example 1 42 | .EXAMPLE 43 | Get-NicDriverAndFirmware -VirtualCenterServer vc-tst-1.test.in -ClusterName Production -asLocalUser $False | c:\temp\vCenterInterfaceDriverandFirmware.csv -notypeinformation 44 | Actions Taken: 45 | This script outputs an object, so you can do anything you want with the output, such as create a CSV, sort, etc. 46 | Results: 47 | Sames as example 1 48 | 49 | .LINK 50 | Original Published Location 51 | http://www.cit3.net/vmware-powercli-gather-nic-driver-and-firmware-versions-from-hosts-via-vcenter 52 | .LINK 53 | VMware KB for gathering NIC Driver and Firmware versions 54 | http://kb.vmware.com/kb/1027206 55 | .LINK 56 | VMware Documentation on PowerCLI's Get-EsxCli commandlet 57 | http://pubs.vmware.com/vsphere-55/topic/com.vmware.powercli.cmdletref.doc/Get-EsxCli.html 58 | #> 59 | [CmdletBinding()] 60 | param ( 61 | [Parameter(Position = 0, Mandatory = $true)] 62 | [System.String] 63 | $VirtualCenterServer, 64 | [Parameter(Position = 1)] 65 | [System.String] 66 | $ClusterName, 67 | [Parameter(Position = 2)] 68 | [System.Boolean] 69 | $asLocalUser = $true 70 | ) 71 | 72 | #region Add Snapin and Connect to vC 73 | #Check to see if the VMware.VimAutomation.Core snapin is loaded - load it if it's not 74 | if ((Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) -eq $null) 75 | { 76 | Add-PsSnapin VMware.VimAutomation.Core 77 | } 78 | 79 | #Check to see if we're already connected to the correct VC Server 80 | if ($DefaultVIServers.name -ne $VirtualCenterServer) 81 | { 82 | #Determine if we're logging in to VirtualCenter as a local user or if we should prompt for credentials 83 | if ($asLocalUser) 84 | { 85 | Connect-VIServer -Server $VirtualCenterServer | Out-Null 86 | Write-Debug "Logging in as local user to vc: $VirtualCenterServer" 87 | } 88 | else 89 | { 90 | Connect-VIServer -Server $VirtualCenterServer -Credential (Get-Credential) | Out-Null 91 | Write-Debug "Logging in as manually selected user to vc: $VirtualCenterServer" 92 | } 93 | } 94 | else 95 | { 96 | Write-Debug "Looks like we're already connected to: $VirtualCenterServer in this session" 97 | } 98 | #endregion Add Snapin and Connect to vC 99 | 100 | #region Get List of Hosts 101 | if ($ClusterName) 102 | { 103 | $VMHosts = Get-Cluster -Name $ClusterName | Get-VMHost | Where-Object { $_.ConnectionState -eq "Connected" } 104 | } 105 | else 106 | { 107 | $VMhosts = Get-VMHost | Where-Object { $_.ConnectionState -eq "Connected" } 108 | } 109 | #endregion Get List of Hosts 110 | 111 | $results = @() 112 | foreach ($VMHost in $VMHosts) 113 | { 114 | #Get list of network interfaces on host 115 | $VMHostNetworkAdapters = Get-VMHost $VMHost | Get-VMHostNetworkAdapter | Where-Object { $_.Name -like "vmnic*" } 116 | 117 | $esxcli = Get-VMHost $VMHost | Get-EsxCli 118 | 119 | $arrNicDetail = @() 120 | foreach ($VMNic in $VMHostNetworkAdapters) 121 | { 122 | $objOneNic = New-Object System.Object 123 | $objDriverInfo = ($esxcli.network.nic.get($VMNic.Name)).DriverInfo 124 | 125 | $objOneNic | Add-Member -type NoteProperty -name Host_Name -Value $VMHost.Name 126 | $objOneNic | Add-Member -type NoteProperty -name VMNic_Name -Value $VMNic.Name 127 | $objOneNic | Add-Member -type NoteProperty -name DriverName -Value $objDriverInfo.Driver 128 | $objOneNic | Add-Member -type NoteProperty -name DriverVersion -Value $objDriverInfo.Version 129 | $objOneNic | Add-Member -type NoteProperty -name FirmwareVersion -Value $objDriverInfo.FirmwareVersion 130 | $arrNicDetail += $objOneNic 131 | } 132 | 133 | $results += $arrNicDetail 134 | } 135 | 136 | $results 137 | Disconnect-VIServer -Server $VirtualCenterServer -Confirm:$false 138 | Remove-PSSnapin VMware.VimAutomation.Core 139 | -------------------------------------------------------------------------------- /Get-VMSnapshots.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for getting current VM snapshots 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | # Connect-VIserver your-vcenter-server -user your-user -password your-password 6 | 7 | param($Cluster) ## Input from command line 8 | 9 | if(!($Cluster)) 10 | { 11 | Write-Host -Fore YELLOW "Missing parameter!" 12 | Write-Host -Fore YELLOW "Usage:" 13 | Write-Host -Fore YELLOW ".\Get-VMSnapshots.ps1 " 14 | Write-Host -Fore YELLOW "" 15 | Write-Host -Fore YELLOW "Example: .\Get-VMSnapshots.ps1 LabCluster" 16 | exit 17 | } 18 | if(!(Get-Cluster $Cluster -EA SilentlyContinue)) 19 | { 20 | Write-Host -Fore RED "No cluster found with the name: $Cluster " 21 | Write-Host -Fore YELLOW "These clusters where found in the vCenter you have connected to:" 22 | Get-Cluster | sort Name | Select Name 23 | exit 24 | } 25 | Get-Cluster $Cluster|Get-VMHost|Get-VM|Get-Snapshot|Select VM, Name, Created|ft -a 26 | -------------------------------------------------------------------------------- /Get-VMwareTrafficShapingSettings.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for Getting Traffic Shapping Settings for All VirtualPortGroup on VirtualSwitch 2 | # @davidstamen 3 | # http://davidstamen.com 4 | # Powershel Functions provided by @LucD http://www.lucd.info/2011/06/11/dvswitch-scripting-part-9-traffic-shaping/ 5 | 6 | function Get-dvPgTrafficShaping{ 7 | <# 8 | .SYNOPSIS 9 | Returns the traffic shaping settings for a dvSwitch portgroup 10 | .DESCRIPTION 11 | The function will return all traffic shaping settings for a dvSwitch portgroup 12 | .NOTES 13 | Author: Luc Dekens 14 | .PARAMETER dvPg 15 | An object that represents a dvPortgroup as returned by the 16 | Get-dVsWPg function 17 | .EXAMPLE 18 | PS> Get-dvSwPg $dvSw $dvPgName | Get-dvPgTrafficShaping 19 | #> 20 | 21 | [CmdletBinding()] 22 | param( 23 | [parameter(Mandatory = $true, ValueFromPipeline = $true)] 24 | [PSObject]$dvPg) 25 | 26 | $ts = New-Object PSObject 27 | 28 | $ingress = $dvPg.Config.DefaultPortConfig.InshapingPolicy 29 | Add-Member -InputObject $ts -Name IngressState -Value $ingress.Enabled.Value -MemberType NoteProperty 30 | if($ingress.Enabled.Value){ 31 | Add-Member -InputObject $ts -Name "InAverage (Kbps)" -Value ($ingress.AverageBandwidth.Value/1000) -MemberType NoteProperty 32 | Add-Member -InputObject $ts -Name "InBurst (KB)" -Value ($ingress.BurstSize.Value/1KB) -MemberType NoteProperty 33 | Add-Member -InputObject $ts -Name "InPeak (Kbps)" -Value ($ingress.PeakBandwidth.Value/1000) -MemberType NoteProperty 34 | } 35 | else{ 36 | Add-Member -InputObject $ts -Name "InAverage (Kbps)" -Value "na" -MemberType NoteProperty 37 | Add-Member -InputObject $ts -Name "InBurst (KB)" -Value "na" -MemberType NoteProperty 38 | Add-Member -InputObject $ts -Name "InPeak (Kbps)" -Value "na" -MemberType NoteProperty 39 | } 40 | 41 | $egress = $dvPg.Config.DefaultPortConfig.OutshapingPolicy 42 | Add-Member -InputObject $ts -Name EgressState -Value $egress.Enabled.Value -MemberType NoteProperty 43 | if($egress.Enabled.Value){ 44 | Add-Member -InputObject $ts -Name "OutAverage (Kbps)" -Value ($egress.AverageBandwidth.Value/1000) -MemberType NoteProperty 45 | Add-Member -InputObject $ts -Name "OutBurst (KB)" -Value ($egress.BurstSize.Value/1KB) -MemberType NoteProperty 46 | Add-Member -InputObject $ts -Name "OutPeak (Kbps)" -Value ($egress.PeakBandwidth.Value/1000) -MemberType NoteProperty 47 | } 48 | else{ 49 | Add-Member -InputObject $ts -Name "OutAverage (Kbps)" -Value "na" -MemberType NoteProperty 50 | Add-Member -InputObject $ts -Name "OutBurst (KB)" -Value "na" -MemberType NoteProperty 51 | Add-Member -InputObject $ts -Name "OutPeak (Kbps)" -Value "na" -MemberType NoteProperty 52 | } 53 | 54 | $ts 55 | } 56 | function Get-dvSwPg{ 57 | param($dvSw, 58 | [string]$PGName, 59 | [int]$VLANnr) 60 | 61 | # Search for Portgroup Name 62 | if($PGName){ 63 | $dvSw.Portgroup | %{Get-View -Id $_} | ` 64 | where{$_.Name -eq $PGName} 65 | } 66 | # Search for VLAN number 67 | elseif($VLANnr){ 68 | $dvSw.Portgroup | %{Get-View -Id $_} | ` 69 | where{$_.Config.DefaultPortConfig.Vlan.VlanId -eq $VLANnr} 70 | } 71 | } 72 | Foreach ($VirtualSwitch in Get-VirtualSwitch -Distributed) { 73 | Foreach ($VirtualPortGroup in Get-VirtualPortGroup -VirtualSwitch $VirtualSwitch|Where {$_.Name -notlike "*DVUplinks*"}) { 74 | Write "$VirtualPortGroup on $VirtualSwitch" 75 | $dvPg = Get-dvSwPg -dvSw $VirtualSwitch.ExtensionData -PGName $VirtualPortGroup 76 | Get-dvPgTrafficShaping -dvPg $dvPg|ft 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /GetHostPathStatus.ps1: -------------------------------------------------------------------------------- 1 | Get-VMHost | Sort-Object -property Name | ForEach-Object { 2 | $VMHost = $_ 3 | $VMHost | Get-VMHostHba | Sort-Object -property Device | ForEach-Object { 4 | $VMHostHba = $_ 5 | $ScsiLun = $VMHostHba | Get-ScsiLun 6 | If ($ScsiLun) { 7 | $ScsiLunPath = $ScsiLun | Get-ScsiLunPath | ` 8 | Where-Object {$_.Name -like "$($VMHostHba.Device)*"} 9 | $Targets = ($ScsiLunPath | ` 10 | Group-Object -Property SanID | Measure-Object).Count 11 | $Devices = ($ScsiLun | Measure-Object).Count 12 | $Paths = ($ScsiLunPath | Measure-Object).Count 13 | } 14 | Else { 15 | $Targets = 0 16 | $Devices = 0 17 | $Paths = 0 18 | } 19 | $Report = "" | Select-Object -Property VMHost,HBA,Targets,Devices,Paths 20 | $Report.VMHost = $VMHost.Name 21 | $Report.HBA = $VMHostHba.Device 22 | $Report.Targets = $Targets 23 | $Report.Devices = $Devices 24 | $Report.Paths = $Paths 25 | $Report 26 | } 27 | } -------------------------------------------------------------------------------- /GetPathStatus.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for getting path selection policy for hosts 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | # Setup common variables to use 6 | $vcenter = "vcenter.lab.local" 7 | 8 | # Connect to vCenter 9 | Connect-VIServer -Server $vcenter 10 | 11 | $vmhosts = @(Get-VMHost) 12 | foreach ($vmhost in $vmhosts) { 13 | $esxcli = Get-EsxCli -VMHost $vmhost 14 | $status = $esxcli.storage.nmp.device.list($null) | Select Device, DeviceDisplayName, PathSelectionPolicy 15 | Write-Host "===================================" 16 | Write-Host "$vmhost" 17 | $status 18 | Write-Host "===================================" 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Install-HostVIB.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for installing a VIB to a host 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | # Define Variables 6 | $Cluster = "Cluster" 7 | $vibpath = "/vmfs/volumes/NFS01/VIB/cisco/scsi-fnic_1.6.0.24-1OEM.600.0.0.2494585.vib" 8 | $vcenter = "vcenter.lab.local" 9 | $cred = Get-Credential 10 | 11 | # Connect to vCenter 12 | Connect-VIServer -Server $vcenter -Credential $cred 13 | 14 | # Get each host in specified cluster that meets criteria 15 | Get-VMhost -Location $Cluster | where { $_.PowerState -eq "PoweredOn" -and $_.ConnectionState -eq "Connected" } | foreach { 16 | 17 | Write-host "Preparing $($_.Name) for ESXCLI" -ForegroundColor Yellow 18 | 19 | $ESXCLI = Get-EsxCli -VMHost $_ -V2 20 | 21 | # Install VIBs 22 | Write-host "Installing VIB on $($_.Name)" -ForegroundColor Yellow 23 | 24 | # Create Installation Arguments 25 | $insParm = @{ 26 | viburl = $vibpath 27 | dryrun = $false 28 | nosigcheck = $true 29 | maintenancemode = $false 30 | force = $false 31 | } 32 | 33 | $action = $ESXCLI.software.vib.install.Invoke($insParm) 34 | 35 | # Verify VIB installed successfully 36 | if ($action.Message -eq "Operation finished successfully."){Write-host "Action Completed successfully on $($_.Name)" -ForegroundColor Green} else {Write-host $action.Message -ForegroundColor Red} 37 | } 38 | -------------------------------------------------------------------------------- /InstallVMSoftware.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for installing a package to a VM 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | #Define Variables 6 | Write-Host "Prompt For Guest Credentials" -ForegroundColor Yellow 7 | $Cred = Get-Credential 8 | $VMs = "VM1","VM2" 9 | #$VMs = Get-VM VM* | Sort Name 10 | 11 | Foreach ($VMName in $VMs) { 12 | $VM = Get-VM $VMName 13 | 14 | #Define file information. Include File Name, Parameters, Source and Destination 15 | $File = "VMware-v4vdesktopagent-x86_64-6.2.0-3295266.exe" 16 | $Param = "/s /v/qn REBOOT=Reallysuppress" 17 | $SrcPath = "c:\" 18 | $DstPath = "c:\temp\" 19 | $Fullpath = $SrcPath + $File 20 | 21 | Write-Host Copying $Fullpath to $VMName -ForegroundColor Cyan 22 | Copy-VMGuestFile -VM $VM -Source $Fullpath -Destination $DstPath -LocalToGuest -GuestCredential $Cred -Force 23 | 24 | #Define Install File Command 25 | $Command = $DstPath + $File + $Param 26 | #Define Delete File Command 27 | $Command2 = "del " + $DstPath + $File 28 | 29 | Write-Host Executing $Command within guest operating system of $VMName -ForegroundColor White 30 | $Result = Invoke-VMScript -VM $VM -ScriptText $Command -GuestCredential $Cred 31 | $ExitCode = $Result.ExitCode 32 | if ($ExitCode = "0") { 33 | Write-Host $VMName returned exit code $ExitCode -ForegroundColor Green 34 | } 35 | Else { 36 | Write-Host $VMName returned exit code $ExitCode -ForegroundColor Red 37 | } 38 | Write-Host Executing $Command2 within guest operating system of $VMName -ForegroundColor White 39 | $Result2 = Invoke-VMScript -VM $VM -ScriptText $Command2 -GuestCredential $Cred 40 | $ExitCode2 = $Result2.ExitCode 41 | if ($ExitCode2 = "0") { 42 | Write-Host $VMName returned exit code $ExitCode2 -ForegroundColor Green 43 | } 44 | Else { 45 | Write-Host $VMName returned exit code $ExitCode2 -ForegroundColor Red 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /ReloadSyslog.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for reloading syslogserver on hosts 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | # Setup common variables to use 6 | $vcenter = "vcenter.lab.local" 7 | 8 | # Connect to vCenter 9 | Connect-VIServer -Server $vcenter 10 | 11 | # Get hosts 12 | $vmhosts = @(Get-VMHost) 13 | 14 | # Configure syslog on each host in vCenter 15 | foreach ($vmhost in $vmhosts) { 16 | $esxcli = Get-EsxCli -VMHost $vmhost 17 | $esxcli.system.syslog.reload() 18 | } 19 | -------------------------------------------------------------------------------- /Set-MaxDiskIO.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for setting Disk Max IO Size 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | #Define Variables 6 | $cred = Get-Credential 7 | $VC = "vc.lab.local" 8 | $Cluster = "Production" 9 | 10 | #Connect to vCenter 11 | Connect-VIServer $VC -Credential $cred 12 | 13 | #Get all Hosts 14 | $esxHosts = Get-Cluster $Cluster | Get-VMHost | Where { $_.PowerState -eq "PoweredOn" -and $_.ConnectionState -eq "Connected" } | Sort Name 15 | 16 | #For each host set DiskMaxIOsize to 4MB 17 | foreach ($esx in $esxHosts) { 18 | Get-AdvancedSetting -Entity $esx -Name Disk.DiskMaxIOSize | Set-AdvancedSetting -Value 4096 -Confirm:$false 19 | } 20 | -------------------------------------------------------------------------------- /Set-VMwareTrafficShapingSettings.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for Setting Traffic Shapping Settings for All VirtualPortGroup on VirtualSwitch 2 | # @davidstamen 3 | # http://davidstamen.com 4 | # Powershel Functions provided by @LucD http://www.lucd.info/2011/06/11/dvswitch-scripting-part-9-traffic-shaping/ 5 | 6 | function Set-dvPgTrafficShaping{ 7 | <# 8 | .SYNOPSIS 9 | Configure traffic shaping on a dvSwitch portgroup 10 | .DESCRIPTION 11 | The function will configure ingress (VM to switch) 12 | and egress (switch to VM) traffic shaping for a specific 13 | dvSwitch portgroup 14 | .NOTES 15 | Author: Luc Dekens 16 | .PARAMETER dvPg 17 | An object that represents a dvPortgroup as returned by the 18 | Get-dVsWPg function 19 | .PARAMETER InShaping 20 | A switch which indicates if inshaping (ingress) should be 21 | enabled or not 22 | .PARAMETER inAverageKbps 23 | The value, in Kbits/sec, for the ingress average bandwidth. 24 | If the value is -1, the setting will be left unchanged. 25 | .PARAMETER inBurstKB 26 | The value, in Kbytes, for the ingress burst size 27 | If the value is -1, the setting will be left unchanged. 28 | .PARAMETER inPeakKbps 29 | The value, in Kbits/sec, for the ingress peak bandwidth 30 | If the value is -1, the setting will be left unchanged. 31 | .PARAMETER OutShaping 32 | A switch which indicates if outshaping (egress) should be 33 | enabled or not 34 | .PARAMETER outAverageKbps 35 | The value, in Kbits/sec, for the average bandwidth 36 | If the value is -1, the setting will be left unchanged. 37 | .PARAMETER outBurstKB 38 | The value, in Kbytes, for the burst size 39 | If the value is -1, the setting will be left unchanged. 40 | .PARAMETER outPeakKbps 41 | The value, in Kbits/sec, for the peak bandwidth 42 | If the value is -1, the setting will be left unchanged. 43 | .EXAMPLE 44 | PS> Get-dvSwPg $dvSw $dvPgName | ` 45 | >> Set-dvPgTrafficShaping -IShaping:$false ` 46 | >> -OutShaping -outAverage 100000 ` 47 | >> -outPeak 100000 ` 48 | >> -outBurst 102400 49 | #> 50 | 51 | [CmdletBinding()] 52 | param( 53 | [parameter(Mandatory = $true, ValueFromPipeline = $true)] 54 | [PSObject]$dvPg, 55 | [switch]$InShaping, 56 | [long]$inAverageKbps, 57 | [long]$inBurstKB, 58 | [long]$inPeakKbps, 59 | [switch]$OutShaping, 60 | [long]$outAverageKbps, 61 | [long]$outBurstKB, 62 | [long]$outPeakKbps 63 | ) 64 | 65 | $spec = New-Object VMware.Vim.DVPortgroupConfigSpec 66 | $spec.ConfigVersion = $dvPg.Config.ConfigVersion 67 | $spec.DefaultPortConfig = New-Object VMware.Vim.VMwareDVSPortSetting 68 | if($InShaping){ 69 | $spec.DefaultPortConfig.InShapingPolicy = New-Object VMware.Vim.DVSTrafficShapingPolicy 70 | $spec.DefaultPortConfig.InShapingPolicy.Enabled = New-Object VMware.Vim.BoolPolicy 71 | $spec.DefaultPortConfig.InShapingPolicy.Enabled.Value = $true 72 | $spec.DefaultPortConfig.InShapingPolicy.Enabled.Inherited = $false 73 | if($inAverageKbps -ne -1){ 74 | $spec.DefaultPortConfig.InShapingPolicy.averageBandwidth = New-Object VMware.Vim.LongPolicy 75 | $spec.DefaultPortConfig.InShapingPolicy.averageBandwidth.Value = $inAverageKbps * 1000 76 | $spec.DefaultPortConfig.InShapingPolicy.averageBandwidth.Inherited = $false 77 | } 78 | if($inBurstKB -ne -1){ 79 | $spec.DefaultPortConfig.InShapingPolicy.burstSize = New-Object VMware.Vim.LongPolicy 80 | $spec.DefaultPortConfig.InShapingPolicy.burstSize.Value = $inBurstKB * 1KB 81 | $spec.DefaultPortConfig.InShapingPolicy.burstSize.Inherited = $false 82 | } 83 | if($inPeakKbps -ne -1){ 84 | $spec.DefaultPortConfig.InShapingPolicy.peakBandwidth = New-Object VMware.Vim.LongPolicy 85 | $spec.DefaultPortConfig.InShapingPolicy.peakBandwidth.Value = $inPeakKbps * 1000 86 | $spec.DefaultPortConfig.InShapingPolicy.peakBandwidth.Inherited = $false 87 | } 88 | } 89 | else{ 90 | $spec.DefaultPortConfig.InShapingPolicy = New-Object VMware.Vim.DVSTrafficShapingPolicy 91 | $spec.DefaultPortConfig.InShapingPolicy.Enabled = New-Object VMware.Vim.BoolPolicy 92 | $spec.DefaultPortConfig.InShapingPolicy.Enabled.Value = $false 93 | $spec.DefaultPortConfig.InShapingPolicy.Enabled.Inherited = $true 94 | } 95 | 96 | if($OutShaping){ 97 | $spec.DefaultPortConfig.OutShapingPolicy = New-Object VMware.Vim.DVSTrafficShapingPolicy 98 | $spec.DefaultPortConfig.OutShapingPolicy.Enabled = New-Object VMware.Vim.BoolPolicy 99 | $spec.DefaultPortConfig.OutShapingPolicy.Enabled.Value = $true 100 | $spec.DefaultPortConfig.OutShapingPolicy.Enabled.Inherited = $false 101 | if($outAverageKbps -ne -1){ 102 | $spec.DefaultPortConfig.OutShapingPolicy.averageBandwidth = New-Object VMware.Vim.LongPolicy 103 | $spec.DefaultPortConfig.OutShapingPolicy.averageBandwidth.Value = $outAverageKbps * 1000 104 | $spec.DefaultPortConfig.OutShapingPolicy.averageBandwidth.Inherited = $false 105 | } 106 | if($outBurstKB -ne -1){ 107 | $spec.DefaultPortConfig.OutShapingPolicy.burstSize = New-Object VMware.Vim.LongPolicy 108 | $spec.DefaultPortConfig.OutShapingPolicy.burstSize.Value = $outBurstKB * 1KB 109 | $spec.DefaultPortConfig.OutShapingPolicy.burstSize.Inherited = $false 110 | } 111 | if($outPeakKbps -ne -1){ 112 | $spec.DefaultPortConfig.OutShapingPolicy.peakBandwidth = New-Object VMware.Vim.LongPolicy 113 | $spec.DefaultPortConfig.OutShapingPolicy.peakBandwidth.Value = $outPeakKbps * 1000 114 | $spec.DefaultPortConfig.OutShapingPolicy.peakBandwidth.Inherited = $false 115 | } 116 | } 117 | else{ 118 | $spec.DefaultPortConfig.OutShapingPolicy = New-Object VMware.Vim.DVSTrafficShapingPolicy 119 | $spec.DefaultPortConfig.OutShapingPolicy.Enabled = New-Object VMware.Vim.BoolPolicy 120 | $spec.DefaultPortConfig.OutShapingPolicy.Enabled.Value = $false 121 | $spec.DefaultPortConfig.OutShapingPolicy.Enabled.Inherited = $true 122 | } 123 | 124 | $dvPg.ReconfigureDVPortgroup($spec) 125 | } 126 | function Get-dvSwPg{ 127 | param($dvSw, 128 | [string]$PGName, 129 | [int]$VLANnr) 130 | 131 | # Search for Portgroup Name 132 | if($PGName){ 133 | $dvSw.Portgroup | %{Get-View -Id $_} | ` 134 | where{$_.Name -eq $PGName} 135 | } 136 | # Search for VLAN number 137 | elseif($VLANnr){ 138 | $dvSw.Portgroup | %{Get-View -Id $_} | ` 139 | where{$_.Config.DefaultPortConfig.Vlan.VlanId -eq $VLANnr} 140 | } 141 | } 142 | Foreach ($VirtualSwitch in Get-VirtualSwitch -Distributed) { 143 | Foreach ($VirtualPortGroup in Get-VirtualPortGroup -VirtualSwitch $VirtualSwitch|Where {$_.Name -notlike "*DVUplinks*"}) { 144 | Write "$VirtualPortGroup on $VirtualSwitch" 145 | $dvPg = Get-dvSwPg -dvSw $VirtualSwitch.ExtensionData -PGName $VirtualPortGroup 146 | Set-dvPgTrafficShaping -dvPg $dvPg -InShaping -inAverageKbps 10485760 -inBurstKB 102400 -inPeakKbps 10485760 -OutShaping -outAverageKbps 10485760 -outBurstKB 102400 -outPeakKbps 10485760 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /Set-vCenterPermissions.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for setting vCenter Permissions base don AD Group and Datacenter 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | param 6 | ( 7 | [Parameter(Mandatory=$False, 8 | HelpMessage='Path to CSV to Import')] 9 | [string[]]$permissionlist 10 | ) 11 | 12 | #Import PowerCLI Module 13 | Get-Module -ListAvailable VMware* | Import-Module 14 | 15 | #Prompt for vCenter to Set Permissions 16 | $vCenter = Read-Host -Prompt "Name or IP address of vcenter" 17 | 18 | #Makes sure CSV was passed as parameter, if not it prompts and checks path. 19 | If($permissionlist -eq $NULL){ 20 | $permissionlist = Read-host -Prompt "Csv to import" 21 | } 22 | If((Test-Path $permissionlist) -eq $False){Write-host "Could not find CSV.";break} 23 | 24 | #tries to connect to vcenter and breaks script if it fails. 25 | Try{Connect-viserver $vCenter -ErrorAction "Stop"|Out-Null} 26 | Catch {Write-Warning "Unable to Logon to $vCenter. Exiting...";break} 27 | 28 | #define variables and loop through each entry setting permissions 29 | $permission = Import-csv "$permissionlist" 30 | foreach ($item in $permission) { 31 | $datacenter=$item.datacenter 32 | $role=$item.role 33 | $group=$item.group 34 | $domain=$item.domain 35 | 36 | Write-host "Setting $group permissions to $role on $vCenter" -ForegroundColor Green 37 | $Permission=New-VIPermission -Entity (Get-Datacenter $datacenter) -Principal (Get-VIAccount -Domain $domain -Group|Where-Object {$_.Name -like "*$group*"}) -Role (Get-VIRole $role) -Propagate:$true|Out-Null 38 | } 39 | -------------------------------------------------------------------------------- /SetNTP.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for adding ntp to hosts 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | # Setup common variables to use 6 | $vcenter = "vc.lab.local" 7 | 8 | # Connect to vCenter 9 | Connect-VIServer -Server $vcenter 10 | 11 | #Set NTP server for all hosts 12 | Get-VMHost | Add-VMHostNTPServer -NTPserver us.pool.ntp.org 13 | 14 | #Restart NTP services on host 15 | Get-VMHost | Get-VMHostService | Where-Object {$_.key -eq "ntpd"} | Stop-VMHostService 16 | Get-VMHost | Get-VMHostService | Where-Object {$_.key -eq "ntpd"} | Start-VMHostService 17 | 18 | #Set service to start automatically 19 | Get-VMHost | Get-VMHostService | Where-Object {$_.key -eq "ntpd"} | Set-VMHostService -policy "on" 20 | -------------------------------------------------------------------------------- /SetSyslog.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script for adding syslogserver to hosts 2 | # @davidstamen 3 | # http://davidstamen.com 4 | 5 | # Setup common variables to use 6 | $vcenter = "vc.lab.local" 7 | $syslogservers = "udp://syslog.lab.local:514" 8 | 9 | Connect-VIServer -Server $vcenter 10 | 11 | # Setup variable to use in script for all hosts in vCenter 12 | $vmhosts = @(Get-VMHost) 13 | 14 | # Configure syslog on each host in vCenter 15 | foreach ($vmhost in $vmhosts) { 16 | Set-VMHostAdvancedConfiguration -Name Syslog.global.logHost -Value "$syslogservers" -VMHost $vmhost 17 | $esxcli = Get-EsxCli -VMHost $vmhost 18 | $esxcli.system.syslog.reload() 19 | } 20 | 21 | # Disconnect from vCenter 22 | Disconnect-VIServer * -Confirm:$false 23 | -------------------------------------------------------------------------------- /UpgradeVDS.ps1: -------------------------------------------------------------------------------- 1 | Connect-VIServer "ds-vcsa-03.cpbu.lab" | Out-Null 2 | $VDSwitch = "VDS" 3 | $VDVersion = "6.6.0" 4 | $Cluster = Get-Cluster "Cluster" 5 | 6 | If ($Cluster.DrsEnabled -like "True") { 7 | Write-Host "DRS is Enabled, it will be temporarily disabled during upgrade." -ForegroundColor "Green" 8 | $ClusterDRSLevel = $Cluster.DrsAutomationLevel 9 | Write-Host "DRS Cluster is currently set to $ClusterDRSLevel. Will change back when complete." -ForegroundColor "Green" 10 | Get-Cluster $Cluster | Set-Cluster -DrsAutomationLevel "PartiallyAutomated" -Confirm:$false 11 | Get-VDSwitch -Name $VDSwitch | Export-VDSwitch -Description "My Backup" -Destination "/PathToBackup/VDSBackup-$VDswitch-$((Get-Date).ToString(‘yyyy-MM-dd-hh-mm’)).zip" 12 | Get-VDSwitch -Name $VDSwitch | Set-VDSwitch -Version $VDVersion 13 | Write-Host "Upgrade is complete. Setting Cluster to $ClusterDRSLevel." -ForegroundColor "Green" 14 | Get-Cluster $Cluster | Set-Cluster -DrsAutomationLevel $ClusterDRSLevel -Confirm:$false 15 | } 16 | ElseIf ($Cluster.DrsEnabled -like "False") { 17 | Write-Host "DRS is Disabled, No additional action needed." -ForegroundColor "Green" 18 | Get-VDSwitch -Name $VDSwitch | Export-VDSwitch -Description "My Backup" -Destination "/PathToBackup/VDSBackup-$VDswitch-$((Get-Date).ToString(‘yyyy-MM-dd-hh-mm’)).zip" 19 | Get-VDSwitch -Name $VDSwitch | Set-VDSwitch -Version $VDVersion 20 | } 21 | -------------------------------------------------------------------------------- /deploy-pureova.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script to deploy Pure Storage VMware Appliance 2 | # @davidstamen 3 | # https://davidstamen.com 4 | 5 | $vcname = "vc01.my.lab" 6 | $vcuser = "administrator@vsphere.local" 7 | $vcpass = "VMware1!" 8 | 9 | 10 | $ovffile = "C:\share\pure-vmware-appliance_3.2.0-prod-signed.ova" #Online OVA https://static.pure1.purestorage.com/vm-analytics-collector/pure-vmware-appliance_3.2.0-prod-signed.ova 11 | $cluster = "MyCluster" 12 | $vmnetwork = "MyNetwork" 13 | $datastore = "MyDatastore" 14 | $vmfolder = "MyFolder" 15 | $vmname = "pureplugin.my.lab" 16 | $vmip = "10.21.234.27" 17 | $netmask = "255.255.255.0" 18 | $gateway = "10.21.234.1" 19 | $dns1 = "10.21.234.10" 20 | $dns2 = "10.21.234.11" 21 | $appliancetype = "vSphere Remote Client Plugin" #"VM Analytics Collector","vSphere Remote Client Plugin", "None (Offline Installation)" 22 | $dhcp = $false #true if dhcp, false if static 23 | 24 | $vcenter = Connect-VIServer $vcname -User $vcuser -Password $vcpass -WarningAction SilentlyContinue 25 | 26 | $datastore_ref = Get-Datastore -Name $datastore 27 | $network_ref = Get-VirtualPortGroup -Name $vmnetwork 28 | $cluster_ref = Get-Cluster -Name $cluster 29 | $vmhost_ref = $cluster_ref | Get-VMHost | Select-Object -First 1 30 | 31 | $ovfconfig = Get-OvfConfiguration $ovffile 32 | 33 | $ovfconfig.NetworkMapping.VM_Network.Value = $network_ref 34 | $ovfconfig.Common.Appliance_Type.Value = $appliancetype 35 | $ovfconfig.Common.DHCP.Value = $dhcp 36 | if ($dhcp -eq $false) { 37 | $ovfconfig.Common.IP_Address.Value = $vmip 38 | $ovfconfig.Common.NetMask.Value = $netmask 39 | $ovfconfig.Common.Gateway.Value = $gateway 40 | $ovfconfig.Common.DNS_Server_1.Value = $dns1 41 | $ovfconfig.Common.DNS_Server_2.Value = $dns2 42 | $ovfconfig.Common.Hostname.Value = $vmname 43 | } 44 | 45 | #Deploy OVA 46 | Import-VApp -Source $ovffile -OvfConfiguration $ovfconfig -Name $vmname -InventoryLocation $vmfolder -Location $cluster_ref -VMHost $vmhost_ref -Datastore $datastore_ref -Server $vcenter 47 | 48 | $vm = get-vm $vmname 49 | $vm | Start-Vm -RunAsync | Out-Null 50 | 51 | Disconnect-VIServer $vcenter -Confirm:$false -------------------------------------------------------------------------------- /deploy-srm83.ps1: -------------------------------------------------------------------------------- 1 | # PowerCLI Script to deploy SRM 8.3 OVF 2 | # @davidstamen 3 | # https://davidstamen.com 4 | 5 | $vcname = "vc01.my.lab" 6 | $vcuser = "administrator@vsphere.local" 7 | $vcpass = "VMware1!" 8 | 9 | $ovffile = "C:\share\VMware\SRM\VMware-srm-va-8.3.0.4135-15929234\bin\srm-va_OVF10.ovf" 10 | $cluster = "MyCluster" 11 | $vmnetwork = "MyNetwork" 12 | $datastore = "MyDatastore" 13 | $vmfolder = "MyFolder" 14 | $vm1name = "srm1.my.lab" 15 | $vm2name = "srm2.my.lab" 16 | $vm1ip = "10.21.230.58" 17 | $vm2ip = "10.21.230.59" 18 | $addrfamily = "ipv4" 19 | $networkmode = "static" 20 | $gateway = "10.21.230.1" 21 | $domain = "my.lab" 22 | $searchpath = "my.lab" 23 | $dns = "10.21.230.6" 24 | $prefix = "24" 25 | $ntp = "us.pool.ntp.org" 26 | $password = "VMware1!" 27 | $enablessh = $true 28 | 29 | $vcenter = Connect-VIServer $vcname -User $vcuser -Password $vcpass -WarningAction SilentlyContinue 30 | 31 | $datastore_ref = Get-Datastore -Name $datastore 32 | $network_ref = Get-VirtualPortGroup -Name $vmnetwork 33 | $cluster_ref = Get-Cluster -Name $cluster 34 | $vmhost_ref = $cluster_ref | Get-VMHost | Select -First 1 35 | 36 | $ovfconfig = Get-OvfConfiguration $ovffile 37 | $ovfconfig.NetworkMapping.Network_1.value = $vmnetwork 38 | $ovfconfig.network.VMware_Site_Recovery_Manager_Appliance.addrfamily.value = $addrfamily 39 | $ovfconfig.network.VMware_Site_Recovery_Manager_Appliance.netmode.value = $networkmode 40 | $ovfconfig.network.VMware_Site_Recovery_Manager_Appliance.gateway.value = $gateway 41 | $ovfconfig.network.VMware_Site_Recovery_Manager_Appliance.domain.value = $domain 42 | $ovfconfig.network.VMware_Site_Recovery_Manager_Appliance.searchpath.value = $searchpath 43 | $ovfconfig.network.VMware_Site_Recovery_Manager_Appliance.DNS.value = $dns 44 | $ovfconfig.network.VMware_Site_Recovery_Manager_Appliance.netprefix0.value = $prefix 45 | $ovfconfig.common.ntpserver.value = $ntp 46 | $ovfconfig.common.varoot_password.value = $password 47 | $ovfconfig.common.vaadmin_password.value = $password 48 | $ovfconfig.common.dbpassword.value = $password 49 | $ovfconfig.common.enable_sshd.value = $enablessh 50 | 51 | #Deploy SRM1 52 | $ovfconfig.network.VMware_Site_Recovery_Manager_Appliance.ip0.value = $vm1ip 53 | $ovfconfig.common.vami.hostname.value = $vm1ip 54 | Import-VApp -Source $ovffile -OvfConfiguration $ovfconfig -Name $vm1name -InventoryLocation $VMFolder -Location $cluster_ref -VMHost $vmhost_ref -Datastore $datastore_ref 55 | 56 | #Deploy SRM2 57 | $ovfconfig.network.VMware_Site_Recovery_Manager_Appliance.ip0.value = $vm2ip 58 | Import-VApp -Source $ovffile -OvfConfiguration $ovfconfig -Name $vm2name -InventoryLocation $VMFolder -Location $cluster_ref -VMHost $vmhost_ref -Datastore $datastore_ref 59 | 60 | $vms = get-vm $vm1name,$vm2name 61 | $vm | Start-Vm -RunAsync | Out-Null 62 | 63 | Disconnect-VIServer $vcenter -Confirm:$false -------------------------------------------------------------------------------- /permissions.csv: -------------------------------------------------------------------------------- 1 | datacenter,role,group,domain 2 | datacenter,Admin,VMware Administrators,LAB -------------------------------------------------------------------------------- /powercli_purestorage/configurestorage.ps1: -------------------------------------------------------------------------------- 1 | $vcname = "vc.lab.local" 2 | $vcuser = "administrator@vsphere.local" 3 | $vcpass = "VMware1!" 4 | $vccluster = "cluster01" 5 | $volname = "ds01" 6 | $volcapacityTB = "5" 7 | 8 | $pureendpoint = "flasharray.lab.local" 9 | $pureuser = "pureuser" 10 | $purepass = ConvertTo-SecureString "pureuser" -AsPlainText -Force 11 | $purecred = New-Object System.Management.Automation.PSCredential -ArgumentList ($pureuser, $purepass) 12 | 13 | #Connect to Flash Array 14 | $array = New-PfaConnection -endpoint $pureendpoint -credentials $purecred -defaultarray 15 | 16 | #Connect to vCenter Server 17 | $vc = Connect-VIServer $vcname -User $vcuser -Password $vcpass -WarningAction SilentlyContinue 18 | 19 | #Create Hosts and Hostgroup 20 | New-PfaHostGroupfromVcCluster -flasharray $array -cluster (Get-Cluster $vccluster -server $vc) -iscsi 21 | 22 | #Configure ESXi Cluster for ISCSI to Flash Array 23 | Set-ClusterPfaiSCSI -cluster (Get-Cluster $vccluster) -flasharray $array 24 | 25 | #Create Volume, Attach to HostGroup and Provision VMFS Datastore 26 | New-PfaVmfs -flasharray $array -cluster (Get-Cluster $vccluster -server $vc) -volName $volname -sizeInTB $volcapacityTB 27 | 28 | #Disconnect from vCenter Server 29 | Disconnect-VIServer -server $vc -Confirm:$false 30 | 31 | #Disconnect Array 32 | $array = $null 33 | -------------------------------------------------------------------------------- /publish_code_to_github.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo "Updating Master branch" 3 | git add --all && git commit -m "$(curl -s whatthecommit.com/index.txt)" && git push --------------------------------------------------------------------------------