@@ -459,7 +459,7 @@ function Copy-FromCloudShell
459
459
- ExceptionObject $PSCmdlet
460
460
return
461
461
}
462
-
462
+
463
463
if ($item -is [System.IO.FileInfo ])
464
464
{
465
465
# item is a file, go ahead to download. Note: No check is necessary because get-item has done that.
@@ -480,7 +480,7 @@ function Copy-FromCloudShell
480
480
481
481
# Zip the directory. Note using jar instead of zip is to ignore original top-level folder structure.
482
482
$null = jar cMvf $tmp - C $fullPath .
483
-
483
+
484
484
if ((Microsoft.PowerShell.Management\Test-Path - Path $tmp ) -or (Microsoft.PowerShell.Management\Test-Path - LiteralPath $tmp ))
485
485
{
486
486
Write-Verbose " Downloading $tmp " - Verbose
@@ -770,7 +770,7 @@ function Get-CloudShellTip
770
770
771
771
if (-not [string ]::IsNullOrEmpty($randomTip ))
772
772
{
773
- $message = " MOTD: " + $randomTip
773
+ $message = " MOTD: " + $randomTip
774
774
$message = " `r`n " + $message + " `r`n " ;
775
775
}
776
776
}
@@ -889,8 +889,8 @@ function Invoke-AzVMCommand
889
889
Provide UserName when connecting to Linux Targets. When used with KeyFilePath parameter, identifies the user on the remote computer
890
890
891
891
. PARAMETER KeyFilePath
892
- Provide SSH KeyFile Path when connecting to Linux Targets, if connection uses Key based authentication
893
-
892
+ Provide SSH KeyFile Path when connecting to Linux Targets, if connection uses Key based authentication
893
+
894
894
. EXAMPLE
895
895
Invoke-AzVMCommand -Name WindowsVM -ResourceGroupName ResourceGroupName -ScriptBlock ScriptBlock -Credential credential
896
896
@@ -928,7 +928,7 @@ function Invoke-AzVMCommand
928
928
[ValidateNotNullOrEmpty ()]
929
929
[string ]$KeyFilePath
930
930
)
931
-
931
+
932
932
if (-not (Test-AzResourceGroup - ResourceGroupName $ResourceGroupName )) {
933
933
$badResourceGroup = $LocalizedData.TestAzResourceGroup -f ($ResourceGroupName )
934
934
throw [System.ArgumentException ] $badResourceGroup
@@ -948,25 +948,25 @@ function Invoke-AzVMCommand
948
948
{
949
949
$message = $LocalizedData.CredentialError
950
950
throw [System.ArgumentException ] $message
951
- }
951
+ }
952
952
}
953
953
954
954
$cName = Test-AzVM @testAzVMParams
955
955
if (-not $cName ) {
956
956
$message = $LocalizedData.GetAzureVMError -f ($Name )
957
957
throw [System.ArgumentException ] $message
958
958
}
959
-
959
+
960
960
if ([OStype ]::Windows -eq $OsType )
961
961
{
962
962
$invokeCommandParams = @ {
963
963
ComputerName = $cName
964
964
UseSSL = $true
965
965
Credential = $Credential
966
966
SessionOption = $script :sessionOption
967
- ScriptBlock = $ScriptBlock
967
+ ScriptBlock = $ScriptBlock
968
968
Authentication = ' Basic'
969
- }
969
+ }
970
970
}
971
971
elseif ([OStype ]::Linux -eq $OsType )
972
972
{
@@ -992,7 +992,7 @@ function Invoke-AzVMCommand
992
992
}
993
993
}
994
994
995
- Invoke-Command @invokeCommandParams - ErrorAction Stop
995
+ Invoke-Command @invokeCommandParams - ErrorAction Stop
996
996
}
997
997
998
998
function Get-AzVmNsg
@@ -1024,7 +1024,7 @@ function Get-AzVmNsg
1024
1024
| Foreach-Object `
1025
1025
{ `
1026
1026
if ($_.NetworkInterfaces -and ($_.NetworkInterfaces.Id -eq $azVMNetInterfacesId )) `
1027
- {
1027
+ {
1028
1028
$nsg += $_
1029
1029
} `
1030
1030
}
@@ -1088,7 +1088,7 @@ function Get-AzVMPSRemoting
1088
1088
1089
1089
[Parameter (Mandatory , ValueFromPipelineByPropertyName )]
1090
1090
$Nsg
1091
- )
1091
+ )
1092
1092
1093
1093
$protocol = @ {https = $false ; http = $false ; ssh = $false }
1094
1094
@@ -1138,7 +1138,7 @@ function Enable-AzVMPSRemoting
1138
1138
1139
1139
[Parameter (Mandatory , ValueFromPipelineByPropertyName )]
1140
1140
[string ]$ResourceGroupName ,
1141
-
1141
+
1142
1142
[ValidateSet (' http' , ' https' , ' ssh' )]
1143
1143
[string ]$Protocol ,
1144
1144
@@ -1186,10 +1186,10 @@ function Enable-AzVMPSRemoting
1186
1186
if ($Protocol -eq ' https' )
1187
1187
{
1188
1188
if (-not $psremoting.Https )
1189
- {
1189
+ {
1190
1190
$null = Az.Network\Add-AzNetworkSecurityRuleConfig - Name ' allow-winrm-https' - DestinationPortRange 5986 @parameters | Az.Network\Set-AzNetworkSecurityGroup
1191
1191
}
1192
-
1192
+
1193
1193
# Setup WinRM HTTPS based remoting using Self-Signed Certificate
1194
1194
$runCommandParameters =
1195
1195
@ {
@@ -1274,7 +1274,7 @@ function Enable-AzVMPSRemoting
1274
1274
# 1) Install powershellcore in linux, if not already present
1275
1275
# 2) backup current sshd_config, configure sshd_config to enable PasswordAuthentication, register powershell subsystem with ssh daemon
1276
1276
# (#2 is required to support interactive username/password authentication over powershell-ssh)
1277
- # 3) Restart the ssh daemon service to pick up the new config changes
1277
+ # 3) Restart the ssh daemon service to pick up the new config changes
1278
1278
$runCommandParameters =
1279
1279
@ {
1280
1280
commandId = ' RunShellScript'
@@ -1286,8 +1286,8 @@ function Enable-AzVMPSRemoting
1286
1286
1287
1287
$null = Az.Resources\Invoke-AzResourceAction - ResourceId $azureVM.Id - Action runCommand - Parameters $runCommandParameters - ApiVersion 2017 - 03 - 30 - Force
1288
1288
}
1289
- }
1290
- }
1289
+ }
1290
+ }
1291
1291
}
1292
1292
1293
1293
function Disable-AzVMPSRemoting
@@ -1339,7 +1339,7 @@ function Disable-AzVMPSRemoting
1339
1339
{
1340
1340
$OsType = Get-OsType - Name $Name - ResourceGroupName $ResourceGroupName
1341
1341
}
1342
-
1342
+
1343
1343
$azVMNsgs = Get-AzVmNsg - Name $Name - ResourceGroupName $ResourceGroupName
1344
1344
1345
1345
if ([OStype ]::Windows -eq $OsType )
@@ -1500,7 +1500,7 @@ function Test-AzVM
1500
1500
[string ]$ResourceGroupName ,
1501
1501
1502
1502
[Parameter (Mandatory = $true )]
1503
- [OSType ]$OsType
1503
+ [OSType ]$OsType
1504
1504
)
1505
1505
1506
1506
$azVMNsgs = Get-AzVmNsg - Name $Name - ResourceGroupName $ResourceGroupName
@@ -1511,10 +1511,10 @@ function Test-AzVM
1511
1511
$psRemoting = Get-AzVMPSRemoting - Name $Name - ResourceGroupName $ResourceGroupName - Nsg $azVMNsg
1512
1512
1513
1513
if ((([OStype ]::Windows -eq $OsType ) -and (-not $psRemoting.https )) -or (([OStype ]::Linux -eq $OsType ) -and (-not $psRemoting.ssh )))
1514
- {
1514
+ {
1515
1515
$errMsg = $LocalizedData.TestAzPsRemotingError -f ($Name , $ResourceGroupName )
1516
- throw $errMsg
1517
- }
1516
+ throw $errMsg
1517
+ }
1518
1518
}
1519
1519
1520
1520
# Check the communication with the remote machine
@@ -1695,7 +1695,7 @@ function GetCommand {
1695
1695
return $commands
1696
1696
}
1697
1697
1698
- function GetAcronymContent
1698
+ function GetAcronymContent
1699
1699
{
1700
1700
# Get the acronyms file
1701
1701
$path = Join-Path - Path $PSScriptRoot - ChildPath ' PSCloudShellUtilityAcronyms.json'
@@ -1710,25 +1710,25 @@ function GetAcronymContent
1710
1710
}
1711
1711
1712
1712
function RedirectOnlineHelp ($Parameters )
1713
- {
1713
+ {
1714
1714
try {
1715
1715
Microsoft.PowerShell.Core\Get-Help @Parameters
1716
1716
}
1717
1717
catch [System.Management.Automation.PSInvalidOperationException ]
1718
1718
{
1719
1719
$err = $_
1720
1720
$matchFound = $err.Exception.Message -match " No program or browser is associated to open the URI (?<link>\w+:\/\/[\w@][\w.:@]+\/?[\w\.?=%&=\-@/$,]*)."
1721
-
1721
+
1722
1722
if (($matchFound -eq $True ) -and (-not [string ]::IsNullOrEmpty($env: ACC_TERM_ID ))) {
1723
1723
$targetLink = $matches [" link" ]
1724
1724
Write-Verbose " Redirecting to $targetLink "
1725
1725
1726
- $uri = " http://localhost:8888/openLink/$ ( $env: ACC_TERM_ID ) "
1727
-
1726
+ $uri = " http://localhost:8888/openLink/$ ( $env: ACC_TERM_ID ) "
1727
+
1728
1728
try {
1729
1729
$null = Invoke-RestMethod - Method Post - Uri $uri - Body " {"" url"" :"" $targetLink "" }" - ContentType " application/json"
1730
1730
}catch {
1731
- Write-Warning - Message " Redirecting to $targetLink failed, please open the link in another page."
1731
+ Write-Warning - Message " Redirecting to $targetLink failed, please open the link in another page."
1732
1732
throw
1733
1733
}
1734
1734
}
@@ -1765,14 +1765,14 @@ function Get-PackageVersion() {
1765
1765
1766
1766
# Apt and some other programs write to stderr, which fails tests without this
1767
1767
$ErrorActionPreference = " Continue"
1768
-
1768
+
1769
1769
# Enumerate all APT packages with versions
1770
1770
$packages = New-Object - TypeName System.Collections.ArrayList
1771
1771
1772
1772
# TODO - find the regular expression to seperate the package name from the package version
1773
- # apt list --installed 2> /dev/null | % {
1773
+ # apt list --installed 2> /dev/null | % {
1774
1774
# Write-Verbose "Apt: $_"
1775
- # if ($_ -match "([^/]*)/[^ ]* ([^ ]*)") {
1775
+ # if ($_ -match "([^/]*)/[^ ]* ([^ ]*)") {
1776
1776
# $p = New-PackageInfo -Name $matches[1] -Version $matches[2] -Type "Apt"
1777
1777
# $null = $packages.Add($p)
1778
1778
# }
@@ -1789,7 +1789,7 @@ function Get-PackageVersion() {
1789
1789
catch {
1790
1790
return " Error"
1791
1791
}
1792
-
1792
+
1793
1793
$version = ($output | % {
1794
1794
if ($_ -match $package.match ) {
1795
1795
Write-Verbose " matched $_ "
@@ -1806,7 +1806,6 @@ function Get-PackageVersion() {
1806
1806
@ {displayname = " Ansible" ; command = " ansible" ; args = " --version" ; match = " ansible \[core ([\d\.]+)\]" },
1807
1807
@ {displayname = " Istio" ; command = " istioctl" ; args = " version -s --remote=false" ; match = " (.+)" },
1808
1808
@ {displayname = " Go" ; command = " go" ; args = " version" ; match = " go version go(\S+) .*" },
1809
- @ {displayname = " Packer" ; command = " packer" ; args = " version" ; match = " Packer v(.+)" },
1810
1809
@ {displayname = " DC/OS CLI" ; command = " dcos" ; args = " --version" ; match = " dcoscli.version=(.*)" },
1811
1810
@ {displayname = " Ripgrep" ; command = " rg" ; args = " --help | head" ; match = " ripgrep ([\d\.]+)$" },
1812
1811
@ {displayname = " Helm" ; command = " helm" ; args = " version --short" ; match = " v(.+)" },
@@ -1826,8 +1825,8 @@ function Get-PackageVersion() {
1826
1825
}
1827
1826
1828
1827
# PIP3 packages
1829
- & pip3 list | % {
1830
- if ($_ -match " (\w+)\s+(.*)" ) {
1828
+ & pip3 list | % {
1829
+ if ($_ -match " (\w+)\s+(.*)" ) {
1831
1830
$p = New-PackageInfo - Name $matches [1 ] - Version $matches [2 ] - Type " PIP"
1832
1831
$null = $packages.Add ($p )
1833
1832
}
0 commit comments