Entradas

Mostrando entradas de 2019

Test SMTP/e-mail Server relay with PowerShell

To test your SMTP/e-mail Server relay using Powershell, execute: Send-MailMessage –From mailbox1@domain.com –To alejandra.restrepo@mailbox1@domain.com –Subject “Test PowerShell” –Body “Test E-mail (body)” -SmtpServer smtp-relay.gmail.com -port 25 You can use a powershell script .ps1: $EmailFrom = "sender@gmail.com" $EmailTo = "recipient@email.com" $Subject = "Subject" $Body = "Body" $SMTPServer = "smtp.gmail.com" $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587) $SMTPClient.EnableSsl = $true $SMTPClient.Credentials = New-Object System.Net.NetworkCredential("sender@gmail.com", "YourGmailPassword"); $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body) If you have problems with the execution policy, run: Powershell.exe -executionpolicy remotesigned -File C:\Users\myusername\myfile.ps1

Simple Way to Delete all Snapshots on vSphere - PowerCLI

Have our virtualization environment free of snapshots is a best practice to prevent low storage problems and performance degradation. Check you environment for snapshots older than 7 day's, using the command: Get-VM | Get-Snapshot |Where { $_ .Created -lt ( Get-Date ).AddDays(-7)}| Select-Object VM,Name,Created, @ {N= "SizeGB" ; E={ [math] :: round( $_ .SizeGB, 1)}} | FT Delete all snapshots for a specific VM run: Get-VM MYVM-NAME| Get-Snapshot | Remove-Snapshot -RemoveChildren -Confirm : $False If you want delete all snapshots for all VM's use: Get-VM | Get-Snapshot | Remove-Snapshot -RemoveChildren -Confirm : $False  Sometimes delete snapshots fail in consolidation process and snapshot manager don't show snapshots. To check if all VM's are OK run: Get-VM | Where-Object { $_ .Extensiondata.Runtime.ConsolidationNeeded}  To start consolitation process execute: Get-VM | Where-Object { $_ .Extensiondata.Runtime.Consolidation