Issue running powershell scripts in user_data (openstack configdriver)
Hi,
I'm trying to use user_data to run some powershell scripts in the host installation.
I followed the user_data documentation, and I tried the following script to add multiple IP's per NIC:
#ps1
Set-Content C:\Windows\Temp\changeIP.ps1 "$IP = ("10.1.1.12
","10.1.1.13
","10.1.1.14
")
$NetMask = "255.0.0.0
"
$Gateway = "10.1.1.1
"
$Dns = "1.1.1.100
"
$IPType = "IPv4
"
$adapter = Get-NetAdapter | ? {$_.Status -eq "up
"}
If (($adapter | Get-NetIPConfiguration).IPv4Address.IPAddress) { $adapter | Remove-NetIPAddress -AddressFamily $IPType -Confirm:$false }
If (($adapter | Get-NetIPConfiguration).Ipv4DefaultGateway) { $adapter | Remove-NetRoute -AddressFamily $IPType -Confirm:$false }
ForEach ($address In $IP) {
$ifName = $adapter.Name.ToString()
If ($address -eq $IP[0]) {
& netsh interface ipv4 add address "$ifName
" $address $NetMask $Gateway
} Else {
& netsh interface ipv4 add address "$ifName
" $address $NetMask
}
}
$adapter | Set-DnsClientServerAddress -ServerAddresses $DNS"
But the userdata execution doesn't work, and in the logs I receive the message "unsupported userdata format"
Any thoughts?
I've already tried the script you pasted, as "user_data" file in the "latest" folder, but IDK is not working.