Skip to content

Commit 6c38a10

Browse files
swashtekwyunchi-ms
andauthored
Adding Remote Support cmdlets for Stack HCI (#16819)
* Adding Remote Support cmdlet to install, remove, enable, disable, get access and get session history. * Adding logging setup and removing -ListAvailable flag for checking module * Added cmdlet help, fixed signature issues, made SasCredential optional parameter * Updating help for cmdlet * Output type of cmdlet to Boolean * Updated release notes for Remote Support cmdlet change * Moving DownloadCacheDirectory and RemoteSupportPAckageUri variables to required function. Co-authored-by: Yunchi Wang <[email protected]>
1 parent dc0fdc3 commit 6c38a10

10 files changed

+833
-3
lines changed

src/StackHCI/Az.StackHCI.psd1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ FunctionsToExport = 'Register-AzStackHCI', 'Unregister-AzStackHCI',
7373
'Test-AzStackHCIConnection', 'Set-AzStackHCI',
7474
'Enable-AzStackHCIAttestation', 'Disable-AzStackHCIAttestation',
7575
'Add-AzStackHCIVMAttestation', 'Remove-AzStackHCIVMAttestation',
76-
'Get-AzStackHCIVMAttestation'
76+
'Get-AzStackHCIVMAttestation','Install-AzStackHCIRemoteSupport',
77+
'Enable-AzStackHCIRemoteSupport','Disable-AzStackHCIRemoteSupport',
78+
'Get-AzStackHCIRemoteSupportAccess','Get-AzStackHCIRemoteSupportSessionHistory',
79+
'Remove-AzStackHCIRemoteSupport'
7780

7881
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
7982
CmdletsToExport = @()

src/StackHCI/Az.StackHCI.psm1

Lines changed: 301 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4496,6 +4496,300 @@ param(
44964496
}
44974497
}
44984498

