Framework/Models/SVT/PSCloudService.ps1
# # CloudService.ps1 # Set-StrictMode -Version Latest class PSCloudService { [PSObject] $Name [PSObject] $Configuration [PSObject] $DeploymentSlot [RoleInstance[]] $RoleInstances [Role[]] $Roles [PSObject] $VirtualIps [PSObject] $UpgradeType [PSObject] $UpgradeDomainCount [Extension[]] $Extensions hidden [void] LoadCloudConfiguration([xml] $CloudServiceResponse) { #$controlResult.AddMessage([MessageData]::new("Compliance details of Azure Active Directory applications:", # $outputList)); # Get the results from the API as XML #Write-Host ServiceName: -ForegroundColor DarkYellow if($null -ne $CloudServiceResponse.hostedservice) { $this.Name = $CloudServiceResponse.hostedservice.ServiceName if($null -ne $CloudServiceResponse.hostedservice.Deployments){ foreach($svc in $CloudServiceResponse.hostedservice.Deployments.Deployment) { $this.Configuration = [xml]([System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($svc.Configuration))) $this.DeploymentSlot = $svc.DeploymentSlot $this.RoleInstances = @() if($null -ne $svc.RoleInstanceList) { foreach($instance in $svc.RoleInstanceList.RoleInstance) { [RoleInstance] $roleInstance = [RoleInstance]::new() $roleInstance.RoleName = $instance.RoleName $roleInstance.InstanceName = $instance.RoleName $roleInstance.PowerState = $instance.PowerState $roleInstance.IPAddress = $instance.IpAddress if($null -ne $instance.InstanceEndpoints -and $null -ne $instance.InstanceEndpoints.InstanceEndpoint) { $roleInstance.InstanceEndpoints = [array]($instance.InstanceEndpoints.InstanceEndpoint | Select-Object Name, Vip, PublicPort, LocalPort, Protocol) } $this.RoleInstances += $roleInstance $this.Roles = @() if($null -ne $svc.RoleList) { foreach($instance in $svc.RoleList.Role) { [Role] $role = [Role]::new() $role.RoleName = $instance.RoleName $role.OSVersion = $instance.OsVersion if($null -ne $instance.ConfigurationSets.ConfigurationSet.InputEndpoints) { $role.InputEndpoint = [array]($instance.ConfigurationSets.ConfigurationSet.InputEndpoints.InputEndpoint | Select-Object Port, Protocol, Vip) } $this.Roles += $role } } $this.VirtualIps = [array]($svc.VirtualIPs.VirtualIP | Select-Object Address, IsDnsProgrammed) #if( $svc.UpgradeStatus -eq $null) # { # $this.UpgradeType = "Manual" # } # else # { # $this.UpgradeType = $svc.UpgradeStatus.UpgradeType # } $this.UpgradeDomainCount = $svc.UpgradeDomainCount # Write-Host `nRole Extensions: -ForegroundColor DarkYellow # Write-Host ------------------ $this.Extensions = @() if($null -ne $svc.ExtensionConfiguration -and $null -ne $svc.ExtensionConfiguration.NamedRoles) { foreach($instance in $svc.ExtensionConfiguration.NamedRoles.Role) { [Extension] $extension = [Extension]::new() $extension.RoleName = $instance.RoleName if($null -ne $instance.Extensions.Extension) { $extension.ExtensionId = ($instance.Extensions.Extension | Select-Object Id ) } $this.Extensions += $extension } } } } } } } } } class RoleInstance { [PSObject] $RoleName [PSObject] $InstanceName [PSObject] $PowerState [PSObject] $IPAddress [PSObject] $InstanceEndpoints } class Role { [PSObject] $RoleName [PSObject] $OSVersion [PSObject] $InputEndpoint } class Extension { [PSObject] $RoleName [PSObject] $ExtensionId } |