来自本地共享的 Windows :: 运行 脚本的自定义脚本扩展

Custom Script Extension for Windows :: Running scripts from a local share

是否可以通过 powershell.

从 arm 模板中的本地共享中 运行 脚本
$protectedSettings = @{"commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File \filesvr\build\serverUpdate1.ps1"};

Set-AzVMExtension -ResourceGroupName <resourceGroupName> `
    -Location <locationName> `
    -VMName <vmName> `
    -Name "serverUpdate"
    -Publisher "Microsoft.Compute" `
    -ExtensionType "CustomScriptExtension" `
    -TypeHandlerVersion "1.10" `
    -ProtectedSettings $protectedSettings

手臂:

{
  "fileUris": ["https://mystorage.blob.core.windows.net/privatecontainer/script1.ps1"],
  "commandToExecute": "powershell.exe script1.ps1",
  "managedIdentity" : {}
}

谢谢

Is it possible to Running scripts from a local share inside arm template as it possible via powershell.

是的,我们可以使用带有 ARM 模板的 PowerShell 脚本.

同样,您可以查看以下示例:

"properties": {
    "publisher": "Microsoft.Compute",
    "type": "CustomScriptExtension",
    "typeHandlerVersion": "1.8",
    "autoUpgradeMinorVersion": true,
    "settings": {
        "fileUris": [
            "https://mystorage.blob.core.windows.net/deployment/iis-preConfigureScript.ps1"
        ],
        "commandToExecute": "powershell -ExecutionPolicy Unrestricted -File iis-preConfigureScript.ps1"
    }
}
  • 需要确保我们在所需路径中保存了正确的 PowerShell script 并在设置中传递了 correct url

更多信息请参考以下链接:-