This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get a list of IP addresses with PowerCLI | |
$Vmhosts = 'sac0esxi*' | |
$Vmks = 'vmk2', 'vmk3', 'vmk5', 'vmk6' | |
Get-VMHostNetworkAdapter -VMHost $Vmhosts -Name $Vmks | sort VMHost, Name | ft -auto VMHost, Name, IP | |
# ESXi host Bash function to ping all iSCSI addresses | |
ping_iscsi () { | |
mtu=8972 | |
failures=0 | |
vmks="vmk2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Disable CBT on virtual machines | |
$vms = (Get-VM | Get-View).Where{$_.ChangeTrackingEnabled -match 'True'}.Name | |
foreach ($vm in $vms) { | |
$vm_view = Get-vm $vm | get-view | |
$vm_config_spec = New-Object VMware.Vim.VirtualMachineConfigSpec | |
$vm_config_spec.changeTrackingEnabled = $false | |
$vm_view.reconfigVM($vm_config_spec) | |
$snap = New-Snapshot (Get-VM $vm) -Name "Disable CBT" | |
$snap | Remove-Snapshot -confirm:$false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get vSphere RDMs | |
Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$vm = 'vm1', 'vm2' | |
Get-VM $vm | New-AdvancedSetting -name "isolation.tools.paste.disable" -Value $false -Confirm:$false -Force | |
Get-VM $vm | New-AdvancedSetting -name "isolation.tools.copy.disable" -Value $false -Confirm:$false -Force | |
# Power off the VM and back on | |
Stop-VMGuest -VM $vm -Confirm:$false | Out-Null | |
while ((Get-VM -Name $vm).PowerState -ne 'PoweredOff') {Start-Sleep 2} | |
Start-VM -VM $vm -ErrorAction SilentlyContinue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save an encrypted password to a file and retrieve it later for use in a script | |
Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File password.txt | |
$user = 'user' | |
$password = Get-Content password.txt | ConvertTo-SecureString | |
$creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user, $password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$datastore = Get-Datastore -Name 'ISOs' | Select-Object -First 1 | |
$src = 'C:\Temp\VMware-VCSA-all-6.5.0-8307201.iso' | |
$ds = New-PSDrive -Location $datastore -Name ds -PSProvider VimDatastore -Root '\' | |
Copy-DatastoreItem -Item $src -Destination ds:\ | |
Remove-PSDrive $ds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$smtp_sender = 'vcenter@domain.com' | |
$smtp_recipients = 'support@domain.com' | |
$smtp_server = 'smtp.domain.com' | |
$smtp_user = '' | |
$smtp_password = '' | |
$smtp_port = '25' | |
$vcenter = $global:defaultviservers.Name | |
$alarms = @( | |
@{ | |
alarm_definition = 'Datastore usage on disk' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$hosts = '*' | |
$domain = 'domain.local' | |
$ad_group = 'Domain Admins' | |
$user = 'user' | |
$password = 'password' | |
Get-VMHostAuthentication -VMHost $hosts | Set-VMHostAuthentication -JoinDomain -Domain $domain -User $user -Password $password | |
Get-AdvancedSetting -Entity $hosts -Name Config.HostAgent.plugins.hostsvc.esxAdminsGroup | Set-AdvancedSetting -Value $ad_group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$vmhost = 'esxi-01.domain.local' | |
$vcenter = 'vcenter.domain.local' | |
$vcenter_user = 'administrator@vsphere.local' | |
# Save encrypted password to a file | |
# Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File vcenter-password.txt | |
$vcenter_password = Get-Content vcenter-password.txt | ConvertTo-SecureString | |
$nimble_mgmt_address = '10.1.1.1' | |
$nimble_user = 'admin' | |
# Save encrypted password to a file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$vmhost = 'esxi-01.domain.local' | |
$virtual_machines = Get-VM -Location $vmhost | |
$vcenter = 'vcenter.domain.local' | |
$vcenter_user = 'administrator@vsphere.local' | |
# Save an encrypted password to a file and retrieve it later for use in a script | |
# Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File password.txt | |
$vcenter_password = Get-Content 'Distributed Switch Migration\password.txt' | ConvertTo-SecureString | |
if(-not $global:DefaultVIServers) { | |
$creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $vcenter_user, $vcenter_password |
OlderNewer