Actions

AWS/Set Host Name

From Ever changing code

< AWS

Windows

User-data

Add-Computer -ComputerName $env:COMPUTERNAME -NewName (((Get-EC2Instance -Instance (Invoke-RestMethod -Method Get -Uri http://169.254.169.254/latest/meta-data/instance-id)).RunningInstance.Tags | Where-Object { $_.Key -eq "Name" }).Value) -DomainName example.com -Credential example\user -restart 

# Require IAM-profile
Invoke-RestMethod -Method Get -Uri http://169.254.169.254/latest/meta-data/instance-id
Get-EC2Instance -InstanceId i-12312312311111122

$instance = (Get-EC2Instance -InstanceId i-12312312311111122)
$instance.Instances.tags


Rename using PowerShell rename

<powershell>
Rename-Computer -NewName foo -Force
Restart-Computer
</powershell>
Resources