Restarting the Management agents on ESXi

Restarting the Management agents on ESXi

To restart the management agents on ESXi:

From the Direct Console User Interface (DCUI):

  1. Connect to the console of your ESXi host.
  2. Press F2 to customize the system.
  3. Log in as root.
  4. Use the Up/Down arrows to navigate to Restart Management Agents.

    Note: In ESXi 4.1 and ESXi 5.0, 5.1 and 5.5, this option is available under Troubleshooting Options.

  5. Press Enter.
  6. Press F11 to restart the services.
  7. When the service has been restarted, press Enter.
  8. Press Esc to log out of the system.

From the Local Console or SSH:

  1. Log in to SSH or Local console as root.
  2. Run these commands:

    /etc/init.d/hostd restart
    /etc/init.d/vpxa restart


PS format table to get txt string

$name = get-aduser lwr | foreach { $ }

 echo $name

Powershell disable UAC

New-ItemProperty -Path HKLM:Software\Microsoft\Windows\CurrentVersion\policies\system -Name EnableLUA -PropertyType DWord -Value 0 -Force


PS install telnet fast


Import-Module servermanager
Add-WindowsFeature telnet-client


Import-Module servermanager
Remove-WindowsFeature telnet-client

PS Write to event log

# run one time to create tread

New-EventLog –LogName Application –Source “My Task”

#Write to event log

Write-EventLog –LogName Application –Source “My Task” –EntryType Information –EventID 1
 –Message “This is a test message.”

Powershell Check if service is running and start it up