4499+
<#
4500+
.DESCRIPTION
4501+
New-Directory creates new directory if doesn't exist already.
4502+
4503+
.PARAMETER Path
4504+
Mandatory. Directory path.
4505+
4506+
.EXAMPLE
4507+
Get all guests on cluster.
4508+
C:\PS>New-Directory -Path "C:\tool"
4509+
4510+
.NOTES
4511+
#>
4512+
function New-Directory{
4513+
param(
4514+
[Parameter(Mandatory=$true)][ValidateNotNull()][string]$Path
4515+
)
4516+
4517+
if (!(Test-Path -Path $Path -PathType Container))
4518+
{
4519+
Write-Progress("Creating directory at $Path")
4520+
New-Item -ItemType Directory -Path $Path | Out-Null
4521+
}
4522+
else
4523+
{
4524+
Write-Progress("Directory already exists at $Path")
4525+
}
4526+
}
4527+
4528+
<#
4529+
.SYNOPSIS
4530+
Invokes deployment module download
4531+
4532+
.Description
4533+
Invoke-DeploymentModuleDownload downloads Remote Support Deployment module from storage account.
4534+
4535+
.EXAMPLE
4536+
Get all guests on cluster.
4537+
C:\PS>Invoke-DeploymentModuleDownload
4538+
4539+
.NOTES
4540+
#>
4541+
function Invoke-DeploymentModuleDownload{
4542+
# Remote Support
4543+
New-Variable -Name RemoteSupportPackageUri -Value "https://remotesupportpackages.blob.core.windows.net/packages" -Option Constant -Scope Script
4544+
$DownloadCacheDirectory = Join-Path $env:Temp "RemoteSupportPkgCache"
4545+
4546+
$BlobLocation = "$script:RemoteSupportPackageUri/Microsoft.AzureStack.Deployment.RemoteSupport.psm1"
4547+
$OutFile = (Join-Path $DownloadCacheDirectory "Microsoft.AzureStack.Deployment.RemoteSupport.psm1")
4548+
New-Directory -Path $DownloadCacheDirectory
4549+
Write-Progress("Downloading Remote Support Deployment module from the BLOB $BlobLocation")
4550+
$retryCount = 3
4551+
Setup-Logging -LogFilePrefix "AzStackHCIRemoteSupport"
4552+
Retry-Command -Attempts $retryCount -RetryIfNullOutput $false -ScriptBlock { Invoke-WebRequest -Uri $BlobLocation -outfile $OutFile }
4553+
}
4554+
4555+
<#
4556+
.SYNOPSIS
4557+
Installs deploy module.
4558+
4559+
.DESCRIPTION
4560+
Install-DeployModule checks if given module is loaded and if not, it downloads, imports and installs remote support deployment module.
4561+
4562+
.EXAMPLE
4563+
C:\PS>Install-DeployModule -ModuleName "Microsoft.AzureStack.Deployment.RemoteSupport"
4564+
4565+
.NOTES
4566+
#>
4567+
function Install-DeployModule {
4568+
[CmdletBinding()]
4569+
param (
4570+
[Parameter(Mandatory=$true)]
4571+
[string]
4572+
$ModuleName
4573+
)
4574+
4575+
if(Get-Module | Where-Object { $_.Name -eq $ModuleName }){
4576+
Write-Host "$ModuleName is loaded already ..."
4577+
}
4578+
else{
4579+
Write-Host "$ModuleName is not loaded, downloading ..."
4580+
4581+
# Download Remote Support Deployment module from storage
4582+
Invoke-DeploymentModuleDownload
4583+
}
4584+
4585+
# Import Remote Support Deployment module
4586+
$DownloadCacheDirectory = Join-Path $env:Temp "RemoteSupportPkgCache"
4587+
Import-Module (Join-Path $DownloadCacheDirectory "Microsoft.AzureStack.Deployment.RemoteSupport.psm1") -Force
4588+
}
4589+
4590+
<#
4591+
.SYNOPSIS
4592+
Installs Remote Support.
4593+
4594+
.DESCRIPTION
4595+
Install-AzStackHCIRemoteSupport installs Remote Support Deployment module.
4596+
4597+
.EXAMPLE
4598+
C:\PS>Install-AzStackHCIRemoteSupport
4599+
4600+
.NOTES
4601+
#>
4602+
function Install-AzStackHCIRemoteSupport{
4603+
[CmdletBinding(SupportsShouldProcess)]
4604+
[OutputType([Boolean])]
4605+
param()
4606+
4607+
Install-DeployModule -ModuleName "Microsoft.AzureStack.Deployment.RemoteSupport"
4608+
Microsoft.AzureStack.Deployment.RemoteSupport\Install-RemoteSupport
4609+
}
4610+
4611+
<#
4612+
.SYNOPSIS
4613+
Removes Remote Support.
4614+
4615+
.DESCRIPTION
4616+
Remove-AzStackHCIRemoteSupport uninstalls Remote Support Deployment module.
4617+
4618+
.EXAMPLE
4619+
C:\PS>Remove-AzStackHCIRemoteSupport
4620+
4621+
.NOTES
4622+
#>
4623+
function Remove-AzStackHCIRemoteSupport{
4624+
[CmdletBinding(SupportsShouldProcess)]
4625+
[OutputType([Boolean])]
4626+
param()
4627+
4628+
Install-DeployModule -ModuleName "Microsoft.AzureStack.Deployment.RemoteSupport"
4629+
Microsoft.AzureStack.Deployment.RemoteSupport\Remove-RemoteSupport
4630+
}
4631+
4632+
<#
4633+
.SYNOPSIS
4634+
Enables Remote Support.
4635+
4636+
.DESCRIPTION
4637+
Enables Remote Support allows authorized Microsoft Support users to remotely access the device for diagnostics or repair depending on the access level granted.
4638+
4639+
.PARAMETER AccessLevel
4640+
Controls the remote operations that can be performed. This can be either Diagnostics or DiagnosticsAndRepair.
4641+
4642+
.PARAMETER ExpireInDays
4643+
Optional. Defaults to 8 hours.
4644+
4645+
.PARAMETER SasCredential
4646+
Hybrid Connection SAS Credential.
4647+
4648+
.PARAMETER AgreeToRemoteSupportConsent
4649+
Optional. If set to true then records user consent as provided and proceeds without prompt.
4650+
4651+
.EXAMPLE
4652+
The example below enables remote support for diagnostics only for 1 day. After expiration no more remote access is allowed.
4653+
PS C:\> Enable-AzStackHCIRemoteSupport -AccessLevel Diagnostics -ExpireInMinutes 1440 -SasCredential "Sample SAS"
4654+
4655+
.NOTES
4656+
Requires Support VM to have stable internet connectivity.
4657+
#>
4658+
function Enable-AzStackHCIRemoteSupport{
4659+
[CmdletBinding(SupportsShouldProcess)]
4660+
[OutputType([Boolean])]
4661+
param (
4662+
[Parameter(Mandatory=$true)]
4663+
[ValidateSet("Diagnostics","DiagnosticsRepair")]
4664+
[string]
4665+
$AccessLevel,
4666+
4667+
[Parameter(Mandatory=$false)]
4668+
[int]
4669+
$ExpireInMinutes = 480,
4670+
4671+
[Parameter(Mandatory=$false)]
4672+
[string]
4673+
$SasCredential,
4674+
4675+
[Parameter(Mandatory=$false)]
4676+
[switch]
4677+
$AgreeToRemoteSupportConsent
4678+
)
4679+
4680+
Install-DeployModule -ModuleName "Microsoft.AzureStack.Deployment.RemoteSupport"
4681+
4682+
Microsoft.AzureStack.Deployment.RemoteSupport\Enable-RemoteSupport -AccessLevel $AccessLevel -ExpireInMinutes $ExpireInMinutes -SasCredential $SasCredential -AgreeToRemoteSupportConsent:$AgreeToRemoteSupportConsent
4683+
}
4684+
4685+
<#
4686+
.SYNOPSIS
4687+
Disables Remote Support.
4688+
4689+
.DESCRIPTION
4690+
Disable Remote Support revokes all access levels previously granted. Any existing support sessions will be terminated, and new sessions can no longer be established.
4691+
4692+
.EXAMPLE
4693+
The example below disables remote support.
4694+
PS C:\> Disable-AzStackHCIRemoteSupport
4695+
4696+
.NOTES
4697+
4698+
#>
4699+
function Disable-AzStackHCIRemoteSupport{
4700+
[CmdletBinding(SupportsShouldProcess)]
4701+
[OutputType([Boolean])]
4702+
param()
4703+
Install-DeployModule -ModuleName "Microsoft.AzureStack.Deployment.RemoteSupport"
4704+
4705+
Microsoft.AzureStack.Deployment.RemoteSupport\Disable-RemoteSupport
4706+
}
4707+
4708+
<#
4709+
.SYNOPSIS
4710+
Gets Remote Support Access.
4711+
4712+
.DESCRIPTION
4713+
Gets remote support access.
4714+
4715+
.PARAMETER IncludeExpired
4716+
Optional. Defaults to false. Indicates whether to include past expired entries.
4717+
4718+
.PARAMETER Cluster
4719+
Optional. Defaults to false. Indicates whether to show remote support sessions across cluster.
4720+
4721+
.EXAMPLE
4722+
The example below retrieves access level granted for remote support. The result will also include expired consents in the last 30 days.
4723+
PS C:\> Get-AzStackHCIRemoteSupportAccess -IncludeExpired -Cluster
4724+
4725+
.NOTES
4726+
4727+
#>
4728+
function Get-AzStackHCIRemoteSupportAccess{
4729+
[OutputType([Boolean])]
4730+
Param(
4731+
[Parameter(Mandatory=$false)]
4732+
[switch]
4733+
$Cluster,
4734+
4735+
[Parameter(Mandatory=$false)]
4736+
[switch]
4737+
$IncludeExpired
4738+
)
4739+
4740+
Install-DeployModule -ModuleName "Microsoft.AzureStack.Deployment.RemoteSupport"
4741+
4742+
Microsoft.AzureStack.Deployment.RemoteSupport\Get-RemoteSupportAccess -Cluster:$Cluster -IncludeExpired:$IncludeExpired
4743+
}
4744+
4745+
<#
4746+
.SYNOPSIS
4747+
Gets Remote Support Session History Details.
4748+
4749+
.DESCRIPTION
4750+
Session history represents all remote accesses made by Microsoft Support for either Diagnostics or DiagnosticsRepair based on the Access Level granted.
4751+
4752+
.PARAMETER SessionId
4753+
Optional. Session Id to get details for a specific session. If omitted then lists all sessions starting from date 'FromDate'.
4754+
4755+
.PARAMETER IncludeSessionTranscript
4756+
Optional. Defaults to false. Indicates whether to include complete session transcript. Transcript provides details on all operations performed during the session.
4757+
4758+
.PARAMETER FromDate
4759+
Optional. Defaults to last 7 days. Indicates date from where to start listing sessions from until now.
4760+
4761+
.EXAMPLE
4762+
The example below retrieves session history with transcript details for the specified session.
4763+
PS C:\> Get-AzStackHCIRemoteSupportSessionHistory -SessionId 467e3234-13f4-42f2-9422-81db248930fa -IncludeSessionTranscript $true
4764+
4765+
.EXAMPLE
4766+
The example below lists session history starting from last 7 days (default) to now.
4767+
PS C:\> Get-AzStackHCIRemoteSupportSessionHistory
4768+
4769+
.NOTES
4770+
4771+
#>
4772+
function Get-AzStackHCIRemoteSupportSessionHistory{
4773+
[OutputType([Boolean])]
4774+
Param(
4775+
[Parameter(Mandatory=$false)]
4776+
[string]
4777+
$SessionId,
4778+
4779+
[Parameter(Mandatory=$false)]
4780+
[switch]
4781+
$IncludeSessionTranscript,
4782+
4783+
[Parameter(Mandatory=$false)]
4784+
[DateTime]
4785+
$FromDate = (Get-Date).AddDays(-7)
4786+
)
4787+
4788+
Install-DeployModule -ModuleName "Microsoft.AzureStack.Deployment.RemoteSupport"
4789+
4790+
Microsoft.AzureStack.Deployment.RemoteSupport\Get-RemoteSupportSessionHistory -SessionId $SessionId -FromDate $FromDate -IncludeSessionTranscript:$IncludeSessionTranscript
4791+
}
4792+
44994793
Export-ModuleMember -Function Register-AzStackHCI
45004794
Export-ModuleMember -Function Unregister-AzStackHCI
45014795
Export-ModuleMember -Function Test-AzStackHCIConnection
@@ -4504,4 +4798,10 @@ Export-ModuleMember -Function Enable-AzStackHCIAttestation
45044798
Export-ModuleMember -Function Disable-AzStackHCIAttestation
45054799
Export-ModuleMember -Function Add-AzStackHCIVMAttestation
45064800
Export-ModuleMember -Function Remove-AzStackHCIVMAttestation
4507-
Export-ModuleMember -Function Get-AzStackHCIVMAttestation
4801+
Export-ModuleMember -Function Get-AzStackHCIVMAttestation
4802+
Export-ModuleMember -Function Install-AzStackHCIRemoteSupport
4803+
Export-ModuleMember -Function Remove-AzStackHCIRemoteSupport
4804+
Export-ModuleMember -Function Enable-AzStackHCIRemoteSupport
4805+
Export-ModuleMember -Function Disable-AzStackHCIRemoteSupport
4806+
Export-ModuleMember -Function Get-AzStackHCIRemoteSupportAccess
4807+
Export-ModuleMember -Function Get-AzStackHCIRemoteSupportSessionHistory

