Skip to content

Mustafa Ateş UZUN Blog

mustafauzun.co

  • About
  • Blog
  • Home
  • »
  • Powershell
  • »
  • Powershell, System Checker Script
  • »
    • May 23, 2023May 23, 2023
    • by mustafauzun
  • Powershell

Powershell, System Checker Script

Write-Host "[System Checker]"
$informationTexts = @{
    Success = @{Text = "Success"; BackgroundColor = "DarkGreen"}
    Error = @{Text = "Error"; BackgroundColor = "DarkRed"}
    Warning = @{Text="Warning"; BackgroundColor = "DarkCyan"}
}
$getRam = (Get-CimInstance Win32_PhysicalMemory | Measure-Object -Property Capacity -Sum).sum / 1GB
$getDisks = (Get-CimInstance -ClassName Win32_LogicalDisk)
$getWindowsType = (Get-ComputerInfo).OsProductType
$getWindowsVersion = (Get-ComputerInfo).WindowsVersion

Write-Host RAM: $getRam GB -NoNewline
Write-Host " - " -NoNewline

if($getRam -ge 16)
{
    Write-Host $informationTexts.Success.Text -BackgroundColor $informationTexts.Success.BackgroundColor
}
else
{
    Write-Host $informationTexts.Error.Text "-" "Minimum RAM must be 16 GB" -BackgroundColor $informationTexts.Error.BackgroundColor
}

foreach($getDisk in $getDisks)
{
    $getDiskSpace = ($getDisk |  Measure-Object -Property Size -Sum).sum / 1GB

    Write-Host DISK $getDisk.DeviceID $getDiskSpace GB -NoNewline
    Write-Host " - " -NoNewline
    
    if($getDiskSpace -ge 128)
    {
        Write-Host $informationTexts.Success.Text -BackgroundColor $informationTexts.Success.BackgroundColor
    }
    else
    {
        Write-Host $informationTexts.Error.Text "-" "Minimum Disk must be 128 GB" -BackgroundColor $informationTexts.Error.BackgroundColor
    }
}

Write-Host Windows Type: $getWindowsType -NoNewline
Write-Host " - " -NoNewline

if($getWindowsType -eq "Server" -Or $getWindowsType -eq "DomainController")
{
    Write-Host $informationTexts.Success.Text -BackgroundColor $informationTexts.Success.BackgroundColor
}
else
{
    Write-Host $informationTexts.Error.Text "-" "Windows Type must be Server or DomainController" -BackgroundColor $informationTexts.Error.BackgroundColor
}

Write-Host Windows Version: $getWindowsVersion -NoNewline
Write-Host " - " -NoNewline

if($getWindowsVersion -ge 2012)
{
    Write-Host $informationTexts.Success.Text -BackgroundColor $informationTexts.Success.BackgroundColor
}
else
{
    Write-Host $informationTexts.Error.Text "-" "Windows Server version must be equal or greater than 2012" -BackgroundColor $informationTexts.Error.BackgroundColor
}

Write-Host Active Directory Version: -NoNewline
try
{
    $getADVersion = (Get-ADObject (Get-ADRootDSE).schemaNamingContext -Property objectVersion).objectVersion

    Write-Host " " $getADVersion -NoNewline

    if($getADVersion -ge 56)
    {
        Write-Host " - " -NoNewline
        Write-Host $informationTexts.Success.Text -BackgroundColor $informationTexts.Success.BackgroundColor -NoNewline
    }
    else
    {
        throw
    }
}
catch
{
    Write-Host " - " -NoNewline
    Write-Host $informationTexts.Error.Text "-" "Active Directory version must be equal or greater than 2012" -BackgroundColor $informationTexts.Error.BackgroundColor -NoNewline
}
pause
Share

Powershell, Host Checker Script

Powershell, Host Path Checker Script

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Javascript, Task Queue
  • Javascript, Thread Pool
  • Javascript, Lexical Environment
  • Javascript, Execution Context
  • Javascript, Event Delegation

Recent Comments

No comments to show.

Archives

  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • January 2022

Categories

  • C#
  • CMD
  • CSS
  • HTML
  • JavaScript
  • MongoDB
  • Node.js
  • Podcast
  • Powershell
  • Uncategorized
Theme: Puskar by Template Sell.