AWS/Set Host Name

From Ever changing code
< AWS
Revision as of 20:37, 6 February 2019 by Pio2pio (talk | contribs) (Created page with "= Windows = == User-data == <syntaxhighlightjs lang="powershell"> Add-Computer -ComputerName $env:COMPUTERNAME -NewName (((Get-EC2Instance -Instance (Invoke-RestMethod -Method...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Windows

User-data

<syntaxhighlightjs lang="powershell"> 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

  1. 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 </syntaxhighlightjs>


Rename using PowerShell rename <syntaxhighlightjs lang="powershell"> <powershell> Rename-Computer -NewName foo -Force Restart-Computer </powershell> </syntaxhighlightjs>

Resources