diff --git a/src/Compute/Compute.Autorest/custom/Set-AzVMRunCommand_ScriptLocalPath.ps1 b/src/Compute/Compute.Autorest/custom/Set-AzVMRunCommand_ScriptLocalPath.ps1 index 3acaed5cbddb..30b4e8ebea80 100644 --- a/src/Compute/Compute.Autorest/custom/Set-AzVMRunCommand_ScriptLocalPath.ps1 +++ b/src/Compute/Compute.Autorest/custom/Set-AzVMRunCommand_ScriptLocalPath.ps1 @@ -180,7 +180,50 @@ function Set-AzVMRunCommand_ScriptLocalPath { if ($PSBoundParameters.ContainsKey("ScriptLocalPath")) { # Read Local File and add - $script = (Get-Content -Path $ScriptLocalPath) -join ";" + $script = "" + if ((Get-ChildItem $scriptLocalPath | Select-Object Extension).Extension -eq ".sh"){ + foreach ($line in Get-Content -Path $scriptLocalPath){ + $words = $line.trim().split() + $commentFound = $false + foreach ($word in $words){ + if ($word[0] -eq "#" -and $commentFound -eq $false){ + $commentFound = $true + $script += "``" + $word + " " + } + else{ + $script += $word + " " + } + } + $script = $script.trim() + #close + if ($commentFound){ + $script += "``" + } + $script += ";" + } + } + else{ + foreach ($line in Get-Content -Path $scriptLocalPath){ + $words = $line.trim().split() + $commentFound = $false + foreach ($word in $words){ + if ($word[0] -eq "#" -and $commentFound -eq $false){ + $commentFound = $true + $script += "<" + $word + " " + } + else{ + $script += $word + " " + } + } + $script = $script.trim() + #close + if ($commentFound){ + $script += "#>" + } + $script += ";" + } + } + $PSBoundParameters.Add("SourceScript", $script) # If necessary, remove the -ParameterA parameter from the dictionary of bound parameters $null = $PSBoundParameters.Remove("ScriptLocalPath") diff --git a/src/Compute/Compute.Autorest/custom/Set-AzVmssVMRunCommand_ScriptLocalPath.ps1 b/src/Compute/Compute.Autorest/custom/Set-AzVmssVMRunCommand_ScriptLocalPath.ps1 index 1777ae997bbf..26035344ba21 100644 --- a/src/Compute/Compute.Autorest/custom/Set-AzVmssVMRunCommand_ScriptLocalPath.ps1 +++ b/src/Compute/Compute.Autorest/custom/Set-AzVmssVMRunCommand_ScriptLocalPath.ps1 @@ -185,8 +185,50 @@ function Set-AzVmssVMRunCommand_ScriptLocalPath { process { if ($PSBoundParameters.ContainsKey("ScriptLocalPath")) { - # Read Local File and add - $script = (Get-Content -Path $ScriptLocalPath) -join ";" + # Read Local File and add + $script = "" + if ((Get-ChildItem $scriptLocalPath | Select-Object Extension).Extension -eq ".sh"){ + foreach ($line in Get-Content -Path $scriptLocalPath){ + $words = $line.trim().split() + $commentFound = $false + foreach ($word in $words){ + if ($word[0] -eq "#" -and $commentFound -eq $false){ + $commentFound = $true + $script += "``" + $word + " " + } + else{ + $script += $word + " " + } + } + $script = $script.trim() + #close + if ($commentFound){ + $script += "``" + } + $script += ";" + } + } + else{ + foreach ($line in Get-Content -Path $scriptLocalPath){ + $words = $line.trim().split() + $commentFound = $false + foreach ($word in $words){ + if ($word[0] -eq "#" -and $commentFound -eq $false){ + $commentFound = $true + $script += "<" + $word + " " + } + else{ + $script += $word + " " + } + } + $script = $script.trim() + #close + if ($commentFound){ + $script += "#>" + } + $script += ";" + } + } $PSBoundParameters.Add("SourceScript", $script) # If necessary, remove the -ParameterA parameter from the dictionary of bound parameters $null = $PSBoundParameters.Remove("ScriptLocalPath")