Öyle uzun uzun anlatacak değilim.Ekran görüntüleri yeter anlatmaya ve anlamaya...

Kod: Tümünü seç
Add-Type @"
using System;
using System.Runtime.InteropServices;
public class Win32 {
[DllImport("kernel32.dll")]
public static extern IntPtr GetConsoleWindow();
[DllImport("user32.dll")]
public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
}
"@
$Console = [Win32]::GetConsoleWindow()
if ($Console -ne [IntPtr]::Zero)
{
[Win32]::ShowWindow($Console, 0)
}
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
try
{
$InstallDate = (Get-CimInstance Win32_OperatingSystem).InstallDate
}
catch
{
[System.Windows.Forms.MessageBox]::Show(
"Unable to read Windows installation date.",
"Error",
[System.Windows.Forms.MessageBoxButtons]::OK,
[System.Windows.Forms.MessageBoxIcon]::Error
)
exit
}
$Now = Get-Date
$DaysPassed = [int](($Now - $InstallDate).TotalDays)
$MonthsPassed = [math]::Round($DaysPassed / 30)
$Form = New-Object System.Windows.Forms.Form
$Form.Text = "Windows Format Reminder"
$Form.Size = New-Object System.Drawing.Size(560,220)
$Form.StartPosition = "CenterScreen"
$Form.FormBorderStyle = "FixedDialog"
$Form.MaximizeBox = $false
$Form.MinimizeBox = $false
$Form.Topmost = $true
$Label1 = New-Object System.Windows.Forms.Label
$Label1.Location = New-Object System.Drawing.Point(20,25)
$Label1.Size = New-Object System.Drawing.Size(510,30)
$Label1.Font = New-Object System.Drawing.Font(
"Segoe UI",
11,
[System.Drawing.FontStyle]::Bold
)
$Label1.Text = "Windows Installation Date : $($InstallDate.ToString('dd MMMM yyyy dddd HH:mm:ss'))"
$Label2 = New-Object System.Windows.Forms.Label
$Label2.Location = New-Object System.Drawing.Point(20,80)
$Label2.Size = New-Object System.Drawing.Size(510,30)
$Label2.Font = New-Object System.Drawing.Font(
"Segoe UI",
11,
[System.Drawing.FontStyle]::Bold
)
$Label2.Text = "$DaysPassed Days Passed (Approximately $MonthsPassed Months)"
$Button = New-Object System.Windows.Forms.Button
$Button.Location = New-Object System.Drawing.Point(400,130)
$Button.Size = New-Object System.Drawing.Size(100,35)
$Button.Text = "OK"
$Button.Add_Click({
$Form.Close()
})
$Form.Controls.Add($Label1)
$Form.Controls.Add($Label2)
$Form.Controls.Add($Button)
[void]$Form.ShowDialog()