src/StackHCI/ChangeLog.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21-
21+
* Adding support cmdlet for Remote Support
22+
- New cmdlets - Install-AzStackHCIRemoteSupport, Remove-AzStackHCIRemoteSupport, Enable-AzStackHCIRemoteSupport, Disable-AzStackHCIRemoteSupport, Get-AzStackHCIRemoteSupportAccess,Get-AzStackHCIRemoteSupportSessionHistory
23+
2224
## Version 1.0.0
2325
* Promoted Az.StackHCI to GA
2426

src/StackHCI/help/Az.StackHCI.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,33 @@ Add-AzStackHCIVMAttestation configures guests for AzureStack HCI IMDS Attestatio
1717
### [Disable-AzStackHCIAttestation](Disable-AzStackHCIAttestation.md)
1818
Disable-AzStackHCIAttestation disables IMDS Attestation on the host
1919

20+
### [Disable-AzStackHCIRemoteSupport](Disable-AzStackHCIRemoteSupport.md)
21+
Disables Remote Support.
22+
2023
### [Enable-AzStackHCIAttestation](Enable-AzStackHCIAttestation.md)
2124
Enable-AzStackHCIAttestation configures the host and enables specified guests for IMDS attestation.
2225

26+
### [Enable-AzStackHCIRemoteSupport](Enable-AzStackHCIRemoteSupport.md)
27+
Enables Remote Support.
28+
29+
### [Get-AzStackHCIRemoteSupportAccess](Get-AzStackHCIRemoteSupportAccess.md)
30+
Gets Remote Support Access.
31+
32+
### [Get-AzStackHCIRemoteSupportSessionHistory](Get-AzStackHCIRemoteSupportSessionHistory.md)
33+
Gets Remote Support Session History Details.
34+
2335
### [Get-AzStackHCIVMAttestation](Get-AzStackHCIVMAttestation.md)
2436
Get-AzStackHCIVMAttestation shows a list of guests added to IMDS Attestation on a node.
2537

38+
### [Install-AzStackHCIRemoteSupport](Install-AzStackHCIRemoteSupport.md)
39+
Installs Remote Support.
40+
2641
### [Register-AzStackHCI](Register-AzStackHCI.md)
2742
Register-AzStackHCI creates a Microsoft.AzureStackHCI cloud resource representing the on-premise cluster and registers the on-premise cluster with Azure.
2843

44+
### [Remove-AzStackHCIRemoteSupport](Remove-AzStackHCIRemoteSupport.md)
45+
Removes Remote Support.
46+
2947
### [Remove-AzStackHCIVMAttestation](Remove-AzStackHCIVMAttestation.md)
3048
Remove-AzStackHCIVMAttestation removes guests from AzureStack HCI IMDS Attestation.
3149

0 commit comments

Comments
 (0)