function FuncCheckService{


    $arrService = Get-Service -Name $ServiceName

    if ($arrService.Status -ne "Running"){

        Stop-Service $ServiceName

                                Start-Service $ServiceName

        FuncMail -To "" -From ""  -Subject "Servername : ($ServiceName) service started." -Body "Service $ServiceName started" -smtpServer ""




function FuncMail {

    #param($strTo, $strFrom, $strSubject, $strBody, $smtpServer)

    param($To, $From, $Subject, $Body, $smtpServer)

    $msg = new-object Net.Mail.MailMessage

    $smtp = new-object Net.Mail.SmtpClient($smtpServer)

    $msg.From = $From


    $msg.Subject = $Subject

    $msg.IsBodyHtml = 1

    $msg.Body = $Body




FuncCheckService -ServiceName "Smart Card"

PS function disable IE Enhanced Security in Windows Server 2012

function Disable-IEESC
$AdminKey = “HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}”
$UserKey = “HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}”
Set-ItemProperty -Path $AdminKey -Name “IsInstalled” -Value 0
Set-ItemProperty -Path $UserKey -Name “IsInstalled” -Value 0
Stop-Process -Name Explorer
Write-Host “IE Enhanced Security Configuration (ESC) has been disabled.” -ForegroundColor Green

# if you paste into console hit enter twice

VMware new vlan VirtualPortGroup powerCLI

# get-cluster ESXiCluxx | get-vmhost | Get-VirtualSwitch -name vswitchx | New-VirtualPortGroup –Name "Name of group" -vlanid xx

get-cluster ESXiClu000 | get-vmhost | Get-VirtualSwitch -name vswitch1 | New-VirtualPortGroup –Name "VLAN 0499 - DMZ-Public" -vlanid 499

Powershell test SQL connection

#see if you can login change to wrong pass to see if you get no connection.

$dataSource = ""

$user = "dbuser"

$pwd = "pass10"

$database = "dbTEST"

$connectionString = "Server=$dataSource;uid=$user; pwd=$pwd;Database=$database;Integrated Security=False;"


$connection = New-Object System.Data.SqlClient.SqlConnection

$connection.ConnectionString = $connectionString







VMware install vm-tools on RedHat from Console

#mount vmware tools in VC

sudo mkdir /mnt/cdrom

sudo mount /dev/cdrom /mnt/cdrom

tar xzvf /mnt/cdrom/VMwareTools-9.4.5-1734305.tar.gz -C /tmp/

cd /tmp/vmware-tools-distrib/

sudo ./ -d

sudo reboot



Telnet test mailserver

telnet mail.domain.ext 25

#You should receive a reply like:

#Trying ???.???.???.???...

#Connected to mail.domain.ext.

#Escape character is '^]'.

#220 mail.domain.ext ESMTP


#This should give you:

#250 mail.domain.ext Hello

MAIL FROM: mail@domain.ext

#250 2.1.0 mail@domain.ext... Sender ok

RCPT TO: mail@otherdomain.ext

#250 2.1.0 mail@otherdomain.ext... Recipient ok

#To start composing the message issue the command DATA


#If you want a subject for your email type Subject:-type subject here- then press enter twice (these are needed to conform to RFC 882)


#You may now proceed to type the body of your message (e.g. hello mail@otherdomain.ext from mail@domain.ext)
#To tell the mail server that you have completed the message enter a single "." on a line on it's own.The mail server should reply with:

#250 2.0.0 ???????? Message accepted for delivery

#You can close the connection by issuing the QUIT command.

#The mailserver should reply with something like:

#221 2.0.0 mail.domain.ext closing connectionConnection closed by foreign host.

Debugging Postfix Config, Mail Logs & more

Test SMTP:

echo "Test mail from postfix" | mail -s "Test Postfix"

postconf -n #show postfix config

/etc/postfix/ #main postfix conf 

/etc/postfix/transport #transport db nano it

postmap /etc/postfix/transport #make db

/var/log/mail.log #mail log file

dpkg-reconfigure postfix #Ubuntu/Debian start an interactive wizard which will guide you through different configurations

service postfix restart #restart service

Exchange 2010 Search-Mailbox

Searches all mailboxes:

Get-Mailbox | Search-Mailbox -SearchQuery 'Search txt here' -TargetMailbox "DiscoveryMailbox" -TargetFolder "SMB_xxx" -LogLevel Full


Searches one user:

Search-Mailbox -Identity "Joe Healy" -SearchQuery "Subject:Search txt here" -TargetMailbox "DiscoveryMailbox" -TargetFolder "SMB_xxx" -LogLevel Full


get-mailbox | Search-Mailbox -SearchQuery 'Participants:"" OR SenderAddress:""' -TargetMailbox "DiscoveryMailbox" -TargetFolder "SMB_fff"

get-mailbox | where {$_.alias -ne "xxx"} | Search-Mailbox -SearchQuery 'Participants:"" OR SenderAddress:""' -TargetMailbox "DiscoveryMailbox" -TargetFolder "SMB_fff"


-eq Equal to
-lt Less than
-gt Greater than
-ge Greater than or Eqaul to
-le Less than or equal to
-ne Not equal to


PowerShell-session with Microsoft Lync 2010 – 201

$cred = Get-Credential “doamin\user”

$session = New-PSSession -ConnectionURI “https://servername/OcsPowershell” -Credential $cred

Import-PsSession $session

PowerShell Commands on Remote Computers

PowerShell Remoting allows you to run individual PowerShell commands or access full PowerShell sessions on remote Windows systems. It’s similar to SSH for accessing remote terminals on other operating systems.
PowerShell is locked-down by default, so you’ll have to enable PowerShell Remoting before using it.

On the computer you want to access remotely, open a PowerShell window as Administrator – right click the PowerShell shortcut and select Run as Administrator.

Enable-PSRemoting -Force

This command starts the WinRM service, sets it to start automatically with your system, and creates a firewall rule that allows incoming connections. The -Force part of the command tells PowerShell to perform these actions without prompting you for each step.

Testing the Connection.

On the computer you want to access the remote system from, use the Test-WsMan cmdlet to test your configuration. This command tests whether the WinRM service is running on the remote computer – if it completes successfully, you’ll know that WinRM is enabled and the computers can communicate with each other. Use the following cmdlet, replacing COMPUTER with the name of your remote computer:


Executing a Remote CommandTo run a command on the remote system, use the Invoke-Command cmdlet. The syntax of the command is as follows:

Invoke-Command -ComputerName COMPUTER -ScriptBlock { COMMAND } -credential USERNAME

COMPUTER represents the computer’s name, COMMAND is the command you want to run, and USERNAME is the username you want to run the command as on the remote computer. You’ll be prompted to enter a password for the username.

Use the Enter-PSSession cmdlet to start a remote PowerShell session, where you can run multiple commands, instead of running a single command:

Enter-PSSession -ComputerName COMPUTER -Credential USER


1 2 3 4 5  Next»