-
Notifications
You must be signed in to change notification settings - Fork 7
/
Excel Report – WSUS Installation settings
44 lines (39 loc) · 1.94 KB
/
Excel Report – WSUS Installation settings
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
Param(
[Parameter(Mandatory=$True,HelpMessage="Please specify CSV file location")]
$InputFile,
[Parameter(Mandatory=$False)]
$OutPut = "$ENV:USERPROFILE\Desktop\WSUS_Configuration.CSV"
)
$ScriptBlock = {
$WSUS = Get-ItemProperty "HKLM:\Software\Microsoft\Update Services\Server\Setup"
$DObject = New-Object PSObject
$DObject | Add-Member -MemberType NoteProperty -Name "SqlDatabaseName" -Value $WSUS.SqlDatabaseName
$DObject | Add-Member -MemberType NoteProperty -Name "SqlServerName" -Value $WSUS.SqlServerName
$DObject | Add-Member -MemberType NoteProperty -Name "ContentDir" -Value $WSUS.ContentDir
$DObject | Add-Member -MemberType NoteProperty -Name "UsingSSL" -Value $WSUS.UsingSSL
$DObject | Add-Member -MemberType NoteProperty -Name "PortNumber" -Value $WSUS.PortNumber
$DObject | Add-Member -MemberType NoteProperty -Name "VersionString" -Value $WSUS.VersionString
$DObject | Add-Member -MemberType NoteProperty -Name "TargetDir" -Value $WSUS.TargetDir
$DObject | Add-Member -MemberType NoteProperty -Name "ServicePackLevel" -Value $WSUS.ServicePackLevel
$DObject | Add-Member -MemberType NoteProperty -Name "OperatingSystem" -Value (Get-WmiObject -Class Win32_OperatingSystem | Select-Object -ExpandProperty Caption)
$DObject
}
IF(Test-Path $InputFile){
$Servers = Import-Csv $InputFile
$EmptyArray = @()
foreach($item in $Servers)
{
Try{
Write-host "Processing $($item.Server) Server" -ForegroundColor Green
$Command = Invoke-Command -ScriptBlock $ScriptBlock -ComputerName $item.Server -ErrorAction STOP
$EmptyArray += $Command
}
Catch{
Write-host "Failed to Connect or WSUS not installed : $($item.Server)" -ForegroundColor RED
}
}
$EmptyArray | Export-Csv $OutPut
}
Else{
Write-Host " -- Please type correct file path ---" -ForegroundColor RED
}