Friday, 24 August 2018

vSphere: Find VM by MAC Address

While trawling through event logs on a Windows server I encountered the following error;


The system detected an address conflict for IP address x.x.x.x with the system having network hardware address 00-50-56-xx-xx-xx. Network operations on this system may be disrupted as a result

Knowing that 00-50-56 is a VMware MAC Address I used PowerShell to search for the network adaptor with that MAC assigned;


Get-VM | Get-NetworkAdapter | Where {$_.MacAddress -eq “00:50:56:xx:xx:xx”} | fl

 The "Parent" in the resulting output is the VM name

Wednesday, 28 February 2018

AWS: IAM Users And Groups Report

The following script will pull the list of groups associated with IAM users in AWS. The user list can be generated by going to the IAM service in the AWS console and selecting "Credential Report".

$users = get-content iam-users.txt
$report = @() 
foreach ($user in $users)
{
    $info = Get-IAMGroupForUser -UserName $user | select -ExpandProperty GroupName
$report+="$user, $info"
}
$report | Out-File "user-groups.csv"