In Linux VMs there is an option to pass script from the local folder as discussed here. As per the following windows VM code, The VM needs outbound network access to fileUris, This is changeable for me and in most of the cases VM doesn't have access, and the custom script is getting an Error. Is any option to pass the PS scripts content as an argument for "Custom Script Extension for Windows"?
resource "azurerm_virtual_machine_extension" "custom-script" {
name = "customScript"
virtual_machine_id = azurerm_windows_virtual_machine.vm.id
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.10"
auto_upgrade_minor_version = true
settings = <<SETTINGS
{
"timestamp":123456789
}
SETTINGS
protected_settings = <<PROTECTED_SETTINGS
{
"commandToExecute": "powershell -ExecutionPolicy Unrestricted -File script.ps1",
"fileUris": ["https://mystorage.blob.core.windows.net/ps/script.ps1"]
}
PROTECTED_SETTINGS