Skip to content

Commit 289ec47

Browse files
grizzlytheodoreTheodore Chang
andauthored
add ScriptLocalPath param set for Set-AzVmRunCommand (#19935)
Co-authored-by: Theodore Chang <[email protected]>
1 parent ac1e417 commit 289ec47

File tree

4 files changed

+445
-6
lines changed

4 files changed

+445
-6
lines changed
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
2+
# ----------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
14+
# is regenerated.
15+
# ----------------------------------------------------------------------------------
16+
17+
function Set-AzVMRunCommand_ScriptLocalPath {
18+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IVirtualMachineRunCommand])]
19+
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
20+
param(
21+
[Parameter(Mandatory)]
22+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Path')]
23+
[System.String]
24+
# The name of the resource group.
25+
${ResourceGroupName},
26+
27+
[Parameter(Mandatory)]
28+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Path')]
29+
[System.String]
30+
# The name of the virtual machine run command.
31+
${RunCommandName},
32+
33+
[Parameter(Mandatory)]
34+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Path')]
35+
[System.String]
36+
# The name of the virtual machine where the run command should be created or updated.
37+
${VMName},
38+
39+
[Parameter(Mandatory)]
40+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
41+
[System.String]
42+
# Specifies a commandId of predefined built-in script.
43+
${ScriptLocalPath},
44+
45+
[Parameter()]
46+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Path')]
47+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
48+
[System.String]
49+
# Subscription credentials which uniquely identify Microsoft Azure subscription.
50+
# The subscription ID forms part of the URI for every service call.
51+
${SubscriptionId},
52+
53+
[Parameter(Mandatory)]
54+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
55+
[System.String]
56+
# Resource location
57+
${Location},
58+
59+
[Parameter()]
60+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
61+
[System.Management.Automation.SwitchParameter]
62+
# Optional.
63+
# If set to true, provisioning will complete as soon as the script starts and will not wait for script to complete.
64+
${AsyncExecution},
65+
66+
[Parameter()]
67+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
68+
[System.String]
69+
# Specifies the Azure storage blob where script error stream will be uploaded.
70+
${ErrorBlobUri},
71+
72+
[Parameter()]
73+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
74+
[System.String]
75+
# Specifies the Azure storage blob where script output stream will be uploaded.
76+
${OutputBlobUri},
77+
78+
[Parameter()]
79+
[AllowEmptyCollection()]
80+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
81+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IRunCommandInputParameter[]]
82+
# The parameters used by the script.
83+
# To construct, see NOTES section for PARAMETER properties and create a hash table.
84+
${Parameter},
85+
86+
[Parameter()]
87+
[AllowEmptyCollection()]
88+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
89+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IRunCommandInputParameter[]]
90+
# The parameters used by the script.
91+
# To construct, see NOTES section for PROTECTEDPARAMETER properties and create a hash table.
92+
${ProtectedParameter},
93+
94+
[Parameter()]
95+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
96+
[System.String]
97+
# Specifies the user account password on the VM when executing the run command.
98+
${RunAsPassword},
99+
100+
[Parameter()]
101+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
102+
[System.String]
103+
# Specifies the user account on the VM when executing the run command.
104+
${RunAsUser},
105+
106+
[Parameter()]
107+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
108+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IResourceTags]))]
109+
[System.Collections.Hashtable]
110+
# Resource tags
111+
${Tag},
112+
113+
[Parameter()]
114+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
115+
[System.Int32]
116+
# The timeout in seconds to execute the run command.
117+
${TimeoutInSecond},
118+
119+
[Parameter()]
120+
[Alias('AzureRMContext', 'AzureCredential')]
121+
[ValidateNotNull()]
122+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Azure')]
123+
[System.Management.Automation.PSObject]
124+
# The credentials, account, tenant, and subscription used for communication with Azure.
125+
${DefaultProfile},
126+
127+
[Parameter()]
128+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
129+
[System.Management.Automation.SwitchParameter]
130+
# Run the command as a job
131+
${AsJob},
132+
133+
[Parameter(DontShow)]
134+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
135+
[System.Management.Automation.SwitchParameter]
136+
# Wait for .NET debugger to attach
137+
${Break},
138+
139+
[Parameter(DontShow)]
140+
[ValidateNotNull()]
141+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
142+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Runtime.SendAsyncStep[]]
143+
# SendAsync Pipeline Steps to be appended to the front of the pipeline
144+
${HttpPipelineAppend},
145+
146+
[Parameter(DontShow)]
147+
[ValidateNotNull()]
148+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
149+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Runtime.SendAsyncStep[]]
150+
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
151+
${HttpPipelinePrepend},
152+
153+
[Parameter()]
154+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
155+
[System.Management.Automation.SwitchParameter]
156+
# Run the command asynchronously
157+
${NoWait},
158+
159+
[Parameter(DontShow)]
160+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
161+
[System.Uri]
162+
# The URI for the proxy server to use
163+
${Proxy},
164+
165+
[Parameter(DontShow)]
166+
[ValidateNotNull()]
167+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
168+
[System.Management.Automation.PSCredential]
169+
# Credentials for a proxy server to use for the remote call
170+
${ProxyCredential},
171+
172+
[Parameter(DontShow)]
173+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
174+
[System.Management.Automation.SwitchParameter]
175+
# Use the default credentials for the proxy
176+
${ProxyUseDefaultCredentials}
177+
)
178+
179+
process {
180+
if ($PSBoundParameters.ContainsKey("ScriptLocalPath"))
181+
{
182+
# Read Local File and add
183+
$script = Get-Content -Path $ScriptLocalPath
184+
$PSBoundParameters.Add("SourceScript", $script)
185+
# If necessary, remove the -ParameterA parameter from the dictionary of bound parameters
186+
$null = $PSBoundParameters.Remove("ScriptLocalPath")
187+
}
188+
Az.Compute\Set-AzVMRunCommand @PSBoundParameters
189+
}
190+
}
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
2+
# ----------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
14+
# is regenerated.
15+
# ----------------------------------------------------------------------------------
16+
17+
function Set-AzVmssVMRunCommand_ScriptLocalPath {
18+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IVirtualMachineRunCommand])]
19+
[CmdletBinding(DefaultParameterSetName='UpdateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
20+
param(
21+
[Parameter(Mandatory)]
22+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Path')]
23+
[System.String]
24+
# The instance ID of the virtual machine.
25+
${InstanceId},
26+
27+
[Parameter(Mandatory)]
28+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Path')]
29+
[System.String]
30+
# The name of the resource group.
31+
${ResourceGroupName},
32+
33+
[Parameter(Mandatory)]
34+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Path')]
35+
[System.String]
36+
# The name of the virtual machine run command.
37+
${RunCommandName},
38+
39+
[Parameter(Mandatory)]
40+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Path')]
41+
[System.String]
42+
# The name of the VM scale set.
43+
${VMScaleSetName},
44+
45+
[Parameter(Mandatory)]
46+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
47+
[System.String]
48+
# Specifies a commandId of predefined built-in script.
49+
${ScriptLocalPath},
50+
51+
[Parameter()]
52+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Path')]
53+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
54+
[System.String]
55+
# Subscription credentials which uniquely identify Microsoft Azure subscription.
56+
# The subscription ID forms part of the URI for every service call.
57+
${SubscriptionId},
58+
59+
[Parameter(Mandatory)]
60+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
61+
[System.String]
62+
# Resource location
63+
${Location},
64+
65+
[Parameter()]
66+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
67+
[System.Management.Automation.SwitchParameter]
68+
# Optional.
69+
# If set to true, provisioning will complete as soon as the script starts and will not wait for script to complete.
70+
${AsyncExecution},
71+
72+
[Parameter()]
73+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
74+
[System.String]
75+
# Specifies the Azure storage blob where script error stream will be uploaded.
76+
${ErrorBlobUri},
77+
78+
[Parameter()]
79+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
80+
[System.String]
81+
# Specifies the Azure storage blob where script output stream will be uploaded.
82+
${OutputBlobUri},
83+
84+
[Parameter()]
85+
[AllowEmptyCollection()]
86+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
87+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IRunCommandInputParameter[]]
88+
# The parameters used by the script.
89+
# To construct, see NOTES section for PARAMETER properties and create a hash table.
90+
${Parameter},
91+
92+
[Parameter()]
93+
[AllowEmptyCollection()]
94+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
95+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IRunCommandInputParameter[]]
96+
# The parameters used by the script.
97+
# To construct, see NOTES section for PROTECTEDPARAMETER properties and create a hash table.
98+
${ProtectedParameter},
99+
100+
[Parameter()]
101+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
102+
[System.String]
103+
# Specifies the user account password on the VM when executing the run command.
104+
${RunAsPassword},
105+
106+
[Parameter()]
107+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
108+
[System.String]
109+
# Specifies the user account on the VM when executing the run command.
110+
${RunAsUser},
111+
112+
[Parameter()]
113+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
114+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.Compute.Models.Api20210701.IResourceTags]))]
115+
[System.Collections.Hashtable]
116+
# Resource tags
117+
${Tag},
118+
119+
[Parameter()]
120+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Body')]
121+
[System.Int32]
122+
# The timeout in seconds to execute the run command.
123+
${TimeoutInSecond},
124+
125+
[Parameter()]
126+
[Alias('AzureRMContext', 'AzureCredential')]
127+
[ValidateNotNull()]
128+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Azure')]
129+
[System.Management.Automation.PSObject]
130+
# The credentials, account, tenant, and subscription used for communication with Azure.
131+
${DefaultProfile},
132+
133+
[Parameter()]
134+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
135+
[System.Management.Automation.SwitchParameter]
136+
# Run the command as a job
137+
${AsJob},
138+
139+
[Parameter(DontShow)]
140+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
141+
[System.Management.Automation.SwitchParameter]
142+
# Wait for .NET debugger to attach
143+
${Break},
144+
145+
[Parameter(DontShow)]
146+
[ValidateNotNull()]
147+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
148+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Runtime.SendAsyncStep[]]
149+
# SendAsync Pipeline Steps to be appended to the front of the pipeline
150+
${HttpPipelineAppend},
151+
152+
[Parameter(DontShow)]
153+
[ValidateNotNull()]
154+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
155+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Runtime.SendAsyncStep[]]
156+
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
157+
${HttpPipelinePrepend},
158+
159+
[Parameter()]
160+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
161+
[System.Management.Automation.SwitchParameter]
162+
# Run the command asynchronously
163+
${NoWait},
164+
165+
[Parameter(DontShow)]
166+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
167+
[System.Uri]
168+
# The URI for the proxy server to use
169+
${Proxy},
170+
171+
[Parameter(DontShow)]
172+
[ValidateNotNull()]
173+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
174+
[System.Management.Automation.PSCredential]
175+
# Credentials for a proxy server to use for the remote call
176+
${ProxyCredential},
177+
178+
[Parameter(DontShow)]
179+
[Microsoft.Azure.PowerShell.Cmdlets.Compute.Category('Runtime')]
180+
[System.Management.Automation.SwitchParameter]
181+
# Use the default credentials for the proxy
182+
${ProxyUseDefaultCredentials}
183+
)
184+
185+
process {
186+
if ($PSBoundParameters.ContainsKey("ScriptLocalPath"))
187+
{
188+
# Read Local File and add
189+
$script = Get-Content -Path $ScriptLocalPath
190+
$PSBoundParameters.Add("SourceScript", $script)
191+
# If necessary, remove the -ParameterA parameter from the dictionary of bound parameters
192+
$null = $PSBoundParameters.Remove("ScriptLocalPath")
193+
}
194+
Az.Compute\Set-AzVMRunCommand @PSBoundParameters
195+
}
196+
}
197+

0 commit comments

Comments
 (0)