Skip to content

Instantly share code, notes, and snippets.

@pavelch
Last active April 11, 2016 20:44
Show Gist options
  • Save pavelch/f3b3a551abdc50b50904c1f1b219f419 to your computer and use it in GitHub Desktop.
Save pavelch/f3b3a551abdc50b50904c1f1b219f419 to your computer and use it in GitHub Desktop.
PowerShell update IP
$path = 'C:\Verne\Data\Config\VerneConfig.omcfg'
$ip = ''
$out = Get-CFNStackResourceSummary -StackName "AWSCloudFormer" | Out-String
$sums = [regex]::split($out, "LastUpdatedTimestamp.*\r\n")
foreach ($sum in $sums) {
if ($sum -Match "LogicalResourceId\s*:\s*InvestigatorFarm") {
$ip = $sum | sls '(?<=PhysicalResourceId\s*:\s*)(.*)(?=\r\n)' | select -expa matches | select -expa value | % { $_.trim() }
}
}
$xml = [xml](Get-Content $path)
$node = $xml.ConfigSectionBase.VerneConfigHostname
Write-Host $xml.ConfigSectionBase.VerneConfigHostname
$xml.ConfigSectionBase.VerneConfigHostname = $ip
Write-Host $xml.ConfigSectionBase.VerneConfigHostname
$xml.Save($path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment