Hi All
i have the following script which works and displays very nicley when ran, but is extremely messy etc… im trying to clean this up, lets start with this
$date = "09/10/2015"
Write-host
Write-host
Write-host "EURXMBS05 Updates"
Get-HotFix -ComputerName eurxmbs05 |? installedon -eq $date | Select-Object description,hotfixid,installedby,
@{l="InstalledOn";e={
[DateTime]::Parse($_.psbase.properties["installedon"].value,
$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}}
$xmbs05 = Get-HotFix -ComputerName eurxmbs05 |? installedon -eq $date |measure | Select-Object count
Write-Host
Write-host "Update Count"
Write-host $xmbs05
Write-host
Write-host "EURXMBS06 Updates"
Get-HotFix -ComputerName eurxmbs06 |? installedon -eq $date | Select-Object description,hotfixid,installedby,
@{l="InstalledOn";e={
[DateTime]::Parse($_.psbase.properties["installedon"].value,
$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}}
$xmbs06 = Get-HotFix -ComputerName eurxmbs06 |? installedon -eq $date |measure | Select-Object count
Write-Host
Write-host "Update Count"
Write-host $xmbs06
Write-host
Write-host "EURXHUB01 Updates"
Get-HotFix -ComputerName eurxhub01 |? installedon -eq $date | Select-Object description,hotfixid,installedby,
@{l="InstalledOn";e={
[DateTime]::Parse($_.psbase.properties["installedon"].value,
$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}}
$hub01 = Get-HotFix -ComputerName eurxhub01 |? installedon -eq $date |measure | Select-Object count
Write-Host
Write-host "Update Count"
Write-host $hub01
Write-host
Write-host "EURXHUB02 Updates"
Get-HotFix -ComputerName eurxhub02 |? installedon -eq $date | Select-Object description,hotfixid,installedby,
@{l="InstalledOn";e={
[DateTime]::Parse($_.psbase.properties["installedon"].value,
$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}}
$hub02 = Get-HotFix -ComputerName eurxhub02 |? installedon -eq $date |measure | Select-Object count
Write-Host
Write-host "Update Count"
Write-host $hub02
Write-host
Write-host "EURXHUB03 Updates"
Get-HotFix -ComputerName eurxhub03 |? installedon -eq $date | Select-Object description,hotfixid,installedby,
@{l="InstalledOn";e={
[DateTime]::Parse($_.psbase.properties["installedon"].value,
$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}}
$hub03 = Get-HotFix -ComputerName eurxhub03 |? installedon -eq $date | measure | Select-Object count
Write-Host
Write-host "Update Count"
Write-host $hub03
Write-host
Write-host "EURXHTS01 Updates"
Get-HotFix -ComputerName eurxhTS01 |? installedon -eq $date | Select-Object description,hotfixid,installedby,
@{l="InstalledOn";e={
[DateTime]::Parse($_.psbase.properties["installedon"].value,
$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}}
$HTS01 = Get-HotFix -ComputerName eurxhTS01 |? installedon -eq $date |measure | Select-Object count
Write-Host
Write-host "Update Count"
Write-host $hts01
Write-host
Write-host "EURXHTS02 Updates"
Get-HotFix -ComputerName eurxhTS02 |? installedon -eq $date | Select-Object description,hotfixid,installedby,
@{l="InstalledOn";e={
[DateTime]::Parse($_.psbase.properties["installedon"].value,
$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}}
$hts02 = Get-HotFix -ComputerName eurxhTS02 |? installedon -eq $date |measure | Select-Object count
Write-Host
Write-host "Update Count"
Write-host $hts02
Write-host
Write-host "EURXHTS03 Updates"
Get-HotFix -ComputerName eurxhTS03 |? installedon -eq $date | Select-Object description,hotfixid,installedby,
@{l="InstalledOn";e={
[DateTime]::Parse($_.psbase.properties["installedon"].value,
$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}}
$HTS03 = Get-HotFix -ComputerName eurxhTS03 |? installedon -eq $date |measure | Select-Object count
Write-Host
Write-host "Update Count"
Write-host $hts03
Write-host
Write-host "EURXCASL1 Updates"
Get-HotFix -ComputerName eurxCASl1 |? installedon -eq $date | Select-Object description,hotfixid,installedby,
@{l="InstalledOn";e={
[DateTime]::Parse($_.psbase.properties["installedon"].value,
$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}}
$Casl1 = Get-HotFix -ComputerName eurxCASl1 |? installedon -eq $date |measure | Select-Object count
Write-Host
Write-host "Update Count"
Write-host $CASl1
Write-host
Write-host "EURXCASL2 Updates"
Get-HotFix -ComputerName eurxCASl2 |? installedon -eq $date | Select-Object description,hotfixid,installedby,
@{l="InstalledOn";e={
[DateTime]::Parse($_.psbase.properties["installedon"].value,
$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}}
$Casl2 = Get-HotFix -ComputerName eurxCASl2 |? installedon -eq $date |measure | Select-Object count
Write-Host
Write-host "Update Count"
Write-host $CASl2
Write-host
i am trying the below but not getting the results i want
#Get Machines by role
$cas = Get-QADComputer -LdapFilter '(Name=eurxca*)' | select name
$hub = Get-QADComputer -LdapFilter '(Name=eurxhu*)' | select name
$hts = Get-QADComputer -LdapFilter '(Name=eurxht*)' | select name
$Active05 = Get-QADComputer -LdapFilter '(Name=eurxmbs05)' | select name
$Active06 = Get-QADComputer -LdapFilter '(Name=eurxmbs05)' | select name
$pub = Get-QADComputer -LdapFilter '(Name=eurxpub*)' | select name
# Combine the Above
$Machines = $cas,$hub,$hts,$Active05,$Active06,$pub
#UK Date Prefix
$date = "18/12/2015"
$machines | ForEach-Object {
Get-HotFix |? installedon -eq $date | Select-Object description,hotfixid,installedby,
@{l="InstalledOn";e={
[DateTime]::Parse($_.psbase.properties["installedon"].value,
$([System.Globalization.CultureInfo]::GetCultureInfo("en-US")))}}
Get-HotFix |? installedon -eq $date |measure | Select-Object count
}
the output i would like to be in the below format is a list of the updates etc… and a count at the bottom, i also had problems adding the count in a single command hence running it twice