Ich hatte Schwierigkeiten, dieses Skript zu beenden. Grundsätzlich möchte ich den Speicher überprüfen, überprüfen Sie die Top 3 Speicher Schweine, zeigen, wenn der letzte Neustart war, zeigen Sie die letzte Aktualisierung, zeigen Sie Dienste, die automatisch sind aber gestoppt haben und zeigen, wie viel Platz HDD Speicherplatz habe ich auf dem Server.Beenden Sie das Powershell-Skript
Write-Host "Getting the information required" -ForeGroundColor green
Function Get-Checks {
$Output = "C:\users\b2badmin\desktop\checklist\check$((Get-Date).ToString('MM-dd-yyyy_hh-mm-ss')).txt"
#Get the computer name
$env:computername | out-file -Append $Output
#Show Available memory
Get-Counter -ComputerName localhost '\Memory\Available MBytes' |
Select-Object -ExpandProperty countersamples |
Select-Object -Property Path, cookedvalue |
Out-File -Append $Output
#Show the processes that are using the most resources top 3
Get-Process | Sort-Object -Descending WS |
select -First 3 |
Format-Table -Property WS,ProcessName |
Out-File -Append $Output
#Show last reboot
Get-WmiObject win32_operatingsystem |
select csname, @{LABEL=’LastBootUpTime’;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}} |
Out-File -Append $Output
#Show the last installed Hotfix for windows updates
Get-HotFix | Select -Last 1 |
Format-List -Property InstalledOn,Description,HotfixI |
Out-File -Append $Output
#Get the services that are Automatically started and list them if they are stopped
Get-WmiObject Win32_Service |
Where-Object { $_.StartMode -eq 'Auto' -and $_.State -ne 'Running' } |
Format-Table -AutoSize @('Name' 'DisplayName' @{Expression='State';Width=9} @{Expression='StartMode';Width=9} 'StartName') |
Out-File -Append $Output
# Show how much room is left on the HDD
Get-WmiObject Win32_LogicalDisk -ComputerName Localhost |
Format-Table DeviceID, MediaType,
@{Name="Size(GB)";Expression={[decimal]("{0:N0}" -f ($_.size/1gb))}},
@{Name="Free Space(GB)";Expression={[decimal]("{0:N0}" -f ($_.freespace/1gb))}},
@{Name="Free (%)";Expression={"{0,6:P0}" -f (($_.freespace/1gb)/($_.size/1gb))}} -AutoSize |
Out-File -Append $Output
Ich bekomme immer eine >>
Eingabeaufforderung. Was benötige ich, um das Skript auszuführen, damit es ausgeführt wird?
Sie vermissen einfach das '}' am Ende der Funktion, um es zu schließen. Sie müssen auch die Funktion aufrufen, damit sie ausgeführt werden kann. – David