forked from DeploymentBunny/Files
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3ad624
commit 53c912d
Showing
7 changed files
with
357 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<# | ||
.Synopsis | ||
Script from TechDays Sweden 2016 | ||
.DESCRIPTION | ||
Script from TechDays Sweden 2016 | ||
.NOTES | ||
Author - Mikael Nystrom | ||
Twitter: @mikael_nystrom | ||
Blog : http://deploymentbunny.com | ||
Disclaimer: | ||
This script is provided "AS IS" with no warranties, confers no rights and | ||
is not supported by the authors or Deployment Artist. | ||
.LINK | ||
http://www.deploymentbunny.com | ||
#> | ||
$getForest = [system.directoryservices.activedirectory.Forest]::GetCurrentForest() | ||
$DCServers = $getForest.domains | ForEach-Object {$_.DomainControllers} | ForEach-Object {$_.Name} | ||
|
||
foreach ($DCServer in $DCServers){ | ||
Write-Host "Checking netaccess to $DCServer" -ForegroundColor Green | ||
Test-NetConnection -ComputerName $DCServer | ||
|
||
Write-Host "Checking Services that should be running on $DCServer" -ForegroundColor Green | ||
Invoke-Command -ComputerName $DCServer -ScriptBlock { | ||
$Services = Get-Service | ||
Foreach($Service in $Services | Where-Object -Property StartType -EQ Automatic){ | ||
$Service | Where-Object -Property Status -NE -Value Running | ||
} | ||
} | ||
|
||
Write-Host "Getting debug logs on $DCServer" -ForegroundColor Green | ||
Invoke-Command -ComputerName $DCServer -ScriptBlock { | ||
Write-Host "C:\Windows\debug\PASSWD.LOG on $DCServer says:" -ForegroundColor Green | ||
Get-Content C:\Windows\debug\PASSWD.LOG | ||
} | ||
|
||
Write-Host "Getting debug logs on $DCServer" -ForegroundColor Green | ||
Invoke-Command -ComputerName $DCServer -ScriptBlock { | ||
Write-Host "C:\Windows\debug\netlogon.log on $DCServer says:" -ForegroundColor Green | ||
Get-Content C:\Windows\debug\netlogon.log | ||
} | ||
|
||
Write-Host "Running DCDiag on $DCServer" -ForegroundColor Green | ||
Invoke-Command -ComputerName $DCServer -ScriptBlock { | ||
dcdiag.exe /test:netlogons /Q | ||
dcdiag.exe /test:Services /Q | ||
dcdiag.exe /test:Advertising /Q | ||
dcdiag.exe /test:FSMOCheck /Q | ||
} | ||
|
||
Write-Host "Checking access to SYSVOL on $DCServer" -ForegroundColor Green | ||
Test-Path -Path \\$DCServer\sysvol | ||
|
||
Write-Host "Get 20 last errors/warning on $DCServer" -ForegroundColor Green | ||
Invoke-Command -ComputerName $DCServer -ScriptBlock { | ||
Get-EventLog -LogName Application -Newest 20 -EntryType Error,Warning | Select-Object Source,Message,TimeGenerated | ||
} | ||
|
||
Write-Host "Running BPA on $DCServer" -ForegroundColor Green | ||
Invoke-Command -ComputerName $DCServer -ScriptBlock { | ||
$BPA = "Microsoft/Windows/DirectoryServices" | ||
Invoke-BpaModel -BestPracticesModelId $BPA | ||
Get-BpaResult -ModelID $BPA -Filter Noncompliant | Select-Object ResultNumber,Severity,Category,Title,Problem,Impact,Resolution | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<# | ||
.Synopsis | ||
Script from TechDays Sweden 2016 | ||
.DESCRIPTION | ||
Script from TechDays Sweden 2016 | ||
.NOTES | ||
Author - Mikael Nystrom | ||
Twitter: @mikael_nystrom | ||
Blog : http://deploymentbunny.com | ||
Disclaimer: | ||
This script is provided "AS IS" with no warranties, confers no rights and | ||
is not supported by the authors or Deployment Artist. | ||
.LINK | ||
http://www.deploymentbunny.com | ||
#> | ||
$DHCPServers = "SRVDC01.network.local" | ||
Foreach($DHCPServer in $DHCPServers){ | ||
Write-Host "Checking netaccess to $DCServer" -ForegroundColor Green | ||
Test-Connection -ComputerName $DCServer | ||
|
||
|
||
Invoke-Command -ComputerName $DCServer -ScriptBlock { | ||
Write-Host "Getting other DCHP/PXE Servers from $env:COMPUTERNAME" -ForegroundColor Green | ||
$DhcpServerInDCs = Get-DhcpServerInDC | ||
$DhcpServerInDCs | ||
|
||
Write-Host "Testing access to other DCHP/PXE Servers from $env:COMPUTERNAME" -ForegroundColor Green | ||
Foreach($DhcpServerInDC in $DhcpServerInDCs){ | ||
Write-Host "Testing access to $($DhcpServerInDC.IPAddress)" -ForegroundColor Green | ||
Test-NetConnection -ComputerName $DhcpServerInDC.IPAddress | ||
} | ||
} | ||
|
||
Invoke-Command -ComputerName $DCServer -ScriptBlock { | ||
Write-Host "Get all Scopes from $env:COMPUTERNAME" -ForegroundColor Green | ||
$DhcpServerv4Scopes = Get-DhcpServerv4Scope | ||
Foreach($DhcpServerv4Scope in $DhcpServerv4Scopes){ | ||
$DhcpServerv4Scope | ||
Write-Host "Percent free $(($DhcpServerv4Scope | Get-DhcpServerv4ScopeStatistics).PercentageInUse) in $($DhcpServerv4Scope.scopeid)" | ||
} | ||
} | ||
|
||
Write-Host "Running BPA on $DHCPServer" -ForegroundColor Green | ||
Invoke-Command -ComputerName $DHCPServer -ScriptBlock { | ||
$BPA = "Microsoft/Windows/DHCPServer" | ||
Invoke-BpaModel -BestPracticesModelId $BPA | ||
Get-BpaResult -ModelID $BPA -Filter Noncompliant | Select-Object ResultNumber,Severity,Category,Title,Problem,Impact,Resolution | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
Tools/Get-ReliabilityStabilityMetrics/Get-ReliabilityStabilityMetrics.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<# | ||
.Synopsis | ||
Script from TechDays Sweden 2016 | ||
.DESCRIPTION | ||
Script from TechDays Sweden 2016 | ||
.NOTES | ||
Author - Mikael Nystrom | ||
Twitter: @mikael_nystrom | ||
Blog : http://deploymentbunny.com | ||
Disclaimer: | ||
This script is provided "AS IS" with no warranties, confers no rights and | ||
is not supported by the authors or Deployment Artist. | ||
.LINK | ||
http://www.deploymentbunny.com | ||
#> | ||
Function Get-RemoteComputerSystemInfo{ | ||
param( | ||
$ComputerName | ||
) | ||
|
||
Invoke-Command -ComputerName $ComputerName -ScriptBlock { | ||
Function Get-ComputerSystemInfo{ | ||
Write-Host "Getting data from $env:COMPUTERNAME" | ||
$Index = Get-WmiObject -Class Win32_ReliabilityStabilityMetrics | Select-Object @{N="TimeGenerated"; E={$_.ConvertToDatetime($_.TimeGenerated)}},SystemStabilityIndex | Select-Object -First 1 | ||
$ComputerSystem = Get-WmiObject -Class Win32_ComputerSystem | ||
$OperatingSystem = Get-WmiObject -Class Win32_OperatingSystem | Select-Object @{N="LastBootUpTime"; E={$_.ConvertToDatetime($_.LastBootUpTime)}},Version | ||
$Plupp = [ordered]@{ | ||
ComputerName = $($env:COMPUTERNAME) | ||
Index = $([math]::Round($Index.SystemStabilityIndex)) | ||
TimeGenerated = $($Index.TimeGenerated) | ||
Make = $($ComputerSystem.Manufacturer) | ||
Model = $($ComputerSystem.Model) | ||
OSVersion = $($OperatingSystem.Version) | ||
UpTimeInDays = $([math]::round(((Get-Date) - ($OperatingSystem.LastBootUpTime)).TotalDays)) | ||
OSDiskFreeSpaceInGB = $([Math]::Round($(((Get-Volume -DriveLetter C).SizeRemaining)/1GB),2)) | ||
} | ||
New-Object PSObject -Property $Plupp | ||
} | ||
Get-ComputerSystemInfo | ||
} | ||
} | ||
|
||
#Get the servers | ||
Write-Host "Getting Server names" | ||
Import-Module "ActiveDirectory" | ||
$Computers = Get-ADComputer -LDAPFilter "(&(objectCategory=computer)(name=SRV*)(operatingSystem=Windows Server*)(!serviceprincipalname=*MSClusterVirtualServer*)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))" | ||
|
||
Write-Host "Found $($Computers.Count)" | ||
Write-Host "Check if they are online" | ||
$ComputersOnline = $Computers.DNShostname | Test-NetConnection -CommonTCPPort WINRM -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Where-Object -Property TcpTestSucceeded -EQ -Value True | ||
Write-Host "Found $($ComputersOnline.Count) that seems to be online" | ||
|
||
$TheSadTruth = Foreach($Computer in $ComputersOnline.ComputerName){ | ||
Get-RemoteComputerSystemInfo -ComputerName $Computer | ||
} | ||
|
||
$Title = "Cloud" | ||
$Head = "Cloud" | ||
$TheSadTruth | Sort-Object -Property ComputerName | ConvertTo-Html -As Table ` | ||
-Title $Title ` | ||
-Head $Head ` | ||
-Body (Get-Date -UFormat "%Y-%m-%d - %T ") ` | ||
-PreContent "<H3>Rel Index from $ENV:USERDNSDOMAIN</H3><P>Generated by Power of the Force</P>" ` | ||
-PostContent "<P>For details, contact [email protected].</P>" ` | ||
-Property ComputerName,Make,Model,OSVersion,OSDiskFreeSpaceInGB,UpTimeInDays,Index | | ||
ForEach { | ||
if($_ -like "*<td>10</td>*"){$_ -replace "<tr>", "<tr bgcolor=Lime>"} | ||
elseif($_ -like "*<td>9</td>*"){$_ -replace "<tr>", "<tr bgcolor=Lime>"} | ||
elseif($_ -like "*<td>8</td>*"){$_ -replace "<tr>", "<tr bgcolor=Lime>"} | ||
elseif($_ -like "*<td>7</td>*"){$_ -replace "<tr>", "<tr bgcolor=Aqua>"} | ||
elseif($_ -like "*<td>6</td>*"){$_ -replace "<tr>", "<tr bgcolor=Aqua>"} | ||
elseif($_ -like "*<td>5</td>*"){$_ -replace "<tr>", "<tr bgcolor=Aqua>"} | ||
elseif($_ -like "*<td>4</td>*"){$_ -replace "<tr>", "<tr bgcolor=Aqua>"} | ||
elseif($_ -like "*<td>3</td>*"){$_ -replace "<tr>", "<tr bgcolor=Yellow>"} | ||
elseif($_ -like "*<td>2</td>*"){$_ -replace "<tr>", "<tr bgcolor=Yellow>"} | ||
elseif($_ -like "*<td>1</td>*"){$_ -replace "<tr>", "<tr bgcolor=Yellow>"} | ||
elseif($_ -like "*<td>0</td>*"){$_ -replace "<tr>", "<tr bgcolor=Red>"} | ||
else{$_} | ||
} > C:\inetpub\wwwroot\default.htm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<# | ||
.Synopsis | ||
Script from TechDays Sweden 2016 | ||
.DESCRIPTION | ||
Script from TechDays Sweden 2016 | ||
.NOTES | ||
Author - Mikael Nystrom | ||
Twitter: @mikael_nystrom | ||
Blog : http://deploymentbunny.com | ||
Disclaimer: | ||
This script is provided "AS IS" with no warranties, confers no rights and | ||
is not supported by the authors or Deployment Artist. | ||
.LINK | ||
http://www.deploymentbunny.com | ||
#> | ||
$HyperVHosts = "demohost03.network.local" | ||
|
||
Foreach($HyperVHost in $HyperVHosts){ | ||
Write-Host "Checking netaccess to $HyperVHost" -ForegroundColor Green | ||
Test-Connection -ComputerName $HyperVHost | ||
|
||
Invoke-Command -ComputerName $HyperVHost -ScriptBlock { | ||
Write-Host "Base info:" -ForegroundColor Green | ||
$Win32_computersystem = Get-WmiObject -Class Win32_computersystem | ||
Write-Host "$($Win32_computersystem.Name), $($Win32_computersystem.Model), $("{0:N0}" -f ($Win32_computersystem.TotalPhysicalMemory/1GB)) GB" | ||
Get-Volume | FT | ||
Get-WmiObject -Class Win32_Processor | Select-Object Name | FT | ||
} | ||
|
||
Invoke-Command -ComputerName $HyperVHost -ScriptBlock { | ||
$VM = Get-VM | ||
|
||
Write-Host "The total number of VM's on this host is: ": -ForegroundColor Green | ||
$VM.Count | ||
|
||
Write-Host "The following VM's are running": -ForegroundColor Green | ||
$VM | Where-Object -Property State -EQ -Value Running | FT -AutoSize | ||
|
||
Write-Host "The following VM's have DiffDisks": -ForegroundColor Green | ||
$VMHardDiskDrives = $VM | Get-VMHardDiskDrive | ||
$VMsWithDiff = foreach($VMHardDiskDrive in $VMHardDiskDrives){ | ||
if($VMHardDiskDrive.Path | Get-VHD | Where-Object -Property VhdType -EQ -Value Differencing){ | ||
$VMHardDiskDrive.VMName | ||
} | ||
} | ||
$VMsWithDiff | FT -AutoSize | ||
|
||
Write-Host "The following DiffDisks are in use": -ForegroundColor Green | ||
$VMHardDiskDrives = $VM | Get-VMHardDiskDrive | ||
$DiffDisks = foreach($VMHardDiskDrive in $VMHardDiskDrives){ | ||
if($VMHardDiskDrive.Path | Get-VHD | Where-Object -Property VhdType -EQ -Value Differencing){ | ||
$VMHardDiskDrive.Path | ||
} | ||
} | ||
$DiffDisks | FT -AutoSize | ||
|
||
Write-Host "The following VM's have SnapShots": -ForegroundColor Green | ||
$VM | Get-VMSnapshot | FT -AutoSize | ||
|
||
Write-Host "Checking for NetAdapter issues": -ForegroundColor Green | ||
$VMNetworkAdapters = $VM | Get-VMNetworkAdapter | ||
$VMNetworkAdapters | Select-Object VMName,MacAddress,DynamicMacAddressEnabled,IsLegacy,SwitchName,Status,IPAddresses | FT -AutoSize | ||
|
||
Write-Host "Checking for CPU issues:" -ForegroundColor Green | ||
$VMProcessor = $VM | Get-VMProcessor | ||
$VMProcessor | Select-Object VMName,Count,CompatibilityForMigrationEnabled,CompatibilityForOlderOperatingSystemsEnabled,ExposeVirtualizationExtensions,OperationalStatus | FT -AutoSize | ||
|
||
Write-Host "Checking for Memory issues:" -ForegroundColor Green | ||
$VMMemory = $VM | Get-VMMemory | ||
$VMMemory | Select-Object VMName,DynamicMemoryEnabled,Startup, Minimum,Maximum | FT -AutoSize | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
$WSUSServers = "SRVWSUS02.network.local" | ||
Foreach($WSUSServer in $WSUSServers){ | ||
Write-Host "Checking netaccess to $WSUSServer" -ForegroundColor Green | ||
Test-Connection -ComputerName $WSUSServer | ||
|
||
Invoke-Command -ComputerName $WSUSServer -ScriptBlock { | ||
Write-Host "Base info:" -ForegroundColor Gray | ||
Get-WsusServer | Select-Object * | ||
} | ||
|
||
Invoke-Command -ComputerName $WSUSServer -ScriptBlock { | ||
$enus = 'en-US' -as [Globalization.CultureInfo] | ||
$TimeToCheck = (get-date).AddDays(-10).ToString("M/d/yyyy hh:mm tt", $enus) | ||
$ComputersWNoReport = Get-WsusComputer -All | Where-Object -Property LastReportedStatusTime -LT -Value $TimeToCheck | Select-Object FullDomainName,Make,Model,LastSyncTime | FT | ||
Write-Host "The following computers have not reported to WSUS in 10 days..." -ForegroundColor Green | ||
$ComputersWNoReport | ||
} | ||
|
||
Invoke-Command -ComputerName $WSUSServer -ScriptBlock { | ||
Write-Host "The following updates are unapproved but needed" -ForegroundColor Green | ||
Get-WsusUpdate -Approval Unapproved -Status Needed | ||
} | ||
} |
Oops, something went wrong.