VMware – Commands to power on VMs from command line

November 10, 2016 Leave a comment

ESXi 5.x and 6.0

List the inventory ID of the virtual machine with the command:

vim-cmd vmsvc/getallvms | grep <vm name>

Note: The first column of the output shows the vmid.

Check the power state of the virtual machine with the command:

vim-cmd vmsvc/power.getstate <vmid>

Power-on the virtual machine with the command:

vim-cmd vmsvc/power.on <vmid>

ESX 4.0 and ESX 4.1

To list the path of all the virtual machines on the host:

vmware-cmd –l

Get the state of the virtual machine with the command:

vmware-cmd <path to the VMX file> getstate

Power on the virtual machine with the command:

vmware-cmd <path to the VMX file> start


PowerShell – Search any User on Active Directory

May 24, 2016 Leave a comment

Below is a small PowerShell script that allows you to search any user on Active Directory:

$user = Read-Host "Enter the name of the user"
Get-ADUser -Filter "sAMAccountName -like ‘*$user*’" |
Get-ADObject -Properties * | ft Name,SamAccountName,Title,,UserPrincipalName,Department


PowerShell – Search and Unlock Active Directory Account

May 23, 2016 Leave a comment

Nice little one-liner to Find and Unlock Active Directory Accounts

Search-ADAccount -LockedOut | Unlock-ADAccount –Confirm


PowerShell – Azure AD Connect sync: Scheduler Command Cheat Sheet

May 13, 2016 Leave a comment

Here are some of the commands.

To view the Scheduler configuration:


This shows you the current sync configuration information like interval, sync policy type, next sync cycle start time etc.

To change the scheduler configuration:


This allows you to change some the following sync parameters.

  • CustomizedSyncCycleInterval
  • NextSyncCyclePolicyType
  • PurgeRunHistoryInterval
  • SyncCycleEnabled
  • MaintenanceEnabled

To Start the Scheduler manually:

There are two synchronization options – Delta and Full.
Delta – Use this when there is an urgent change that needs to be synchronized immediately.

Start-ADSyncSyncCycle -PolicyType Delta

Full – Use this when the following changes have been made.

  • Synchronization rules have been changed
  • Filtering changes, which included different number of objects
  • More attributes or objects are to be imported from source directory
    Start-ADSyncSyncCycle -PolicyType Initial
    Check the status of the connector:

    If its busy and running the sync the connector name will be returned.


More info – Azure Documentation


How to recover sysadmin access to SQL Server 2005/2008 R2 when sa password is lost

May 9, 2016 Leave a comment


  1. Open the SQL Server Configuration Manager tool
  2. Navigate to SQL Server Services and Stop the SQL Server Instance that needs a sa password reset
  3. Right click the on the instance/service and select properties.
  4. Go to the “Advanced” tab, and in the Properties text box add “;–m” to the end of the list in the “Startup parameters” option

    Note! – Please make sure there is no space between “;” and “-m”. In the SQL Server ERRORLOG, there should be an entry that says   “SQL Server started in single-user mode.”

  5. Click the “OK” button and restart the SQL Server Instance

When the SQL Server Instance starts in single-user mode,  you can use the Windows Administrator account to connect to SQL Server using the sqlcmd utility and Windows authentication.

Connect to SQL Server using sqlcmd: sqlcmd –S SERVER1\SQLExpress

The following example adds the account “John” in the “EXAMPLE” domain to the SQL Server “sysadmin” role:

EXEC sp_addsrvrolemember ‘EXAMPLE\John, ‘sysadmin’;

Once the sysadmin access has been recovered, remove the “;-m” from the startup parameters using the Configuration Manager and restart the SQL Server Instance


Upgrading Zabbix from 2.4.x to 3.0.x on CentOS 7

April 13, 2016 Leave a comment

Before starting with the upgrade I recommend familiarising yourself with these pages.

Note! If you are upgrading from earlier versions then you need to upgrade from 1.8.x – 2.x to 2.4.x first. Have a look at my previous post about upgrading Zabbix.

Steps to upgrade

  1. If you are running Zabbix on a virtual machine take a snapshot to revert back to if something goes wrong.
  2. Clean up yum
    yum clean all
  3. Check what zabbix packages you have installed and take a note of them.
    rpm -qa | grep zabbix
  4. Stop Zabbix service.
    systemctl stop zabbix-server
  5. Backup Zabbix (you can skip these if you are using a snapshot)
    mkdir ~/etc_zabbix.bak
    cp -r -p /etc/zabbix/* ~/etc_zabbix.bak
    mkdir ~/web_zabbix.bak
    cp -r -p /usr/share/zabbix/* ~/web_zabbix.bak
    mysqldump -u zabbix -p zabbix > ~/zabbix_dump.sql
  6. Remove old zabbix repo and add the new 3.0.x repo
    rpm -e zabbix-release
    rpm -ivh
  7. Run yum update and install the new packages
    yum update
  8. Verify that new packages have been installed
    rpm -qa | grep zabbix
  9. Restart Zabbix services
    systemctl restart zabbix-agent
    systemctl restart zabbix-server
Categories: CentOS, Linux, Zabbix Tags: , ,

How to clear values via PowerShell in Active Directory

March 23, 2016 Leave a comment


$user = domainuser

set-aduser $user –clear manager

This also works for multiple values, like phonenumber, address etc. just add a coma after values.