Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down