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
$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
$params = @{ | |
To = 'user@domain.com' | |
From = 'test@client.com' | |
Subject = 'Test Alert' | |
Body = ' ' | |
SmtpServer = 'smtp-relay.gmail.com' | |
UseSsl = $true | |
} | |
Send-MailMessage @params |
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
$services = Import-Csv -Path Services.csv | |
$fname = "Report-$(get-date -f yyyyMMdd.HHmmss).json" | |
$report = @() | |
# Export services to JSON for readability | |
ConvertTo-Json -InputObject $services | Out-File -FilePath Services.json -Force -Confirm:$false | |
foreach ($svc in $services) { | |
foreach ($addr in $svc.Destination_Address.split(',')) { | |
$obj = New-Object -TypeName PSObject |
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
$subnets = @( | |
'10.1.1.253/22' | |
'10.10.10.252/24' | |
'10.1.20.253/24' | |
'10.120.10.252/22' | |
'10.220.10.252/22' | |
'10.254.254.253/24' | |
'10.100.1.249/22' | |
'10.200.1.249/22' | |
'10.30.1.251/22' |
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_names = 'SQL2', 'APP2' | |
$orig_vcenter = 'vc01.client.local' | |
$new_vcenter = 'vcenter.client.local' | |
foreach ($vm_name in $vm_names) { | |
$vm = Get-VM -Server $orig_vcenter -Name $vm_name | |
$vm_path = $vm.extensiondata.config.files.vmpathname | |
'Shutting down {0} ...' -f $vm.Name | |
Stop-VMGuest -Server $orig_vcenter -VM $vm -Confirm:$false | Out-Null |
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
$hosts = '*' | |
$datastore_name = 'NS-VMFS-01' | |
$datastore = Get-Datastore -Name $datastore_name | Select-Object -First 1 | |
$log_dir = '[{0}] Logs' -f $datastore.Name | |
$scratch_location = '{0}/Logs' -f $datastore.ExtensionData.Info.Url -replace 'ds://' | |
foreach ($h in (Get-VMHost $hosts | Sort-Object -Property Name)) { | |
Write-Host "$($h.Name): Redirecting log files ..." | |
$result = Get-AdvancedSetting -Entity $h -Name Syslog.global.logDir | Set-AdvancedSetting -Value "$log_dir/$h" -Confirm:$false | |
Write-Host "New syslog location: $($result.Value)" |
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 = '*' | |
$ntp_servers = '10.10.1.10', '10.10.1.5' | |
Get-VMHostService -VMHost $hosts | Where-Object {$_.key -eq 'ntpd'} | |
Get-VMHostNtpServer -VMHost $hosts | |
Add-VMHostNtpServer -VMHost $hosts -NtpServer $ntp_servers | |
Get-VMHostService -VMHost $hosts | Where-Object {$_.key -eq 'ntpd'} | Start-VMHostService | Set-VMHostService -Policy 'automatic' |