Framework/Core/MetadataInfo/BasicInfo.ps1
using namespace System.Management.Automation Set-StrictMode -Version Latest class BasicInfo: CommandBase { hidden [PSObject] $AzSDKRG = $null BasicInfo([string] $subscriptionId, [InvocationInfo] $invocationContext): Base($subscriptionId, $invocationContext) { $azsdkRGName = [ConfigurationManager]::GetAzSdkConfigData().AzSDKRGName; $this.AzSDKRG = Get-AzureRmResourceGroup -Name $azsdkRGName -ErrorAction SilentlyContinue } GetBasicInfo() { $this.PublishCustomMessage([Constants]::DoubleDashLine + "`r`n" + $this.InvocationContext.MyCommand.ModuleName +" component versions `r`n" + [Constants]::DoubleDashLine); $this.GetAzSDKAlertVersion() $this.GetAzSDKARMPolicyVersion() $this.GetAzSDKRBACVersion() $this.GetAzSDKSecurityCenterVersion() } GetAzSDKAlertVersion() { $AlertPolicyObj = $this.LoadServerConfigFile("Subscription.InsARMAlerts.json"); $this.PublishCustomMessage("Alert version in " + $this.InvocationContext.MyCommand.ModuleName +": " + $AlertPolicyObj.Version, [MessageType]::Info); if($null -ne $this.AzSDKRG -and $this.AzSDKRG.Tags.Count -gt 0 -and $this.AzSDKRG.Tags.Contains([Constants]::AzSDKAlertsVersionTagName)) { $this.PublishCustomMessage("Alert version configured in subscription " + $this.SubscriptionContext.SubscriptionId +" is: " + $this.AzSDKRG.Tags[[Constants]::AzSDKAlertsVersionTagName], [MessageType]::Info); } else { $this.PublishCustomMessage("Alerts are not configured in subscription: " + $this.SubscriptionContext.SubscriptionId, [MessageType]::Info); } $this.PublishCustomMessage([Constants]::SingleDashLine, [MessageType]::Info); } GetAzSDKARMPolicyVersion() { $ARMPolicyObj = [PSObject] $this.LoadServerConfigFile("Subscription.ARMPolicies.json"); $this.PublishCustomMessage("ARM policy version in " + $this.InvocationContext.MyCommand.ModuleName +": " + $ARMPolicyObj.Version); if($null -ne $this.AzSDKRG -and $this.AzSDKRG.Tags.Count -gt 0 -and $this.AzSDKRG.Tags.Contains([Constants]::ARMPolicyConfigVersionTagName)) { $this.PublishCustomMessage("ARM policy version configured in subscription " + $this.SubscriptionContext.SubscriptionId +" is: " + $this.AzSDKRG.Tags[[Constants]::ARMPolicyConfigVersionTagName], [MessageType]::Info); } else { $this.PublishCustomMessage("ARM policies are not configured in subscription: " + $this.SubscriptionContext.SubscriptionId, [MessageType]::Info); } $this.PublishCustomMessage([Constants]::SingleDashLine, [MessageType]::Info); } GetAzSDKRBACVersion() { $rbacPolicy = [PSObject] $this.LoadServerConfigFile("Subscription.RBAC.json"); $this.PublishCustomMessage("Central accounts RBAC version in " + $this.InvocationContext.MyCommand.ModuleName +": " + $rbacPolicy.ActiveCentralAccountsVersion); if($null -ne $this.AzSDKRG -and $this.AzSDKRG.Tags.Count -gt 0 -and $this.AzSDKRG.Tags.Contains([Constants]::CentralRBACVersionTagName)) { $this.PublishCustomMessage("Central accounts RBAC version configured in subscription " + $this.SubscriptionContext.SubscriptionId +" is: " + $this.AzSDKRG.Tags[[Constants]::CentralRBACVersionTagName], [MessageType]::Info); } else { $this.PublishCustomMessage("Central accounts RBAC is not configured in subscription: " + $this.SubscriptionContext.SubscriptionId, [MessageType]::Info); } $this.PublishCustomMessage("Deprecated accounts RBAC version in " + $this.InvocationContext.MyCommand.ModuleName +": " + $rbacPolicy.DeprecatedAccountsVersion); if($null -ne $this.AzSDKRG -and $this.AzSDKRG.Tags.Count -gt 0 -and $this.AzSDKRG.Tags.Contains([Constants]::DeprecatedRBACVersionTagName)) { $this.PublishCustomMessage("Deprecated accounts RBAC version configured in subscription " + $this.SubscriptionContext.SubscriptionId +" is: " + $this.AzSDKRG.Tags[[Constants]::DeprecatedRBACVersionTagName], [MessageType]::Info); } else { $this.PublishCustomMessage("Deprecated accounts RBAC is not configured in subscription: " + $this.SubscriptionContext.SubscriptionId, [MessageType]::Info); } $this.PublishCustomMessage([Constants]::SingleDashLine, [MessageType]::Info); } GetAzSDKSecurityCenterVersion() { $secCentObj = $this.LoadServerConfigFile("SecurityCenter.json"); $this.PublishCustomMessage("Security Center configuration version in " + $this.InvocationContext.MyCommand.ModuleName +": " + $secCentObj.Version, [MessageType]::Info); if($null -ne $this.AzSDKRG -and $this.AzSDKRG.Tags.Count -gt 0 -and $this.AzSDKRG.Tags.Contains([Constants]::SecurityCenterConfigVersionTagName)) { $this.PublishCustomMessage("Security Center configuration version in subscription " + $this.SubscriptionContext.SubscriptionId +" is: " + $this.AzSDKRG.Tags[[Constants]::SecurityCenterConfigVersionTagName], [MessageType]::Info); } else { $this.PublishCustomMessage("Security Center is not configured in subscription: " + $this.SubscriptionContext.SubscriptionId, [MessageType]::Info); } } } |