########### BEGIN SCRIPT HEADER ########### # SUPPLEMENTAL BES DATA # Author: Lonny Motto # Version: See Instantiation below # Date: 3/17/2023 ############ END SCRIPT HEADER ############ <# .SYNOPSIS Creates a number of files containing information about the server. .DESCRIPTION Retrieves local server information and writes this data to a number of local files. If the local file already exists, it deletes it first. These data files are then utilized by a BigFix Web Report. Requires Powershell 2.0. .EXAMPLE C:\WindowsSupplementalDiscovery.ps1 .OUTPUTS Returns zero if the script completes with no issues. #> # ------------------------------------------------------------------------------------------------------------ # # --- INSTANTIATION # ------------------------------------------------------------------------------------------------------------ # $DiscoveryVersion = "2.0.1" # For all updates, see NOTES above $DiscoveryDirectory = "C:\Windows\temp\" $DiscoveryPrefix = "RackspaceTransitionDiscovery" $StrDiv = "," # Use comma, semi-colon, etc. $Global:WriteStatusLogFile = "C:\Windows\temp\WindowsSupplementalDiscovery.log" # ------------------------------------------------------------------------------------------------------------ # # --- FUNCTIONS # ------------------------------------------------------------------------------------------------------------ # Function WriteStatus( [Parameter(Position = 1, Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)] [ValidateSet('SUCCESS', 'INFO', 'WARNING', 'ERROR', 'START', 'STOP', 'FINISH', 'SECTION', 'VERBOSE')][string]$Type, [Parameter(Position = 2, Mandatory = $True, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)] [string]$Message, [Parameter(Position = 3, Mandatory = $False, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)] [string]$LogFile = $Global:WriteStatusLogFile ) { <# .SYNOPSIS Writes Message to the screen and to a log file. .DESCRIPTION The Type and Message are formatted with all caps and justified, making them easier to read both on-screen and in a log file. Types are color-coded on-screen. .PARAMETER Type Required. 'SUCCESS','INFO','WARNING','ERROR','START','STOP','FINISH','SECTION','VERBOSE' .PARAMETER Message Required. String. Message to be displayed to the screen and to be written to LogFile. .PARAMETER LogFile Optional. String. Path of the log file. Default value is $Global:WriteStatusLogFile, which if not set, sets LogFile to C:\Windows\Temp\WriteStatusLogFile.log. .EXAMPLE WriteStatus ERROR "Something went wrong." .OUTPUTS None. #> $Time = (Get-Date -Format G).ToString() $Message = $Message.ToUpper() $TypePad = 16 if ($LogFile.Length -eq 0) { $LogFile = "C:\Windows\Temp\WriteStatusLogFile.log" } Switch ($Type) { 'SUCCESS' { $BGColor = 'Green'; $FGColor = 'Black'; $BGType = ''; $FGType = '' } 'INFO' { $BGColor = 'DarkCyan'; $FGColor = 'White'; $BGType = ''; $FGType = '' } 'WARNING' { $BGColor = 'Red'; $FGColor = 'Yellow'; $BGType = ''; $FGType = '' } 'ERROR' { $BGColor = 'Black'; $FGColor = 'Yellow'; $BGType = ''; $FGType = '' } 'START' { $BGColor = 'DarkCyan'; $FGColor = 'White'; $BGType = 'Gray'; $FGType = 'Black' } 'STOP' { $BGColor = 'DarkRed'; $FGColor = 'White'; $BGType = 'White'; $FGType = 'Black' } 'FINISH' { $BGColor = 'DarkCyan'; $FGColor = 'White'; $BGType = 'White'; $FGType = 'Black' } 'SECTION' { $BGColor = 'Black'; $FGColor = 'White'; $BGType = 'Black'; $FGType = 'White' } 'VERBOSE' { $BGColor = 'DarkCyan'; $FGColor = 'Gray'; $BGType = ''; $FGType = '' } } # Write to log Add-Content $LogFile ($Time.PadRight(24, " ") + ("[" + $Type + "]").PadRight($TypePad, " ") + "TransitionServer".PadRight(24, " ") + $Message) # Write to screen if (($BGType) -and ($FGType)) { Write-Host -BackgroundColor $BGType -ForegroundColor $FGType (" [" + $Type + "]").PadRight($TypePad, " ") -NoNewline } else { Write-Host (" [" + $Type + "]").PadRight($TypePad, " ") -NoNewline } Write-Host -BackgroundColor $BGColor -ForegroundColor $FGColor (" " + $Message) } Function PrepDiscoveryFilePath( [Parameter(Position = 1, Mandatory = $True)][string]$DataType ) { <# .SYNOPSIS Returns file path for data outputs based on DataType. Deletes file if it exists. #> $FilePath = ($DiscoveryDirectory + $DiscoveryPrefix + "-" + $DataType + ".txt") if (Test-Path $FilePath) { Remove-Item $FilePath } return($FilePath) } Function ListServices( [Parameter(Position = 1, Mandatory = $True)][string]$ServiceName, [Parameter(Position = 2, Mandatory = $False)][string]$FilterName = "" ) { <# .SYNOPSIS Returns services matching ServiceName. Excludes services matching FilterName. #> if ($FilterName -eq "") { $Svcs = $Services | Where-Object { $_.Status -eq "Running" -and $_.DisplayName -like ("*" + $ServiceName + "*") } } else { $Svcs = $Services | Where-Object { $_.Status -eq "Running" -and $_.DisplayName -like ("*" + $ServiceName + "*") -and $_.DisplayName -notlike ("*" + $FilterName + "*") } } $SvcNames = @() foreach ($Svc in $Svcs) { $SvcNames = $SvcNames + $Svc.DisplayName } return($SvcNames) } Function ListApplications( [Parameter(Position = 1, Mandatory = $True)][string]$AppName, [Parameter(Position = 2, Mandatory = $False)][string]$FilterName = "", [Parameter(Position = 3, Mandatory = $False)][switch]$AppendVersion ) { <# .SYNOPSIS Returns applications matching AppName. Excludes applications matching FilterName. #> if ($FilterName -eq "") { $Apps = $Applications | Where-Object { $_.Name -like ("*" + $AppName + "*") } } else { $Apps = $Applications | Where-Object { ($_.Name -like ("*" + $AppName + "*")) -and ($_.Name -notlike ("*" + $FilterName + "*")) } } $AppNames = @() foreach ($App in $Apps) { if ($AppendVersion) { if ($App.Version) { $AppNames = $AppNames + ($App.Name + " [" + $App.Version + "]") } else { $AppNames = $AppNames + $App.Name } } else { $AppNames = $AppNames + $App.Name } } return($AppNames) } Function GetUpdateHistory { <# .SYNOPSIS Returns installation date, ID and Description for both HotFix updates and client install updates. .DESCRIPTION Runs two parts: Update History and Client Update History #> # Part 1: Update History $UpdateHistory = $null # Skip if OS less than or equal to 2008 if ([Environment]::OSVersion.Version -le "6.0") { try { # Method #1: PS $UpdateHistory = Get-HotFix -ErrorAction stop $UpdateHistory = $UpdateHistory | Select-Object -Property InstalledOn, HotFixID, Description # Method #2: WMI if ($UpdateHistory -eq $null) { $UpdateHistory = Get-WmiObject -Class Win32_QuickFixEngineering $UpdateHistory = $UpdateHistory | Select-Object -Property InstalledOn, HotFixID, Description } } catch { WriteStatus WARNING "Unable to get Windows Update history." } } # Part 2: Microsoft Update Client Install History # See for more info: https://social.technet.microsoft.com/wiki/contents/articles/4197.windows-how-to-list-all-of-the-windows-and-software-updates-applied-to-a-computer.aspx # This is necessary for updates like CredSSP and for OS less than 2008 R2 $UpdateClientInstallHistory = $null try { $Session = New-Object -ComObject "Microsoft.Update.Session" $Searcher = $Session.CreateUpdateSearcher() $HistoryCount = $Searcher.GetTotalHistoryCount() if ($HistoryCount) { $UpdateClientInstallHistory = $Searcher.QueryHistory(0, $HistoryCount) | Select-Object -Property @{n = 'InstalledOn'; e = { $_.Date } }, @{n = 'HotFixID'; e = { $_.Title } }, Description | Where-Object { $_.HotFixID -notlike "*Update for Microsoft Defender*" } } } catch { WriteStatus ERROR "Unable to get Windows Client Install Update history." } return ($UpdateHistory + $UpdateClientInstallHistory) } Function GetNicInfo { <# .SYNOPSIS Returns an array of NIC info if there are no errors or else returns $null. #> Function InlineIfElse( [Parameter(Position = 1, Mandatory = $True)][string]$Condition, [Parameter(Position = 2, Mandatory = $True)][string]$IfTrue, [Parameter(Position = 3, Mandatory = $True)][string]$IfFalse ) { <# .SYNOPSIS Inline IfElse, returns $IsTrue value if $Condition is true, else returns $IsFalse value. #> if ($Condition) { $IfTrue } else { return $IfFalse } } $NICs = @() try { $NetConfigs = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled=True" | Where-Object { ($NetConfig.Description -ne "RAS Async Adapter") -and ($NetConfig.IP -notlike "169.*") } foreach ($NetConfig in $NetConfigs) { $Name = (Get-WmiObject -Class Win32_NetworkAdapter -Filter ("DeviceId = " + $NetConfig.index) | Select-Object -ExpandProperty NetConnectionID) $IP = InlineIfElse ($NetConfig.IPAddress.Length) -IfTrue $NetConfig.IPAddress[0] -IfFalse "NA" $Subnet = InlineIfElse ($NetConfig.IPSubnet.Length) -IfTrue $NetConfig.IPSubnet[0] -IfFalse "NA" $Gateway = InlineIfElse ($NetConfig.DefaultIPGateway.Length) -IfTrue $NetConfig.DefaultIPGateway[0] -IfFalse "NA" # Possible future support: #$DNSServers = InlineIfElse ($NetConfig.DNSServerSearchOrder) -IfTrue (($NetConfig.DNSServerSearchOrder) -join ', ') -IfFalse "NA" #$DNSSuffix = InlineIfElse ($NetConfig.DNSDomainSuffixSearchOrder) -IfTrue (($NetConfig.DNSDomainSuffixSearchOrder) -join ', ') -IfFalse "NA" #$MacAddress = $NetConfig.MacAddress #$RegisterInDNS = $NetConfig.FullDNSRegistrationEnabled $Speed = ("{ 0:N2 }" -f ((Get-WmiObject -Class Win32_NetworkAdapter -Filter ("DeviceId = " + $NetConfig.index) | Select-Object -ExpandProperty Speed) / 1000000000)) $NICDetails = New-Object PSObject $NICDetails | Add-Member NoteProperty "Name" $Name $NICDetails | Add-Member NoteProperty "IP" $IP $NICDetails | Add-Member NoteProperty "Subnet" $Subnet $NICDetails | Add-Member NoteProperty "Gateway" $Gateway # Possible future support: #$NICDetails | Add-Member NoteProperty "DNSServers" $DNSServers #$NICDetails | Add-Member NoteProperty "DNSSuffix" $DNSSuffix #$NICDetails | Add-Member NoteProperty "MacAddress" $MacAddress #$NICDetails | Add-Member NoteProperty "RegisterInDNS" $RegisterInDNS $NICDetails | Add-Member NoteProperty "Speed" $Speed $NICs += $NICDetails } return $NICs } catch { WriteStatus ERROR "Unable to get Network Adapter Configuration." return $null } } # ------------------------------------------------------------------------------------------------------------ # # --- BEGIN SCRIPT # ------------------------------------------------------------------------------------------------------------ # WriteStatus START "Starting Rackspace Transition Supplemental Discovery." WriteStatus INFO ("All discovery files will be written to '" + $DiscoveryDirectory + "'.") # ------------------------------------------------------------------------------------------------------------ # # --- DISCOVERY VERSION WriteStatus INFO "Current Checkpoint 'Version'" WriteStatus INFO "Version: $DiscoveryVersion" $FilePathTemp = PrepDiscoveryFilePath "Version" Add-Content $FilePathTemp $DiscoveryVersion # ------------------------------------------------------------------------------------------------------------ # # --- OS PREREQUISITES WriteStatus INFO "Current Checkpoint 'OS Prequisites'" # --------------------------------------------------------------------------------- # # UPDATES $UpdateHistory = GetUpdateHistory # --------------------------------------------------------------------------------- # # SERVICES $Services = Get-Service # --------------------------------------------------------------------------------- # # APPLICATIONS if ([Environment]::OSVersion.Version -lt "6.0") { $AppsToExclude = ('Security Update*', 'Hotfix*', 'Update for Windows*', 'Update for Microsoft*') $Applications = Get-ChildItem 'HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall' | Get-ItemProperty -Name DisplayName -ErrorAction SilentlyContinue | Where-Object { (($_.DisplayName -match ($AppsToExclude -Join "|")) -eq $false) -and ($_.DisplayName -ne $null) } | Select-Object -Property @{n = 'Name'; e = { $_.DisplayName } } | Sort-Object -Property Name } else { $Applications = Get-WmiObject -Class Win32_Product | Select-Object -Property Name | Sort-Object -Property Name } # --------------------------------------------------------------------------------- # # FEATURES if ([Environment]::OSVersion.Version -lt "6.0") { $Features = @() $FeatureNames = net start foreach ($FeatureName in $FeatureNames) { if (($FeatureName.length -gt 3) -and ($FeatureName -ne "These Windows services are started:") -and ($FeatureName -ne "The command completed successfully.")) { $FeatureName = $FeatureName.replace(" ", "") $FeatureTemp = New-Object System.Object $FeatureTemp | Add-Member -type NoteProperty -Name Name -Value $FeatureName $Features = $Features + $FeatureTemp } } } else { $Features = Get-WmiObject -Class Win32_ServerFeature } # --------------------------------------------------------------------------------- # # NICS $NICs = GetNicInfo # ------------------------------------------------------------------------------------------------------------ # # NICS [Name,IP,SM,GW,Speed(Gbps)] WriteStatus INFO "Current Checkpoint 'NICs'" $FilePathTemp = PrepDiscoveryFilePath "NICs" try { foreach ($NIC in $NICs) { Add-Content $FilePathTemp ($NIC.Name + $StrDiv + $NIC.IP + $StrDiv + $NIC.Subnet + $StrDiv + $NIC.Gateway + $StrDiv + $NIC.Speed) } } catch { Add-Content $FilePathTemp "NA/ERROR" } # ------------------------------------------------------------------------------------------------------------ # # --- NIC TEAMS WriteStatus INFO "Current Checkpoint 'NICTeams'" $FilePathTemp = PrepDiscoveryFilePath "NICTeams" try { $NicTeams = Get-NetLbfoTeam if ($NicTeams.count -eq 0) { Add-Content $FilePathTemp "NONE DETECTED" } else { foreach ($NicTeam in $NicTeams) { Add-Content $FilePathTemp ($NicTeam.Name + ' {' + ($NicTeam.Members -join ",") + '}') } } } catch { # HP or Intel teaming Add-Content $FilePathTemp "UNABLE TO DETECT" } # ------------------------------------------------------------------------------------------------------------ # # --- ROUTES [Destination,NextHop,Interface,Metric] WriteStatus INFO "Current Checkpoint 'Routes'" $FilePathTemp = PrepDiscoveryFilePath "Routes" # Get persistent routes try { # 2012+ $Routes = Get-NetRoute -PolicyStore PersistentStore -ErrorAction Stop if ($Routes) { foreach ($Route in $Routes) { try { $InterfaceTemp = Get-NetAdapter -InterfaceIndex $Route.ifIndex -ErrorAction Stop } catch { $InterfaceTemp.Name = $Route.ifIndex } Add-Content $FilePathTemp ($Route.DestinationPrefix + "," + $Route.NextHop + "," + $InterfaceTemp.Name + "," + $Route.RouteMetric) } } else { Add-Content $FilePathTemp "None" } } catch { # 2008 $RoutePrint = route print $i = 0 while ($i -lt $RoutePrint.Count) { if ($RoutePrint[$i] -like "Persistent Routes:*") { $x = $i + 1 # First line of persistent routes } $i = $i + 1 } if ($RoutePrint[$x] -like "*None*") { Add-Content $FilePathTemp "None" } else { while (($x -lt $RoutePrint.Count) -and ($RoutePrint[$x] -notlike "=====*")) { Add-Content $FilePathTemp $RoutePrint[$x] $x = $x + 1 } } } # ------------------------------------------------------------------------------------------------------------ # # --- DOMAIN SERVICE WriteStatus INFO "Current Checkpoint 'DomainService'" $FilePathTemp = PrepDiscoveryFilePath "DomainService" $ADDSService = $Services | Where-Object { $_.DisplayName -like "Active Directory Domain Services" } if ([string]::IsNullOrEmpty($ADDSService)) { Add-Content $FilePathTemp "" } else { # FSMO Role Holders Add-Content $FilePathTemp "FSMO Role Holders:" try { $DomainControllers = Get-ADDomainController -Filter * -ErrorAction Stop foreach ($DC in $DomainControllers) { if ($DC.OperationMasterRoles) { Add-Content $FilePathTemp ($DC.Name + " for " + $DC.Domain + ": " + ($DC.OperationMasterRoles -join ",")) } } } catch { $FSMOs = @() $ADDCs = netdom query fsmo if ($ADDCs -like "*The command failed to complete successfully.*") { Add-Content $FilePathTemp "Failed to retrieve FSMO Role holders." } else { foreach ($ADDC in $ADDCs) { if (($ADDC.length -ne 0) -and ($ADDC -ne "The command completed successfully.")) { $FSMOTemp = ($ADDC -replace ' +', '$').split('$') $RoleTemp = $FSMOTemp[0] $DCTemp = ($FSMOTemp[1]).split(".")[0] $DomainTemp = ($FSMOTemp[1] -replace ($DCTemp + ".")) $FSMO = New-Object System.Object $FSMO | Add-Member -type NoteProperty -Name Role -Value $RoleTemp $FSMO | Add-Member -type NoteProperty -Name DC -Value $DCTemp $FSMO | Add-Member -type NoteProperty -Name Domain -Value $DomainTemp $FSMOs += $FSMO } } # Get unique FSMO role holders $UniqueFSMORoleHolders = $FSMOs | Group-Object "DC", "Domain" | ForEach-Object { $_.Group | Select-Object "DC", "Domain" -First 1 } foreach ($UniqueFSMORoleHolder in $UniqueFSMORoleHolders) { $ValueTemp = "" foreach ($FSMO in $FSMOs) { if ($UniqueFSMORoleHolder.DC -eq $FSMO.DC) { if ($ValueTemp -eq "") { $ValueTemp = $FSMO.Role } else { $ValueTemp = ($ValueTemp + "," + $FSMO.Role) } } } Add-Content $FilePathTemp ($UniqueFSMORoleHolder.DC + " for " + $UniqueFSMORoleHolder.Domain + ": " + $ValueTemp) } } } Add-Content $FilePathTemp "" # AD Functional Level try { # Domain Functional Level $ADDomain = Get-ADDomain -ErrorAction Stop Add-Content $FilePathTemp ("Domain Functional Level: " + $ADDomain.DomainMode + " for " + $ADDomain.Name) Add-Content $FilePathTemp "" # Forest Functional Level $ADForest = Get-ADForest Add-Content $FilePathTemp ("Forest Functional Level: " + $ADForest.ForestMode + " for " + $ADForest.Name) Add-Content $FilePathTemp "" } catch { # Domain Functional Level $DomainNameTemp = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain().Name $DC1Temp = ($DomainNameTemp).split('.')[-1] $DC2Temp = ($DomainNameTemp).split('.')[-2] $DCQuery = ('DC=' + $DC2Temp + ',DC=' + $DC1Temp) $DomainModeNum = (dsquery * $DCQuery -scope base -attr msDS-Behavior-Version ntMixedDomain)[1] -replace '\s+', '' if ($DomainModeNum -eq "00") { $DomainMode = "Windows 2000 Native" } elseif ($DomainModeNum -eq "01") { $DomainMode = "Windows 2000 Mixed" } elseif ($DomainModeNum -eq "20") { $DomainMode = "Windows 2003" } elseif ($DomainModeNum -eq "30") { $DomainMode = "Windows 2008" } elseif ($DomainModeNum -eq "40") { $DomainMode = "Windows 2008 R2" } elseif ($DomainModeNum -eq "50") { $DomainMode = "Windows 2012" } else { $DomainMode = "ERROR" } Add-Content $FilePathTemp ("Domain Functional Level: " + $DomainMode + " for " + $DomainNameTemp) Add-Content $FilePathTemp "" # Forest Functional Level $ForestModeNum = (dsquery * ("CN=Partitions,CN=Configuration," + $DCQuery) -scope base -attr msDS-Behavior-Version)[1] -replace '\s+', '' if ($ForestModeNum -eq "0") { $ForestMode = "Windows 2000" } elseif ($ForestModeNum -eq "1") { $ForestMode = "Windows 2003 interim" } elseif ($ForestModeNum -eq "2") { $ForestMode = "Windows 2003" } elseif ($ForestModeNum -eq "3") { $ForestMode = "Windows 2008" } elseif ($ForestModeNum -eq "4") { $ForestMode = "Windows 2008 R2" } elseif ($ForestModeNum -eq "5") { $ForestMode = "Windows 2012" } elseif ($ForestModeNum -eq "6") { $ForestMode = "Windows 2012 R2" } elseif ($ForestModeNum -eq "7") { $ForestMode = "Windows 2016" } else { $ForestMode = "ERROR" } Add-Content $FilePathTemp ("Forrest Functional Level: " + $ForestMode + " for " + $DomainNameTemp) } Add-Content $FilePathTemp "" # Replication Status $ADReplFailures = (repadmin /showrepl | Select-String -Pattern "warning").count if ($ADReplFailures -eq 0) { $ADReplStatus = "OK" } elseif ($ADReplFailures -gt 0) { $ADReplStatus = "WARNING" } else { $ADReplStatus = "ERROR" } Add-Content $FilePathTemp ("AD Replication Status: " + $ADReplStatus) Add-Content $FilePathTemp "" # Replication Summary $ADReplSummaryFailures = @() $ReplSummary = repadmin /replsummary $ReplSummaryFailures = $ReplSummary | Select-String -Pattern "/" | Select-String -Pattern "fails/total" -NotMatch foreach ($ReplSummaryFailure in $ReplSummaryFailures) { # Failure % if (($ReplSummaryFailure.Line -Replace " +", "`t").Split("`t")[4] -gt 0) { $ADReplSummaryFailures = $ADReplSummaryFailures + $ReplSummaryFailure.Line } } if ($ADReplSummaryFailures.count -eq 0) { $ADReplSummary = "OK" } elseif ($ADReplSummaryFailures.count -gt 0) { $ADReplSummary = "WARNING" } else { $ADReplSummary = "ERROR" } Add-Content $FilePathTemp ("AD Replication Summary: " + $ADReplSummary) Add-Content $FilePathTemp "" # Operational Errors if ($ReplSummary -like "*operational errors*") { Add-Content $FilePathTemp ("AD operational errors detected:") $i = 0 while ($i -lt $ReplSummary.Count) { if ($ReplSummary[$i] -like "*operational errors*") { $i = $i + 1 while ($i -lt $ReplSummary.Count) { if ($ReplSummary[$i] -ne "") { Add-Content $FilePathTemp $ReplSummary[$i] } $i = $i + 1 } } $i = $i + 1 } } Add-Content $FilePathTemp "" # DNS try { $DNSZones = Get-DnsServerZone -ErrorAction stop $DNSZonesNonAD = $DNSZones | Where-Object { ($_.IsDsIntegrated -eq $false) -and ($_.ZoneName -notlike "*arpa") } if ([string]::IsNullOrEmpty($DNSZonesNonAD)) { $DNSZonesNonADCount = 0 } elseif ([string]::IsNullOrEmpty($DNSZonesNonAD.count)) { $DNSZonesNonADCount = 1 } else { $DNSZonesNonADCount = $DNSZonesNonAD.count } Add-Content $FilePathTemp ("DNS Zone Count: " + $DNSZones.count) Add-Content $FilePathTemp ("Non-AD Zone Count: " + $DNSZonesNonADCount) Add-Content $FilePathTemp "" } catch { Add-Content $FilePathTemp "DNS Zone Count: Unable to pull" Add-Content $FilePathTemp "Non-AD Zone Count: Unable to pull" } } # ------------------------------------------------------------------------------------------------------------ # # --- PATCH SCHEDULE WriteStatus INFO "Current Checkpoint 'Update History'" $FilePathTemp = PrepDiscoveryFilePath "UpdateHistory" $TempDates = @() $UpdateNum = 5 $UpdateString = "" if ($UpdateHistory) { # Convert to dates, zero out hours, minutes, seconds, miliseconds foreach ($Update in $UpdateHistory) { $TempDates = $TempDates + (Get-Date -Year $Update.InstalledOn.Year -Month $Update.InstalledOn.Month -Day $Update.InstalledOn.Day -Hour "0" -Minute "0" -Second "0" -Millisecond "0") } # Limit update history to last 5 unique dates $LatestDates = $TempDates | Select-Object -Unique | Sort-Object -Descending | Select-Object -First $UpdateNum foreach ($Date in $LatestDates) { $UpdateString = $UpdateString + $Date.DayOfWeek.ToString().Substring(0, 3).ToUpper() + "-" $UpdateString = $UpdateString + $Date.Month.ToString().PadLeft(2, "0") + "/" $UpdateString = $UpdateString + $Date.Day.ToString().PadLeft(2, "0") + "/" $UpdateString = $UpdateString + $Date.Year.ToString().Substring(2, 2) + "," } # Trim trailing comma $UpdateString = $UpdateString.TrimEnd(",") Add-Content $FilePathTemp ("Last " + $UpdateNum + " updates: " + $UpdateString) } else { Add-Content $FilePathTemp "NA/ERROR" } # ------------------------------------------------------------------------------------------------------------ # # --- CREDSSP WriteStatus INFO "Current Checkpoint 'CredSSP'" $FilePathTemp = PrepDiscoveryFilePath "CredSSP" if (([Environment]::OSVersion.Version -match [version]"6.0.6002") -or # 2008 SP2 ([Environment]::OSVersion.Version -match [version]"6.1.7601") -or # 2008 R2 SP1 ([Environment]::OSVersion.Version -ge "6.2")) { # 2012+ if ($UpdateHistory) { $CredSSPHotfixIDs = @( "KB4056564" # 2008 SP 2 "KB4103718", "KB4103712" # 2008 R2 SP 1 "KB4103730", "KB4103726" # 2012 "KB4103725", "KB4103715" # 2012 R2 "KB4103723", "KB4103727", "KB4103721" # 2016 "KB4551853" # 2019 ) $CredSSPFix = $UpdateHistory | Where-Object { $_.HotFixID -match ($CredSSPHotfixIDs -Join "|") } $CredSSPPath = "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System\CredSSP\Parameters" if (Get-ItemProperty -Path $CredSSPPath -Name AllowEncryptionOracle -ErrorAction SilentlyContinue) { $CredSSPRegKey = $true } else { $CredSSPRegKey = $false } if ($CredSSPFix -and $CredSSPRegKey) { Add-Content $FilePathTemp "Fixed" } else { Add-Content $FilePathTemp "Not Fixed" } } else { WriteStatus ERROR "Update history missing. Unable to check CredSSP." Add-Content $FilePathTemp "ERROR" } } else { Add-Content $FilePathTemp "NA" } # ------------------------------------------------------------------------------------------------------------ # # --- RDP WriteStatus INFO "Current Checkpoint 'RDP'" $FilePathTemp = PrepDiscoveryFilePath "RDP" $RDPStatus = ($Services | Where-Object { $_.Name -eq "TermService" }).Status Add-Content $FilePathTemp $RDPStatus # ------------------------------------------------------------------------------------------------------------ # # --- WINRM WriteStatus INFO "Current Checkpoint 'WinRM'" $FilePathTemp = PrepDiscoveryFilePath "WinRM" $WinRMErrors = "" # Does OS support TLS 1.2? try { if ($UpdateHistory) { $OsSupportsTls12 = ( ([Environment]::OSVersion.Version -ge [version]"6.1") -or # 2008 R2 ( ([Environment]::OSVersion.Version -ge [version]"6.0") -and # 2008 RTM ($UpdateHistory | Where-Object { $_.HotFixID -eq 'KB4019276' }) ) ) } else { WriteStatus WARNING "Update history missing. Unable to check TLS OS support." $OsSupportsTls12 = $false } } catch { $OsSupportsTls12 = $false $WinRMErrors = $WinRMErrors + $Error[0].Exception.Message + "`r`n" } # Is TLS 1.2 enabled? try { if ($OsSupportsTls12 -eq $true) { $TlsKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Server' $TlsReg = Get-ItemProperty $TlsKey -Name Enabled, DisabledByDefault -ErrorAction SilentlyContinue if ([Environment]::OSVersion.Version -ge [version]"6.2") { # 2012 RTM; enabled by default $Tls12ServerEnabled = ( $null -eq $TlsReg -or ( ($null -eq $TlsReg.Enabled -or $TlsReg.Enabled -band 1) -and # Check only the LSB; confusion exists over how to set this value, some set to FFFFFFFF ($null -eq $TlsReg.DisabledByDefault -or $TlsReg.DisabledByDefault -eq 0) ) ) } else { $Tls12ServerEnabled = ( $TlsReg.Enabled -band 1 -and $TlsReg.DisabledByDefault -eq 0 ) } } else { $Tls12ServerEnabled = $false } } catch { $WinRmEnabled = $false $WinRMErrors = $WinRMErrors + $Error[0].Exception.Message + "`r`n" } # Is WinRM enabled? try { $WinRmService = Get-Service WinRM if ($WinRmService.status -eq 'running') { $Pssc = Get-PSSessionConfiguration -Name 'microsoft.powershell' -ErrorAction SilentlyContinue $WinRmEnabled = ( $WinRmService.Status -eq 'Running' -and $Pssc.Permission -match 'BUILTIN\\Administrators AccessAllowed' ) } else { $WinRmEnabled = "false" } } catch { $WinRmEnabled = $false $WinRMErrors = $WinRMErrors + $Error[0].Exception.Message + "`r`n" } # Is WinRm https enabled? try { if ($WinRmService.status -eq 'running') { $Listeners = Get-ChildItem 'WSMan:\localhost\Listener' $HttpsListeners = $Listeners | Where-Object { $_.Keys -contains 'Transport=HTTPS' } $WinRmHttpsEnabled = ( $WinRmEnabled -and $HttpsListeners -and (netstat -ano | Select-String '0.0.0.0:5986 .* LISTENING') ) } else { $WinRmHttpsEnabled = "false" } } catch { $WinRmHttpsEnabled = $false $WinRMErrors = $WinRMErrors + $Error[0].Exception.Message + "`r`n" } # Is WinRM negotiate enabled? try { if ($WinRmService.status -eq 'running') { $WinRmNegotiateEnabled = (Get-Item WSMan:\localhost\Service\Auth\Negotiate).Value -eq 'true' } else { $WinRmNegotiateEnabled = "false" } } catch { $WinRmNegotiateEnabled = $false $WinRMErrors = $WinRMErrors + $Error[0].Exception.Message + "`r`n" } if ($OsSupportsTls12 -and $Tls12ServerEnabled -and $WinRmEnabled -and $WinRmHttpsEnabled -and $WinRmNegotiateEnabled) { Add-Content $FilePathTemp "OK" } else { Add-Content $FilePathTemp "FAILED" Add-Content $FilePathTemp ("OS supports TLS 1.2: " + $OsSupportsTls12) Add-Content $FilePathTemp ("TLS 1.2 enabled: " + $Tls12ServerEnabled) Add-Content $FilePathTemp ("WinRM enabled: " + $WinRmEnabled) Add-Content $FilePathTemp ("WinRM https enabled: " + $WinRmHttpsEnabled) Add-Content $FilePathTemp ("WinRM negotiate enabled: " + $WinRmNegotiateEnabled) if ($WinRMErrors) { Add-Content $FilePathTemp "" Add-Content $FilePathTemp "ERROR DETAILS:" Add-Content $FilePathTemp $WinRMErrors } } # ------------------------------------------------------------------------------------------------------------ # # --- UAC WriteStatus INFO "Current Checkpoint 'UAC'" $FilePathTemp = PrepDiscoveryFilePath "UAC" if ([Environment]::OSVersion.Version -lt "6.0") { # Unsupported OS WriteStatus ERROR "UAC not supported." Add-Content $FilePathTemp "NA" } else { $UACRegPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" if ((Get-ItemProperty -Path $UACRegPath -ErrorAction SilentlyContinue | Select-Object -ExpandProperty EnableLUA) -eq 0) { Add-Content $FilePathTemp "Disabled" } else { Add-Content $FilePathTemp "Enabled" } } # ------------------------------------------------------------------------------------------------------------ # # --- PAGEFILE WriteStatus INFO "Current Checkpoint 'PageFile'" $FilePathTemp = PrepDiscoveryFilePath "PageFile" try { if ((Get-WmiObject win32_ComputerSystem).AutomaticManagedPagefile -eq "True") { Add-Content $FilePathTemp "SYSTEM MANAGED" } else { $Page = Get-WmiObject Win32_PageFileSetting foreach ($File in $Page) { Add-Content $FilePathTemp ($File.Name + "," + $File.MaximumSize) } } } catch { Add-Content $FilePathTemp "NA/ERROR" } # ------------------------------------------------------------------------------------------------------------ # # --- DISKS [Disks:Drive,Size(GB),Free(GB),Disk#,LunID,Model,NAA] WriteStatus INFO "Current Checkpoint 'Disks'" $FilePathTemp = PrepDiscoveryFilePath "Disks" $Drives = @() try { Get-WmiObject Win32_Volume | Sort-Object DriveLetter | ForEach-Object { $TotalGB = "{0:N2}" -f ([Math]::Round($_.Capacity / 1024 / 1024 / 1024, 2)) $FreeGB = "{0:N2}" -f ([Math]::Round($_.FreeSpace / 1024 / 1024 / 1024, 2)) $DriveDetails = New-Object PSObject $DriveDetails | Add-Member NoteProperty "DriveLetter" $_.DriveLetter $DriveDetails | Add-Member NoteProperty "TotalGB" $TotalGB $DriveDetails | Add-Member NoteProperty "FreeGB" $FreeGB $Drives += $DriveDetails } foreach ($Drive in $Drives) { Add-Content $FilePathTemp ( $Drive.DriveLetter + $StrDiv + # Drive $Drive.TotalGB + $StrDiv + # Size(DB) $Drive.FreeGB + $StrDiv + # Free(GB) "ERR" + $StrDiv + # Disk#* "ERR" + $StrDiv + # LunID* "ERR" + $StrDiv + # Model* "ERR" # NAA* # *Possible future support ) } } catch { Add-Content $FilePathTemp "NA/ERROR" } # ------------------------------------------------------------------------------------------------------------ # # --- RAID CONFIG # Possible future support # ------------------------------------------------------------------------------------------------------------ # # --- HBAS [Model,WWN,Active,Status] WriteStatus INFO "Current Checkpoint 'HBAs'" $FilePathTemp = PrepDiscoveryFilePath "HBAs" $Port = Get-WmiObject MSFC_FibrePortHBAAttributes -Namespace "root\WMI" -ErrorAction SilentlyContinue $HBAs = Get-WmiObject MSFC_FCAdapterHBAAttributes -Namespace "root\WMI" -ErrorAction SilentlyContinue if ($Port -and $HBAs) { $HBAProperties = $HBAs | Get-Member -MemberType Property, AliasProperty | Select-Object -ExpandProperty name | Where-Object { $_ -notlike "__*" } $HBAs = $HBAs | Select-Object $HBAProperties foreach ($HBA in $HBAs) { Add-Content $FilePathTemp ($HBA.model + $StrDiv + $HBA.NodeWWN + $StrDiv + $HBA.Active + $StrDiv + $HBA.HBAStatus) } } else { Add-Content $FilePathTemp "NA/ERROR" } # ------------------------------------------------------------------------------------------------------------ # # --- MPIO [INSTALLED] WriteStatus INFO "Current Checkpoint 'MPIO'" $FilePathTemp = PrepDiscoveryFilePath "MPIO" $MPIO = $Features | Where-Object { $_.Name -eq "Multipath I/O" } if ([string]::IsNullOrEmpty($MPIO)) { Add-Content $FilePathTemp "NOT DETECTED" } else { Add-Content $FilePathTemp "Installed" } # ------------------------------------------------------------------------------------------------------------ # # --- ISILON [IN USE] WriteStatus INFO "Current Checkpoint 'Isilon'" $FilePathTemp = PrepDiscoveryFilePath "Isilon" if ($NICs) { $IsilonNetworks = @( '192.168.15', '192.168.17', '192.168.180', '192.168.29') $IsilonDetected = "ERROR" if ([string]::IsNullOrEmpty(($NICs | Where-Object { ($_.Name -like "*isilon*") -and ($_.IP -match ($IsilonNetworks -Join "|")) }) -eq $false)) { $IsilonDetected = "Likely" } elseif ([string]::IsNullOrEmpty(($NICs | Where-Object { $_.Name -like "*isilon*" }) -eq $false)) { $IsilonDetected = "Possibly" } elseif ([string]::IsNullOrEmpty(($NICs | Where-Object { $_.IP -match ($IsilonNetworks -Join "|") }) -eq $false)) { $IsilonDetected = "Possibly" } else { $IsilonDetected = "Unable to detect" } Add-Content $FilePathTemp $IsilonDetected } else { Add-Content $FilePathTemp "NA/ERROR" } # ------------------------------------------------------------------------------------------------------------ # # --- SERVICE PORTS WriteStatus INFO "Current Checkpoint 'ServicePorts'" $FilePathTemp = PrepDiscoveryFilePath "ServicePorts" $Netstat = netstat -anb $ExclusionPorts = @( '88', '135', '139', '389', '445', '464', '593', '636', '3268', '3389', '10808') # https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers $Listeners = @() $i = 0 while ($null -ne $Netstat[$i]) { if ($Netstat[$i] -clike "*LISTENING*") { $PortTemp = [int](($Netstat[$i] -replace '\s+', '$').split('$')[2]).split(':')[-1] $SvcTemp = $Netstat[$i + 1] if ($SvcTemp -eq "") { $SvcTemp = "OwnerFail" } # Replacements $SvcTemp = $SvcTemp.replace('Can not obtain ownership information', 'OwnerFail') $SvcTemp = $SvcTemp.replace('[', '') $SvcTemp = $SvcTemp.replace(']', '') $SvcTemp = $SvcTemp.replace('.exe', '') $SvcTemp = ($SvcTemp -replace '\s+', ' ') $SvcTemp = $SvcTemp.replace(' ', '') if (($PortTemp -lt 49152) -and (($PortTemp -match ($ExclusionPorts -Join "|")) -eq $false)) { $Listener = New-Object System.Object $Listener | Add-Member -type NoteProperty -Name Port -Value $PortTemp.ToString() $Listener | Add-Member -type NoteProperty -Name Svc -Value $SvcTemp $Listeners += $Listener } } $i = $i + 1 } # Remove duplicate Listeners $Listeners = $Listeners | Group-Object "Port", "Svc" | ForEach-Object { $_.Group | Select-Object "Port", "Svc" -First 1 } | Sort-Object -Property Port # Get unique processes $UniqueSvcs = $Listeners | Group-Object "Svc" | ForEach-Object { $_.Group | Select-Object "Svc" -First 1 } foreach ($UniqueSvc in $UniqueSvcs) { $ValueTemp = "" foreach ($Listener in $Listeners) { if ($UniqueSvc.Svc -eq $Listener.Svc) { if ($ValueTemp -eq "") { $ValueTemp = [string]($Listener.Port) } else { $ValueTemp = ($ValueTemp + "|" + $Listener.Port) } } } $ValueTemp = ($ValueTemp + ":" + $UniqueSvc.Svc) Add-Content $FilePathTemp $ValueTemp } # ------------------------------------------------------------------------------------------------------------ # # --- INSTALLATIONS WriteStatus INFO "Current Checkpoint 'Installations'" $FilePathTemp = PrepDiscoveryFilePath "Installations" $Installations = @() # Azure AD Connect $Installations = $Installations + (ListServices -ServiceName "Azure AD Connect") # ADFS $Installations = $Installations + (ListServices -ServiceName "Active Directory Federation Services") # Apache $Installations = $Installations + (ListApplications -AppName "Apache") # Bitlocker $Installations = $Installations + (ListServices -ServiceName "BitLocker Drive Encryption") # Certificate Services $Installations = $Installations + (ListServices -ServiceName "Certificate Services") # CloudBerry $Installations = $Installations + (ListApplications -AppName "CloudBerry Backup") # Coldfusion $Installations = $Installations + (ListServices -ServiceName "ColdFusion") # DNS $Installations = $Installations + (ListServices -ServiceName "DNS Server") # FTP $Installations = $Installations + (ListServices -ServiceName "FTP") # URL Rewrite $Installations = $Installations + (ListApplications -AppName "IIS URL Rewrite") # Mail $Installations = $Installations + (ListServices -ServiceName "Mail") # Office if (ListApplications -AppName "Microsoft Office") { $OsppVbs = Get-ChildItem -Path 'C:\Program Files\Microsoft Office\' -Recurse -Filter "*ospp.vbs" -ErrorAction SilentlyContinue if ([string]::IsNullOrEmpty($OsppVbs.FullName)) { $OsppVbs = Get-ChildItem -Path 'C:\Program Files (x86)\Microsoft Office\' -Recurse -Filter "*ospp.vbs" -ErrorAction SilentlyContinue } if ([string]::IsNullOrEmpty($OsppVbs.FullName) -eq $False) { $LicenseName = (cscript $OsppVbs.FullName /dstatus | Select-String -Pattern "LICENSE NAME: ").ToString().Replace("LICENSE NAME: ", "") $ProductKey = (cscript $OsppVbs.FullName /dstatus | Select-String -Pattern "Last 5").ToString().Split(" ")[-1] $OfficeDetails = (" [" + $LicenseName + " : " + $ProductKey + "]") } else { $OfficeDetails = " [License Unknown : Key Unknown]" } } if (ListApplications -AppName "Microsoft Office Standard") { $Installations = $Installations + ((ListApplications -AppName "Microsoft Office Standard") + $OfficeDetails) } if (ListApplications -AppName "Microsoft Office Professional") { $Installations = $Installations + ((ListApplications -AppName "Microsoft Office Professional") + $OfficeDetails) } # Oracle $Installations = $Installations + (ListServices -ServiceName "Oracle") # MySQL $Installations = $Installations + (ListServices -ServiceName "MySQL") # NPS $Installations = $Installations + (ListServices -ServiceName "Network Policy Server") # NLB $Installations = $Installations + (ListServices -ServiceName "Network Setup Service") # PostgreSQL $Installations = $Installations + (ListServices -ServiceName "PostgreSQL") # RRAS $Installations = $Installations + (ListServices -ServiceName "Routing and Remote Access") # Sitecore $Installations = $Installations + (ListServices -ServiceName "Sitecore") # SMTP $Installations = $Installations + (ListServices -ServiceName "SMTP") # SQL Backup (Redgate) if (ListApplications -AppName "SQL Backup") { foreach ($App in ($Applications | Where-Object { $_.Name -like "*sql backup*" })) { $Installations = $Installations + ($App.Name + " [" + $App.Vendor + "] " + $App.Version) } } # Tomcat $Installations = $Installations + (ListServices -ServiceName "Tomcat") # VirtualCenter $Installations = $Installations + (ListServices -ServiceName "VMware VirtualCenter Server") # vSphere $Installations = $Installations + (ListServices -ServiceName "VMware vSphere Web Client") # Remove blank lines $Installations = $Installations | Where-Object { $_ -ne "" } if ($Installations) { Add-Content $FilePathTemp $Installations } else { Add-Content $FilePathTemp "" } # ------------------------------------------------------------------------------------------------------------ # # --- .NET VERSIONS WriteStatus INFO "Current Checkpoint '.Net Framework'" $FilePathTemp = PrepDiscoveryFilePath "DotNetFramework" Add-Content $FilePathTemp "VERSIONS:" Add-Content $FilePathTemp "" $DotNetFramework = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse | Get-ItemProperty -Name Version, Release -ErrorAction SilentlyContinue | Where-Object { $_.PSChildName -match '^(?!S)\p{L}' } | Select-Object Version, PSChildName foreach ($Framework in $DotNetFramework) { $VersionTemp = $Framework.Version if ($Framework.PSChildName -eq "Windows Communication Foundation") { $VersionTemp = $VersionTemp + " (WCF)" } elseif ($Framework.PSChildName -eq "Windows Presentation Foundation") { $VersionTemp = $VersionTemp + " (WPF)" } if ($Framework.PSChildName -eq "Full") { $VersionTemp = $VersionTemp + " (Full)" } elseif ($Framework.PSChildName -eq "Client") { $VersionTemp = $VersionTemp + " (Client)" } Add-Content $FilePathTemp $VersionTemp } Add-Content $FilePathTemp "" Add-Content $FilePathTemp "UPDATES:" Add-Content $FilePathTemp "" if (Test-Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Updates') { $DotNetUpdates = Get-ChildItem 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Updates' | Where-Object { $_.name -like "*.NET Framework*" } } else { $DotNetUpdates = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\Updates' | Where-Object { $_.name -like "*.NET Framework*" } } foreach ($Version in $DotNetUpdates) { $Updates = Get-ChildItem $Version.PSPath foreach ($Update in $Updates) { Add-Content $FilePathTemp $Update.PSChildName } } # ------------------------------------------------------------------------------------------------------------ # # --- CITRIX WriteStatus INFO "Current Checkpoint 'Citrix'" $FilePathTemp = PrepDiscoveryFilePath "Citrix" $Citrix = ListServices -ServiceName "Citrix" if ($Citrix) { Add-Content $FilePathTemp $Citrix } else { Add-Content $FilePathTemp "" } # ------------------------------------------------------------------------------------------------------------ # # --- EXCHANGE WriteStatus INFO "Current Checkpoint 'Exchange'" $FilePathTemp = PrepDiscoveryFilePath "Exchange" $Exchange = (ListApplications -AppName "Microsoft Exchange Server" -AppendVersion) + (ListServices -ServiceName "Microsoft Exchange") if ($Exchange) { Add-Content $FilePathTemp $Exchange } else { Add-Content $FilePathTemp "" } # ------------------------------------------------------------------------------------------------------------ # # --- SHAREPOINT WriteStatus INFO "Current Checkpoint 'Sharepoint'" $FilePathTemp = PrepDiscoveryFilePath "Sharepoint" $Sharepoint = ListServices -ServiceName "Microsoft Sharepoint Server" if ($Sharepoint) { Add-Content $FilePathTemp $Sharepoint } else { Add-Content $FilePathTemp "" } # ------------------------------------------------------------------------------------------------------------ # # --- WEB SERVICE WriteStatus INFO "Current Checkpoint 'WebService'" $FilePathTemp = PrepDiscoveryFilePath "WebService" $IISTemp = ListServices -ServiceName "World Wide Web Publishing Service" if ([string]::IsNullOrEmpty($IISTemp) -eq $false) { Add-Content $FilePathTemp "Installed" } else { Add-Content $FilePathTemp "" } # ------------------------------------------------------------------------------------------------------------ # # --- CLUSTER SERVICE WriteStatus INFO "Current Checkpoint 'ClusterService'" $FilePathTemp = PrepDiscoveryFilePath "ClusterService" $ClusterService = $Services | Where-Object { $_.DisplayName -like "Cluster Service" } if ([string]::IsNullOrEmpty($ClusterService)) { Add-Content $FilePathTemp "" } else { try { #If Get-Cluster doesn't work, unsupported and skip Get-Cluster -ErrorAction Stop | Out-Null Add-Content $FilePathTemp "Cluster Names:" foreach ($Cluster in (Get-Cluster)) { Add-Content $FilePathTemp $Cluster.Name } Add-Content $FilePathTemp "" Add-Content $FilePathTemp "Cluster Nodes:" foreach ($Cluster in (Get-ClusterNode)) { Add-Content $FilePathTemp $Cluster.Name } Add-Content $FilePathTemp "" Add-Content $FilePathTemp "Cluster Group Owners:" foreach ($Cluster in (Get-ClusterGroup)) { Add-Content $FilePathTemp ($Cluster.Name + ":" + $Cluster.OwnerNode) } Add-Content $FilePathTemp "" Add-Content $FilePathTemp "Cluster Resources:" foreach ($Cluster in (Get-ClusterResource)) { Add-Content $FilePathTemp ($Cluster.Name + "[" + $Cluster.ResourceType + "]:" + $Cluster.OwnerGroup) } Add-Content $FilePathTemp "" } catch { Add-Content $FilePathTemp "Cluster Service is installed, but unable to pull cluster info" } } # ------------------------------------------------------------------------------------------------------------ # # --- HYPER-V WriteStatus INFO "Current Checkpoint 'Hyper-V'" $FilePathTemp = PrepDiscoveryFilePath "Hyper-V" $HyperV = ListServices -ServiceName "Hyper-V" if ($HyperV) { Add-Content $FilePathTemp $HyperV } else { Add-Content $FilePathTemp "" } # ------------------------------------------------------------------------------------------------------------ # # --- REMOTE DESKTOP SERVICE WriteStatus INFO "Current Checkpoint 'RemoteDesktopService'" $FilePathTemp = PrepDiscoveryFilePath "RemoteDesktopService" $RDSServices = $Features | Where-Object { ($_.Name -like "Remote Desktop Connection Broker") -or ` ($_.Name -like "Remote Desktop Gateway") -or ` ($_.Name -like "Remote Desktop Licensing") -or ` ($_.Name -like "Remote Desktop Session Host") -or ` ($_.Name -like "Remote Desktop Virtualization Host") -or ` ($_.Name -like "Remote Desktop Web Access") } if ($RDSServices.Count -eq 0) { Add-Content $FilePathTemp "" } else { foreach ($RDSService in $RDSServices) { Add-Content $FilePathTemp $RDSService.Name } } # TS CALs # Possible future support # ------------------------------------------------------ # # --- DISTRIBUTED FILE SERVICE WriteStatus INFO "Current Checkpoint 'DistributedFileService'" $FilePathTemp = PrepDiscoveryFilePath "DistributedFileService" $DFS = ListServices -ServiceName "Distributed File System" if ($DFS) { Add-Content $FilePathTemp "Installed" } else { Add-Content $FilePathTemp "" } # Possible future support # Namespace # Nodes # Shares # ------------------------------------------------------------------------------------------------------------ # WriteStatus FINISH "Rackspace Transition Supplemental Discovery Completed." return(0) # ------------------------------------------------------------------------------------------------------------ # # --- END SCRIPT # ------------------------------------------------------------------------------------------------------------ #