VMware Cloud Community
HdeJongh
Contributor
Contributor
Jump to solution

how to copy advanced settings between multipli hosts

Hello,

First of all im a complete powershell n00b.

Im trying to create a simple script which copy's certain advancedsettings from an esxi (5.5) host to another host.

#syslog = get-vmhost $name | get-advancedsettings -name syslog*

but how do i now get it on another host?

cause get-vmhost $name2 | set-advancedsettings $syslog doesnt work Smiley Sad

thanks

Tags (1)
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The Value parameter on the Set-AdvancedSetting is required.

So you should do something like this

foreach($adv in (Get-VMHost $name | Get-AdvancedSetting -Name syslog*)){
 
Get-VMHost -Name $name2 | Get-AdvancedSetting -Name $adv.Name |
   
Set-AdvancedSetting -Value $adv.Value
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

The Value parameter on the Set-AdvancedSetting is required.

So you should do something like this

foreach($adv in (Get-VMHost $name | Get-AdvancedSetting -Name syslog*)){
 
Get-VMHost -Name $name2 | Get-AdvancedSetting -Name $adv.Name |
   
Set-AdvancedSetting -Value $adv.Value
}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

RvdNieuwendijk
Leadership
Leadership
Jump to solution

You have to set each advanced setting separate. Something like this:

$VMHostFrom = Get-VMHost -Name "From"

$VMHostTo = Get-VMHost -Name "To"

$AdvancedSettings = $VMHostFrom | Get-AdvancedSetting -Name syslog*

foreach ($AdvancedSetting in $AdvancedSettings)

{

  $VMHostTo | Get-AdvancedSetting -Name $AdvancedSetting.Name |

  Set-AdvancedSetting -Value $AdvancedSetting.Value -Confirm:$false

}

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition