Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### Define Title
- $host.ui.RawUI.WindowTitle = "Rules of Acquisition"
- # Vendor information Template
- $VendorLine_1 = "For support with $Vendor1 software, contact:"
- $VendorLine_2 = "Vendor 1"
- $VendorLine_3 = "vendor1@vendor1support.com"
- $VendorLine_4 = "vendor website information"
- $VendorLine_5 = "1 (800) 342 0652 "
- # Stage 1 - Gathering
- ## Name
- $ServerName = "# " + $env:COMPUTERNAME
- $FQDN = "$env:COMPUTERNAME" + "." + "$env:USERDNSDOMAIN"
- ## CPU
- $ServerCPU_Core = (Get-CimInstance -Class CIM_Processor).NumberOfCores
- $ServerCPU_Logic = (Get-CimInstance -Class CIM_Processor).NumberOfLogicalProcessors
- $ServerCPU_NVM = "$ServerCPU_Core" + ", " + "$ServerCPU_Logic"
- ## Drives
- $allDrives = [system.IO.DriveInfo]::GetDrives()
- foreach ($d in $allDrives) {
- "Drive {0}" -f $d.Name
- " File type: {0}" -f $d.DriveType
- if ($d.IsReady) {
- " Volume label: {0}" -f $d.VolumeLabel
- " File system: {0}" -f $d.DriveFormat
- $fs = $d.AvailableFreeSpace/1gb
- $tfs = $d.TotalFreeSpace/1gb
- $TS = $d.TotalSize/1gb
- " Available space to current user:{0, 15:n2} GiB" -f $fs
- " Total available space: {0, 15:n2} GiB" -f $tfs
- " Total size of drive: {0, 15:n3} GiB" -f $ts
- }
- $DriveListing = "Drive {0}" -f $d.Name
- $DriveSize = $TS
- $DriveFree = $tfs
- $DriveA = $d.TotalSize
- $DriveB = $d.TotalFreeSpace
- $DriveCalc1 = ($DriveB/$DriveA).tostring("P")
- }
- ## RAM
- $ServerRAM_Calc = (Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property capacity -Sum).sum /1gb
- ## Network and Domain
- $Serverv4 = (Get-NetIPAddress -AddressFamily IPv4 -PrefixOrigin Dhcp).IPAddress
- $ServerSubnetString = cmd /c ipconfig | findstr /i "Subnet"
- $ServerGatewayString = cmd /c ipconfig | findstr /i "Gateway"
- $a, $ServerSubnet = $ServerSubnetString.Split("{:}")
- $b, $ServerGateway = $ServerGatewayString.Split("{:}")
- $ServerMACGet = (Get-WmiObject -ClassName Win32_NetworkAdapterConfiguration -Filter "IPEnabled='True'" -ComputerName $env:COMPUTERNAME | Select-Object -Property MACAddress, Description).MACAddress
- $Trust = Test-ComputerSecureChannel
- switch ($Trust) {
- "True" {$Trustee = "Secure Channel to $env:USERDNSDOMAIN alive and working."; break}
- "False" {$Trustee = "Secure Channel Connection to $env:USERDNSDOMAIN failed."; break}
- default {$Trustee = "Something else happened. "; break}
- }
- ## Convert variables into ROA Configuration Collection Variables
- $ServerOS = "| OS | " + (Get-ComputerInfo).WindowsProductName + " |"
- $ServerCPU = "| CPU & Core Count | " + $ServerCPU_NVM + " |"
- $ServerRAM = "| RAM | " + $ServerRAM_Calc + " GiB" + " |"
- $ServerHDD = "| Hard Drives | $DriveListing ," + "Total Size: {0, 5:n3} GiB" -f $ts + ", Free Space: $DriveCalc1" + " |"
- $ServerFQDN = "| FQDN | " + $FQDN + " |"
- $ServerIP = "| IP | " + $Serverv4 + " |"
- $ServerSunett = "| Subnet Mask | " + $ServerSubnet + " |"
- $ServerDefaultGate = "| Default Gateway | " + $ServerGateway + " |"
- $ServerMAC = "| MAC Address | " + $ServerMACGet + " |"
- $ServerTrust = "| Trust | " + $Trustee + " |"
- # Gather System Software
- $SoftwareMD = $env:COMPUTERNAME + '_software.md'
- $SoftwareMDFile = "C:\Automation\" + $SoftwareMD
- Set-Content -Path "C:\Automation\$SoftwareMD" -Value '| Software Name | Version | Reason |'
- $Tables = "|:-------|:-----:|-----|"
- Sleep 3
- Add-Content -Path "C:\Automation\$SoftwareMD" -Value $Tables
- foreach ($UKey in 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*','HKLM:\SOFTWARE\Wow6432node\Microsoft\Windows\CurrentVersion\Uninstall\*','HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*','HKCU:\SOFTWARE\Wow6432node\Microsoft\Windows\CurrentVersion\Uninstall\*')
- {foreach ($Product in (Get-ItemProperty $UKey -ErrorAction SilentlyContinue)){if($Product.DisplayName -and $Product.SystemComponent -ne 1){$SoftwareDN = $Product.DisplayName ; $SoftwareDV = $Product.DisplayVersion ; $SoftwareDVI = "| " + "$SoftwareDN" + " | " + "$SoftwareDV" + " | | " ; Add-Content -Path "C:\Automation\$SoftwareMD" -Value $SoftwareDVI }}}
- # Gather System Services
- $NonDefaultServices = @()
- $Services = Get-wmiobject win32_service | where { $_.PathName -notmatch "policyhost.exe" -and $_.Name -ne "LSM" -and $_.PathName -notmatch "OSE.EXE" -and $_.PathName -notmatch "OSPPSVC.EXE" -and $_.PathName -notmatch "Microsoft Security Client" -and $_.DisplayName -notmatch "NetSetupSvc" -and $_.Caption -notmatch "Windows" -and $_.PathName -notmatch "Windows" }
- $ServicesMD = $env:COMPUTERNAME + '_services.md'
- $ServicesMDFile = "C:\Automation\" + $ServicesMD
- Set-Content -Path "C:\Automation\$ServicesMD" -Value '| Display Name | Description |
- |:-------|---:|'
- Foreach ($Service in $Services){
- $NonDefaultServices+= [pscustomobject]@{
- DisplayName = $Service.DisplayName
- Description = $Service.Description
- }
- $Total = '| ' + $Service.DisplayName + ' | ' + $Service.Description + ' |'
- Add-Content -Path "C:\Automation\$ServicesMD" -Value $Total
- }
- $ServicesFile = "C:\Automation\$ServicesMD"
- # Configuration Overview
- $Table = "|:----|:----|"
- $ConfigurationOverviewFile = "C:\Automation\" + $env:COMPUTERNAME + "_Config_Overview.md"
- Set-Content -Path "$ConfigurationOverviewFile" -Value '| Component | Information |'
- Add-Content -Path "$ConfigurationOverviewFile" -Value $Table
- #Add-Content -Path "$ConfigurationOverviewFile" -Value
- Add-Content -Path "$ConfigurationOverviewFile" -Value $ServerOS
- Add-Content -Path "$ConfigurationOverviewFile" -Value $ServerCPU
- Add-Content -Path "$ConfigurationOverviewFile" -Value $ServerRAM
- Add-Content -Path "$ConfigurationOverviewFile" -Value $ServerHDD
- Add-Content -Path "$ConfigurationOverviewFile" -Value $ServerFQDN
- Add-Content -Path "$ConfigurationOverviewFile" -Value $ServerIP
- Add-Content -Path "$ConfigurationOverviewFile" -Value $ServerSunett
- Add-Content -Path "$ConfigurationOverviewFile" -Value $ServerDefaultGate
- Add-Content -Path "$ConfigurationOverviewFile" -Value $ServerMAC
- Add-Content -Path "$ConfigurationOverviewFile" -Value $ServerTrust
- # Define ROA Documentation Markdown Template Variables
- $ExecutiveTitle = "## Executive Summary / Typical Use"
- $ExecutiveSummary = "Brief overview of how it's used and what it does for the company. Keep it non IT simple."
- $ServicesProvidedTitle = "## Services Provided"
- $ServicesProcidedSummary = "Services functions protocols etc. Go into more depth here."
- $ConfigurationOverviewTitle = "## Configuration Overview"
- $ConfigurationOverviewSummary = "Describe the hardware and host setup here, OS, CPU, RAM, etc. Purchase Order info."
- $ConfigurationOverview = [IO.File]::ReadAllText("$ConfigurationOverviewFile")
- $SystemSoftwareTitle = "## System Software"
- $SystemSoftwareSummary = "List, in general, the software installed on the server. Operating system updates are omitted. Include anything at all out of the normal install. Include Runtimes such as .net and C++ etc."
- $SystemSoftwareOverview = [IO.File]::ReadAllText("$SoftwareMDFile")
- $ServicesTitle = "### System Services"
- $ServicesSummary = "List, in general, the services installed on the server. Include anything that’s a non-standard service."
- $ServicesOverview = [IO.File]::ReadAllText("$ServicesFile")
- $BackupTitle = "### Backup & Recovery Plan"
- $BackupSummary = "This is where you list local backups, network backups, tape backups, and put any backup schedules down to paper. Keep this updated. Don't omit RAID drives even if they are not backup this is a place to document it.
- And always remember the goal is to recreate the data and services. Not to put stuff on tape. No matter how you recreate the data or service, those resources are your backup."
- $PerformanceBenchmarksTitle = " ### Performance Benchmarks "
- $PerformanceBenchmarksSummary = "You have done performance benchmarks, haven't you? Just to get an idea of network traffic, CPU traffic, and RAM usage during business hours & off hours. Nothing fancy, just write what you know."
- $InstallationNotesTitle = "## Installation Notes"
- $InstallationNotesSummary = "Anything special about the install & the vendors that provide it goes here. Kind of an errata section."
- $TroubleshootingSequencesTitle = "## Troubleshooting Sequences"
- $TroubleshootingSequencesSummary = "General steps for services to reboot or steps needed to be performed to reboot the machine."
- $SupportContactsTitle = "### Support Contacts"
- $LineBreak = "***"
- $ParagraphTool = "<br/><br/>"
- # Write file
- sleep 10
- $ServerTemplate = $env:COMPUTERNAME + ".md"
- $ServerTemplateFile = "C:\Temp\" + $ServerTemplate
- New-Item -Path "C:\Temp\" -Name "$ServerTemplate" -ItemType "File"
- # Add-Content -Path "$ServerTemplateFile" -Value
- Add-Content -Path "$ServerTemplateFile" -Value $ServerName
- Add-Content -Path "$ServerTemplateFile" -Value $ExecutiveTitle
- Add-Content -Path "$ServerTemplateFile" -Value $ExecutiveSummary
- Add-Content -Path "$ServerTemplateFile" -Value $ParagraphTool
- Add-Content -Path "$ServerTemplateFile" -Value $ServicesProvidedTitle
- Add-Content -Path "$ServerTemplateFile" -Value $ServicesProcidedSummary
- Add-Content -Path "$ServerTemplateFile" -Value $ParagraphTool
- Add-Content -Path "$ServerTemplateFile" -Value $ConfigurationOverviewTitle
- Add-Content -Path "$ServerTemplateFile" -Value $ConfigurationOverviewSummary
- Add-Content -Path "$ServerTemplateFile" -Value $ConfigurationOverview
- Add-Content -Path "$ServerTemplateFile" -Value $ParagraphTool
- Add-Content -Path "$ServerTemplateFile" -Value $LineBreak
- Add-Content -Path "$ServerTemplateFile" -Value $SystemSoftwareTitle
- Add-Content -Path "$ServerTemplateFile" -Value $SystemSoftwareSummary
- Add-Content -Path "$ServerTemplateFile" -Value $SystemSoftwareOverview
- Add-Content -Path "$ServerTemplateFile" -Value $ServicesTitle
- Add-Content -Path "$ServerTemplateFile" -Value $ServicesSummary
- Add-Content -Path "$ServerTemplateFile" -Value $ServicesOverview
- Add-Content -Path "$ServerTemplateFile" -Value $LineBreak
- Add-Content -Path "$ServerTemplateFile" -Value $BackupTitle
- Add-Content -Path "$ServerTemplateFile" -Value $BackupSummary
- Add-Content -Path "$ServerTemplateFile" -Value $ParagraphTool
- Add-Content -Path "$ServerTemplateFile" -Value $PerformanceBenchmarksTitle
- Add-Content -Path "$ServerTemplateFile" -Value $PerformanceBenchmarksSummary
- Add-Content -Path "$ServerTemplateFile" -Value $ParagraphTool
- Add-Content -Path "$ServerTemplateFile" -Value $InstallationNotesTitle
- Add-Content -Path "$ServerTemplateFile" -Value $InstallationNotesSummary
- Add-Content -Path "$ServerTemplateFile" -Value $ParagraphTool
- Add-Content -Path "$ServerTemplateFile" -Value $TroubleshootingSequencesTitle
- Add-Content -Path "$ServerTemplateFile" -Value $TroubleshootingSequencesSummary
- Add-Content -Path "$ServerTemplateFile" -Value $ParagraphTool
- Add-Content -Path "$ServerTemplateFile" -Value $SupportContactsTitle
- Add-Content -Path "$ServerTemplateFile" -Value $VendorLine_1
- Add-Content -Path "$ServerTemplateFile" -Value $VendorLine_2
- Add-Content -Path "$ServerTemplateFile" -Value $VendorLine_3
- Add-Content -Path "$ServerTemplateFile" -Value $VendorLine_4
- Add-Content -Path "$ServerTemplateFile" -Value $VendorLine_5
- <# For More than one Vendor contact information please use the following templates
- $VendorLine_ = "For support with $Vendor1 software, contact:"
- $VendorLine_ = "Vendor 1"
- $VendorLine_ = "vendor1@vendor1support.com"
- $VendorLine_ = "vendor website information"
- $VendorLine_ = "1 (800) 342 0652 "
- #>
- <# Add this to the write contact:
- Add-Content -Path "$ServerTemplateFile" -Value $VendorLine_
- Add-Content -Path "$ServerTemplateFile" -Value $VendorLine_
- Add-Content -Path "$ServerTemplateFile" -Value $VendorLine_
- Add-Content -Path "$ServerTemplateFile" -Value $VendorLine_
- Add-Content -Path "$ServerTemplateFile" -Value $VendorLine_
- #>
- # Remove files that are no longer needed:
- Remove-Item -Path $ConfigurationOverviewFile -Force
- Remove-Item -Path $SoftwareMDFile -Force
- Remove-Item -Path $ServicesMDFile -Force
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement