Set-AzVMCustomScriptExtension
將自定義腳本擴充功能新增至虛擬機。
語法
Set-AzVMCustomScriptExtension
[-ResourceGroupName] <String>
[-VMName] <String>
[-Name <String>]
-ContainerName <String>
-FileName <String[]>
[-StorageAccountName <String>]
[-StorageEndpointSuffix <String>]
[-StorageAccountKey <String>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzVMCustomScriptExtension
[-ResourceGroupName] <String>
[-VMName] <String>
[-Name <String>]
[-FileUri <String[]>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzVMCustomScriptExtension
-Name <String>
-VMObject <PSVirtualMachine>
-ContainerName <String>
-FileName <String[]>
[-StorageAccountName <String>]
[-StorageEndpointSuffix <String>]
[-StorageAccountKey <String>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzVMCustomScriptExtension
-Name <String>
-VMObject <PSVirtualMachine>
[-FileUri <String[]>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzVMCustomScriptExtension
-ResourceId <String>
-ContainerName <String>
-FileName <String[]>
[-StorageAccountName <String>]
[-StorageEndpointSuffix <String>]
[-StorageAccountKey <String>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzVMCustomScriptExtension
-ResourceId <String>
[-FileUri <String[]>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzVMCustomScriptExtension
-InputObject <VirtualMachineCustomScriptExtensionContext>
-ContainerName <String>
-FileName <String[]>
[-StorageAccountName <String>]
[-StorageEndpointSuffix <String>]
[-StorageAccountKey <String>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzVMCustomScriptExtension
-InputObject <VirtualMachineCustomScriptExtensionContext>
[-FileUri <String[]>]
[-Run <String>]
[-Argument <String>]
[-SecureExecution]
[-TypeHandlerVersion <String>]
[-Location <String>]
[-DisableAutoUpgradeMinorVersion]
[-ForceRerun <String>]
[-NoWait]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Set-AzVMCustomScriptExtension Cmdlet 會將自定義腳本虛擬機擴充功能新增至虛擬機。 此擴充功能可讓您在虛擬機上執行自己的腳本。
範例
範例 1:新增自訂腳本
Set-AzVMCustomScriptExtension -ResourceGroupName "ResourceGroup11" -Location "Central US" -VMName "VirtualMachine07" -Name "ContosoTest" -TypeHandlerVersion "1.1" -StorageAccountName "Contoso" -StorageAccountKey <StorageKey> -FileName "ContosoScript.exe" -ContainerName "Scripts"
此命令會將自定義腳本新增至名為 VirtualMachine07 的虛擬機。 文稿檔案 contososcript.exe。
範例 2
將自定義腳本擴充功能新增至虛擬機。 ( 自動產生 )
Set-AzVMCustomScriptExtension -Argument <String> -ContainerName 'Scripts' -DefaultProfile <IAzureContextContainer> -FileName 'ContosoScript.exe' -Location 'Central US' -Name 'ContosoTest' -ResourceGroupName 'ResourceGroup11' -Run 'myScript.ps1' -SecureExecution -StorageAccountKey <String> -StorageAccountName 'Contoso' -TypeHandlerVersion '1.1' -VMName 'VirtualMachine07'
參數
-Argument
指定文稿延伸模組傳遞至腳本的自變數。
類型: | String |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | True |
接受萬用字元: | False |
-Confirm
在執行 Cmdlet 之前,提示您進行確認。
類型: | SwitchParameter |
別名: | cf |
Position: | Named |
預設值: | False |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-ContainerName
指定此 Cmdlet 儲存文稿的 Azure 記憶體容器名稱。
類型: | String |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-DefaultProfile
用於與 azure 通訊的認證、帳戶、租用戶和訂用帳戶。
類型: | IAzureContextContainer |
別名: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-DisableAutoUpgradeMinorVersion
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | True |
接受萬用字元: | False |
-FileName
指定文稿檔的名稱。 如果檔案儲存在 Azure Blob 記憶體中,檔名值會區分大小寫。 儲存在 Azure 檔案記憶體中的檔案檔名不區分大小寫。
類型: | String[] |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-FileUri
指定文稿檔案的 URI。
類型: | String[] |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | True |
接受萬用字元: | False |
-ForceRerun
表示此 Cmdlet 會在虛擬機上強制重新執行相同的擴充功能組態,而不需卸載並重新安裝擴充功能。 值可以是與目前值不同的任何字串。 如果未變更 forceUpdateTag,處理程式仍會套用對公用或受保護設定的更新。
類型: | String |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | True |
接受萬用字元: | False |
-InputObject
VM 擴充物件。
類型: | VirtualMachineCustomScriptExtensionContext |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-Location
指定虛擬機的位置。
類型: | String |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | True |
接受萬用字元: | False |
-Name
指定自訂文稿擴充功能的名稱。
類型: | String |
別名: | ExtensionName |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-NoWait
啟動作業,並在作業完成之前立即傳回。 若要判斷作業是否已順利完成,請使用一些其他機制。
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-ResourceGroupName
指定虛擬機的資源群組名稱。
類型: | String |
Position: | 0 |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-ResourceId
VM 擴充功能 ResourceID。
類型: | String |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-Run
指定要用來執行文稿的命令。
類型: | String |
別名: | RunFile, Command |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | True |
接受萬用字元: | False |
-SecureExecution
指出此 Cmdlet 可確保 Run 參數的值不會登入伺服器,或使用 GET 擴充功能 API 傳回給使用者。 Run 的值可能包含要安全地傳遞至腳本檔案的秘密或密碼。
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | True |
接受萬用字元: | False |
-StorageAccountKey
指定 Azure 記憶體容器的金鑰。
類型: | String |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | True |
接受萬用字元: | False |
-StorageAccountName
指定此 Cmdlet 儲存文稿的 Azure 記憶體帳戶名稱。
類型: | String |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | True |
接受萬用字元: | False |
-StorageEndpointSuffix
指定記憶體端點後綴。
類型: | String |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | True |
接受萬用字元: | False |
-TypeHandlerVersion
指定要用於此虛擬機的擴充功能版本。 若要取得版本,請使用 PublisherName 參數的 Microsoft.Compute 值和 Type 參數的 CustomScriptExtension 執行 Get-AzVMExtensionImage Cmdlet。
類型: | String |
別名: | HandlerVersion, Version |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | True |
接受萬用字元: | False |
-VMName
指定虛擬機的名稱。 這個 Cmdlet 會為此參數指定的虛擬機新增自定義腳本擴充功能。
類型: | String |
別名: | ResourceName |
Position: | 1 |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-VMObject
VM 物件。
類型: | PSVirtualMachine |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-WhatIf
顯示 Cmdlet 執行時會發生什麼事。 Cmdlet 未執行。
類型: | SwitchParameter |
別名: | wi |
Position: | Named |
預設值: | False |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
輸入
String[]