@@ -4887,10 +4887,10 @@ function Install-DeployModule {
4887
4887
)
4888
4888
4889
4889
if (Get-Module | Where-Object { $_.Name -eq $ModuleName }){
4890
- Write-Host " $ModuleName is loaded already ..."
4890
+ Write-InfoLog ( " $ModuleName is loaded already ..." )
4891
4891
}
4892
4892
else {
4893
- Write-Host " $ModuleName is not loaded, downloading ..."
4893
+ Write-InfoLog ( " $ModuleName is not loaded, downloading ..." )
4894
4894
4895
4895
# Download Remote Support Deployment module from storage
4896
4896
Invoke-DeploymentModuleDownload
@@ -4917,8 +4917,14 @@ function Install-AzStackHCIRemoteSupport{
4917
4917
[CmdletBinding (SupportsShouldProcess )]
4918
4918
[OutputType ([Boolean ])]
4919
4919
param ()
4920
- Install-DeployModule - ModuleName " Microsoft.AzureStack.Deployment.RemoteSupport"
4921
- Microsoft.AzureStack.Deployment.RemoteSupport\Install-RemoteSupport
4920
+
4921
+ if (Assert-IsObservabilityStackPresent ){
4922
+ Write-InfoLog (" Install-AzStackHCIRemoteSupport is not available." )
4923
+ }
4924
+ else {
4925
+ Install-DeployModule - ModuleName " Microsoft.AzureStack.Deployment.RemoteSupport"
4926
+ Microsoft.AzureStack.Deployment.RemoteSupport\Install-RemoteSupport
4927
+ }
4922
4928
}
4923
4929
4924
4930
<#
@@ -4937,8 +4943,14 @@ function Remove-AzStackHCIRemoteSupport{
4937
4943
[CmdletBinding (SupportsShouldProcess )]
4938
4944
[OutputType ([Boolean ])]
4939
4945
param ()
4940
- Install-DeployModule - ModuleName " Microsoft.AzureStack.Deployment.RemoteSupport"
4941
- Microsoft.AzureStack.Deployment.RemoteSupport\Remove-RemoteSupport
4946
+
4947
+ if (Assert-IsObservabilityStackPresent ){
4948
+ Write-InfoLog (" Remove-AzStackHCIRemoteSupport is not available." )
4949
+ }
4950
+ else {
4951
+ Install-DeployModule - ModuleName " Microsoft.AzureStack.Deployment.RemoteSupport"
4952
+ Microsoft.AzureStack.Deployment.RemoteSupport\Remove-RemoteSupport
4953
+ }
4942
4954
}
4943
4955
4944
4956
<#
@@ -4989,9 +5001,14 @@ function Enable-AzStackHCIRemoteSupport{
4989
5001
$AgreeToRemoteSupportConsent
4990
5002
)
4991
5003
4992
- Install-DeployModule - ModuleName " Microsoft.AzureStack.Deployment.RemoteSupport"
4993
-
4994
- Microsoft.AzureStack.Deployment.RemoteSupport\Enable-RemoteSupport - AccessLevel $AccessLevel - ExpireInMinutes $ExpireInMinutes - SasCredential $SasCredential - AgreeToRemoteSupportConsent:$AgreeToRemoteSupportConsent
5004
+ if (Assert-IsObservabilityStackPresent ){
5005
+ Import-Module DiagnosticsInitializer - Verbose - Force
5006
+ Enable-RemoteSupport - AccessLevel $AccessLevel - ExpireInMinutes $ExpireInMinutes - SasCredential $SasCredential - AgreeToRemoteSupportConsent:$AgreeToRemoteSupportConsent
5007
+ }
5008
+ else {
5009
+ Install-DeployModule - ModuleName " Microsoft.AzureStack.Deployment.RemoteSupport"
5010
+ Microsoft.AzureStack.Deployment.RemoteSupport\Enable-RemoteSupport - AccessLevel $AccessLevel - ExpireInMinutes $ExpireInMinutes - SasCredential $SasCredential - AgreeToRemoteSupportConsent:$AgreeToRemoteSupportConsent
5011
+ }
4995
5012
}
4996
5013
4997
5014
<#
@@ -5012,9 +5029,15 @@ function Disable-AzStackHCIRemoteSupport{
5012
5029
[CmdletBinding (SupportsShouldProcess )]
5013
5030
[OutputType ([Boolean ])]
5014
5031
param ()
5015
- Install-DeployModule - ModuleName " Microsoft.AzureStack.Deployment.RemoteSupport"
5016
5032
5017
- Microsoft.AzureStack.Deployment.RemoteSupport\Disable-RemoteSupport
5033
+ if (Assert-IsObservabilityStackPresent ){
5034
+ Import-Module DiagnosticsInitializer - Verbose - Force
5035
+ Disable-RemoteSupport
5036
+ }
5037
+ else {
5038
+ Install-DeployModule - ModuleName " Microsoft.AzureStack.Deployment.RemoteSupport"
5039
+ Microsoft.AzureStack.Deployment.RemoteSupport\Disable-RemoteSupport
5040
+ }
5018
5041
}
5019
5042
5020
5043
<#
@@ -5049,9 +5072,47 @@ function Get-AzStackHCIRemoteSupportAccess{
5049
5072
$IncludeExpired
5050
5073
)
5051
5074
5052
- Install-DeployModule - ModuleName " Microsoft.AzureStack.Deployment.RemoteSupport"
5075
+ if (Assert-IsObservabilityStackPresent ){
5076
+ Import-Module DiagnosticsInitializer - Verbose - Force
5077
+ Get-RemoteSupportAccess - IncludeExpired:$IncludeExpired
5078
+ }
5079
+ else {
5080
+ Install-DeployModule - ModuleName " Microsoft.AzureStack.Deployment.RemoteSupport"
5081
+ Microsoft.AzureStack.Deployment.RemoteSupport\Get-RemoteSupportAccess - Cluster:$Cluster - IncludeExpired:$IncludeExpired
5082
+ }
5083
+ }
5084
+
5085
+ <#
5086
+ . SYNOPSIS
5087
+ Gets if Observability Remote Support Service exists.
5088
+ . DESCRIPTION
5089
+ Gets if Observability Remote Support Service exists to determine module to import.
5090
+ .PARAMETER
5091
+ . EXAMPLE
5092
+ The example below returns whether environment is HCI or not.
5093
+ PS C:\> Assert-IsObservabilityStackPresent
5094
+ . NOTES
5095
+ #>
5096
+ function Assert-IsObservabilityStackPresent {
5097
+ [OutputType ([Boolean ])]
5098
+ param ()
5053
5099
5054
- Microsoft.AzureStack.Deployment.RemoteSupport\Get-RemoteSupportAccess - Cluster:$Cluster - IncludeExpired:$IncludeExpired
5100
+ try {
5101
+ $obsService = Get-Service - Name " *Observability RemoteSupportAgent*" - ErrorAction SilentlyContinue
5102
+ $deviceType = (Get-ItemProperty - Path " HKLM:\SOFTWARE\Microsoft\AzureStack" - ErrorAction SilentlyContinue).DeviceType
5103
+ if ($obsService -or $deviceType -eq " AzureEdge" ){
5104
+ Write-InfoLog (" AzureStack device type is AzureEdge." )
5105
+ return $true
5106
+ }
5107
+ else {
5108
+ Write-InfoLog (" AzureStack device type is not AzureEdge." )
5109
+ return $false
5110
+ }
5111
+ }
5112
+ catch {
5113
+ Write-Error " Failed while getting Observability Remote Support service."
5114
+ return $false
5115
+ }
5055
5116
}
5056
5117
5057
5118
<#
@@ -5079,7 +5140,6 @@ function Get-AzStackHCIRemoteSupportAccess{
5079
5140
PS C:\> Get-AzStackHCIRemoteSupportSessionHistory
5080
5141
5081
5142
. NOTES
5082
-
5083
5143
#>
5084
5144
function Get-AzStackHCIRemoteSupportSessionHistory {
5085
5145
[OutputType ([Boolean ])]
@@ -5097,9 +5157,14 @@ function Get-AzStackHCIRemoteSupportSessionHistory{
5097
5157
$FromDate = (Get-Date ).AddDays(-7 )
5098
5158
)
5099
5159
5100
- Install-DeployModule - ModuleName " Microsoft.AzureStack.Deployment.RemoteSupport"
5101
-
5102
- Microsoft.AzureStack.Deployment.RemoteSupport\Get-RemoteSupportSessionHistory - SessionId $SessionId - FromDate $FromDate - IncludeSessionTranscript:$IncludeSessionTranscript
5160
+ if (Assert-IsObservabilityStackPresent ){
5161
+ Import-Module DiagnosticsInitializer - Verbose - Force
5162
+ Get-RemoteSupportSessionHistory - SessionId $SessionId - FromDate $FromDate - IncludeSessionTranscript:$IncludeSessionTranscript
5163
+ }
5164
+ else {
5165
+ Install-DeployModule - ModuleName " Microsoft.AzureStack.Deployment.RemoteSupport"
5166
+ Microsoft.AzureStack.Deployment.RemoteSupport\Get-RemoteSupportSessionHistory - SessionId $SessionId - FromDate $FromDate - IncludeSessionTranscript:$IncludeSessionTranscript
5167
+ }
5103
5168
}
5104
5169
5105
5170
# Export-ModuleMember -Function Register-AzStackHCI
0 commit comments