Intune Initial Scripts Backup

This commit is contained in:
2025-04-21 14:21:38 -04:00
commit 71764cd10f
241 changed files with 28218 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
#import correct file
#Uncomment Restart-Computer
$Dte = Get-Date -UFormat %m-%d-%Y
#########################################################################################
#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt
$WSUSGroup = "Tier0"
$Current_Month = (Get-Date -UFormat %B)
$Current_Year = (Get-Date -UFormat %Y)
#$WSUSGroup = Read-Host "Enter Target Group Name"
$Folder = "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year"
$Group_Folder = "$Folder\$WSUSGroup-$Current_Month-PENDING-Reboot"
$Pending_Reboot_File_Name = "$Group_Folder\$WSUSGroup-PENDING-Reboots-$Current_Month"
#If(!(Test-Path E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching)) { New-Item -Path "E:\WSUS_Scripts\Patching-Day" -ItemType Directory -Name $WSUSGroup-$Current_Month-Patching }
#########################################################################################
#$Server_Reboot_Before_Patching = Import-Csv "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$Group_Folder\$Pending_Reboot_File_Name.csv" | ? { $_.RebootPending -eq "True" } | select computer
#$Server_Reboot_Before_Patching | Export-Csv "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$Group_Folder\$WSUSGroup-Servers-Rebooting-Before-Patching-$Dte.csv" -NoTypeInformation
$Server_Reboot_Before_Patching = Import-Csv "$Pending_Reboot_File_Name.csv" | ? { $_.RebootPending -eq "True" } | select computer
Write-Host "$WSUSGroup - Server Count: $($Server_Reboot_Before_Patching.count)" -ForegroundColor Yellow
$Server_Reboot_Before_Patching.Computer | % {
#Write-EventLog -LogName System -Source "Powershell-WSUS-Reboot-Before-Patching" -EntryType Information -EventId 7893 -Message "Reboot-Before-Patching-Remote" -ErrorAction SilentlyContinue
#Invoke-Command $_ -ErrorAction SilentlyContinue {
# New-EventLog -LogName System -Source "Reboot-Before-Patching" -ErrorAction SilentlyContinue
# Write-EventLog -LogName System -Source "Reboot-Before-Patching" -EntryType Information -EventId 7893 -Message "Reboot-Before-Patching-Invoke" -ErrorAction SilentlyContinue
#}#endInvoke
Write-Host "Rebooting --- $_"
xRestart-Computer $_ -Force -Verbose
}#end%
##############################################################################################################################
<#
$Server_Reboot_Before_Patching.computer | % { $T = Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue
If($T) { Write-Host "Server $_ -- Responding" -ForegroundColor Green } Else { Write-Host "Server $_ -- Not Responding" -ForegroundColor Red }
}
$Server_Reboot_Before_Patching.computer | % { gwmi win32_operatingsystem -ComputerName $_ | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}}
#>

View File

@@ -0,0 +1,102 @@
#################################################################################################################################
If(Test-Path E:\WSUS_Scripts\Lock_Script.txt) {
Write-Host "The Script is locked for protection. If you are not running it by mistake - Delete the file (E:\WSUS_Scripts\Lock_Script.txt) and run the Script again" -ForegroundColor Yellow
Break
}
Else { New-Item -Path E:\WSUS_Scripts -Name Lock_Script.txt -ItemType File }
#################################################################################################################################
Get-Job | Remove-Job
#$Location = Split-Path $MyInvocation.MyCommand.Path -Parent
############################################################
#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt
$Current_Month = (Get-Date -UFormat %B)
$Current_Year = (Get-Date -UFormat %Y)
############################################################
$Dte = Get-Date -UFormat %m-%d-%Y
$Collect_Jobs = @()
$Patch_Job = @()
$Failed_Jobs = @()
$Receive_Jobs = @()
$servers = ""
$WSUSGroup = "xxx" #Read-Host "Enter Target Group Name"
If(!(Test-Path E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching)) { New-Item -Path "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year" -ItemType Directory -Name $WSUSGroup-$Current_Month-Patching }
#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select -ExpandProperty Fulldomainname
$Group_Folder = "$WSUSGroup-$Current_Month-Patching"
$Group_Folder_Location = "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$Group_Folder"
#$Servers_Reboot_Only = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\CCXQ1-November-Prep-Files\Manual-$WSUSGroup-OperatingSystems-$Current_Month.csv
#$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup.csv | select -ExpandProperty "Server Name"
$servers = Import-Csv $Group_Folder_Location\$WSUSGroup.csv | select -ExpandProperty "Computer"
####$servers = $servers | ? { $_ -notin $Servers_Reboot_Only.FullDomainName }
#$servers | Out-File $Location\Patching-Day\$Current_Month-2019\$Group_Folder\$WSUSGroup-Patching-Today-$Dte.txt
$servers | Out-File $Group_Folder_Location\$WSUSGroup-Patching-Today-Backup-$Dte.txt
xxxForeach ($server in $servers) {
#New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -ComputerName $server -verbose
#New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -ComputerName $server -verbose
#New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -ComputerName $server -verbose
#Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Remote" -ComputerName $server -ErrorAction SilentlyContinue -verbose
$Patch_Job += xxxStart-Job -ScriptBlock { Param($server) WindowsUpdate\Install-WindowsUpdate -ComputerName $server } -Name "$WSUSGroup-#$server#-Patching" -ArgumentList $server
#Invoke-Command $server -ErrorAction SilentlyContinue {
# New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -verbose
# New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -verbose
# New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -verbose
# Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Invoke" -verbose
# }#endInvoke
}#endForeach
#$Patch_Job | Export-Csv $Location\Patching-Day\$Current_Month-2019\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte.csv -NoTypeInformation
$Patch_Job | Export-Csv $Group_Folder_Location\$WSUSGroup-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
#$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\$Current_Month-2019\$Group_Folder\$WSUSGroup-Collect-Patching-Jobs-$Dte.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv $Group_Folder_Location\$WSUSGroup-Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
#$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\$Group_Folder\$Current_Month-2019\$WSUSGroup-Jobs-ChildJobs-$Dte.csv -NoTypeInformation
$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Group_Folder_Location\$WSUSGroup-Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation
Get-Job
<#
$Failed_Jobs += $Patch_Job | ? { $_.State -eq "Failed" }
$Failed_Jobs | ft -autosize
$Failed_Jobs | Export-Csv "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching\failed-jobs.csv" -NoTypeInformation
#>
### Running Count
# $Patch_Job
<#
$Patch_Job | ft -AutoSize
( $Patch_Job | ? { $_.State -eq "Running" } ).count
( $Patch_Job | ? { $_.State -eq "Completed" } ).count
( $Patch_Job | ? { $_.State -eq "Failed" } ).count
$Patch_Job | ? { $_.State -eq "Running" } | export-csv $Group_Folder_Location\jobs-running.csv
$T = import-csv $Group_Folder_Location\jobs-running.csv
$T = $T | % {$_.Name.Split('#')[1] }
#>

View File

@@ -0,0 +1,61 @@
###### This Script must be run after the patching is in progress ####################
$File_Date = Get-Date -UFormat %H-%M-%p
$Current_Month = (Get-Date -UFormat %B)
$Current_Year = (Get-Date -UFormat %Y)
If(!(Test-Path "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching\ReRun")) { New-Item -Path "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching\ReRun" -ItemType Directory }
$Collect_Completed_Servers = @()
$Collect_Completed_Jobs = ""
$WSUSGroup = ""
$WSUSGroup = Read-Host "Enter Target Group Name"
$Collect_Completed_Jobs = $Patch_Job
$Patch_Job = $Patch_Job | ? { $_.State -ne "Completed" }
$Failed_Jobs = $Patch_Job | ? { $_.State -eq "Failed" }
$Collect_Completed_Jobs | % {
$Obj = New-Object -TypeName PSObject
$Obj | Add-Member -MemberType NoteProperty -Name Server -Value ($_.Name.Split('#')[1])
$Obj | Add-Member -MemberType NoteProperty -Name State -Value $_.State
$Obj
}
$TPJ = $Obj
#If(!(Test-Path "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching\ReRun")) { New-Item -Path "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching\ReRun" -ItemType Directory }
$Patch_Job | Export-Csv "$ReRun_File_Location\$WSUSGroup-Completed-Jobs-$File_Date.csv" -NoTypeInformation
$ReRun_File_Location = "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching\ReRun"
#$TPJ | Export-Csv "$ReRun_File_Location\$WSUSGroup-Completed-Jobs-$File_Date.csv" -NoTypeInformation
$Failed_Jobs | Export-Csv "$ReRun_File_Location\$WSUSGroup-FAILED-Jobs-$File_Date.csv" -NoTypeInformation
#$Unique_Servers = $Collect_Completed_Servers | select Name -Unique
#$temp = Import-Csv "E:\WSUS_Scripts\Patching-Day\November-2019\NCRA - Development Servers-November-Patching\test--NCRA - Development Servers-Patching-Jobs-11-01-2019 - Copy.csv"
#$Collect_Completed_Servers = $Collect_Completed_Jobs.Name | % {$_.Split('#')[1] }
###################################### Reboot Servers ##########################
Restart-Computer -ComputerName $TPJ.Server -Force -Verbose
################################################################################
<#
$servers | % { $T = Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue
If($T) { Write-Host "Server $_ -- Responding" -ForegroundColor Green } Else { Write-Host "Server $_ -- Not Responding" -ForegroundColor Red }
}
#>
# $Servers | % { gwmi win32_operatingsystem -ComputerName $_ | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}}

View File

@@ -0,0 +1,96 @@
#################################################################################################################################
#$ErrorActionPreference = "Ignore"
#$servers = "W2012A","W2012B","slfkjsdl"
#$WSUSGroup = "Test GGroupppppp"
#$Location = Split-Path $MyInvocation.MyCommand.Path -Parent
#################################################################################################################################
If(Test-Path E:\WSUS_Scripts\Patching-Day\December-2019\Lock_Script.txt) {
Write-Host "The Script is locked for protection. If you are not running it by mistake - Delete the file (E:\WSUS_Scripts\Patching-Day\December-2019\Lock_Script.txt) and run the Script again" -ForegroundColor Yellow
Break
}
Else { New-Item -Path E:\WSUS_Scripts\Patching-Day\December-2019 -Name Lock_Script.txt -ItemType File }
#################################################################################################################################
############################################################
#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt
$Current_Month = (Get-Date -UFormat %B)
$Current_Year = (Get-Date -UFormat %Y)
############################################################
$Dte = Get-Date -UFormat %m-%d-%Y
$Collect_Jobs = @()
$Patch_Job = @()
$Failed_Jobs = @()
$Receive_Jobs = @()
#If(!(Test-Path E:\WSUS_Scripts\Patching-Day\$WSUSGroup-$Current_Month-Patching)) { New-Item -Path "E:\WSUS_Scripts\Patching-Day" -ItemType Directory -Name $WSUSGroup-$Current_Month-Patching }
$servers = ""
$WSUSGroup = Read-Host "Enter Target Group Name"
$ReRun_File_Location = "E:\WSUS_Scripts\Patching-Day\$Current_Month-$Current_Year\$WSUSGroup-$Current_Month-Patching\ReRun"
#$Group_Folder = "$WSUSGroup-$Current_Month-Patching"
$Recent_File = gci $ReRun_File_Location | sort LastWriteTime -Descending | select -First 1 | Select FullName
$servers = Import-Csv $Recent_File.FullName | select -ExpandProperty Server
#$servers | Out-File $Location\Patching-Day\$Current_Month-$Current_Year\$Group_Folder\$WSUSGroup-Patching-Today-$Dte.txt
#$servers | Out-File $ReRun_File_Location\$WSUSGroup-Patching-Today-Backup-$Dte.txt
Foreach ($server in $servers) {
New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -ComputerName $server -verbose
New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -ComputerName $server -verbose
New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -ComputerName $server -verbose
Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Remote" -ComputerName $server -ErrorAction SilentlyContinue -verbose
$Patch_Job_ReRun += Start-Job -ScriptBlock { Param($server) WindowsUpdate\Install-WindowsUpdate -ComputerName $server } -Name "ReRun-$WSUSGroup-#$server#-Patching" -ArgumentList $server
Invoke-Command $server -ErrorAction SilentlyContinue {
New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -verbose
New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -verbose
New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -verbose
Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Invoke" -verbose
}#endInvoke
}#endForeach
#Get-Job
#$Patch_Job_ReRun | Export-Csv $Location\Patching-Day\$Current_Month-$Current_Year\$Group_Folder\ReRun-$WSUSGroup-Patching-Jobs-$Dte.csv -NoTypeInformation
$Patch_Job_ReRun | Export-Csv $ReRun_File_Location\ReRun-$WSUSGroup-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
#$Collect_Jobs_ReRun = Get-Job | Export-Csv $Location\Patching-Day\$Current_Month-$Current_Year\$Group_Folder\ReRun-$WSUSGroup-Collect-Patching-Jobs-$Dte.csv -NoTypeInformation
$Collect_Jobs_ReRun = Get-Job | Export-Csv $ReRun_File_Location\ReRun-$WSUSGroup-Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
#$Patch_Job_ReRun | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\$Current_Month-$Current_Year\$Group_Folder\ReRun-$WSUSGroup-Jobs-ChildJobs-$Dte.csv -NoTypeInformation
$Patch_Job_ReRun | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $ReRun_File_Location\ReRun-$WSUSGroup-Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation
#################### Reboot Servers ########################
# Restart-Computer -ComputerName $servers -Verbose
############################################################
<#
$Failed_Jobs += $Patch_Job | ? { $_.State -eq "Failed" }
$Failed_Jobs | ft -autosize
$Failed_Jobs | Export-Csv "E:\WSUS_Scripts\Patching-Day\NCRA - Quality Assurance Servers-November-Patching\failed-jobs.csv" -NoTypeInformation
#>
### Running Count
## ( $Patch_Job | ? { $_.State -eq "Running" } ).count
## ( $Patch_Job | ? { $_.State -eq "Completed" } ).count
## ( $Patch_Job | ? { $_.State -eq "Failed" } ).count
#>

View File

@@ -0,0 +1,67 @@

$Location = Split-Path $MyInvocation.MyCommand.Path -Parent
#################################################################################################################################
$Dte = Get-Date -UFormat %m-%d-%Y
$Current_Month = (Get-Date -UFormat %B)
#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt
#$Group_Folder = "$WSUSGroup-$Current_Month-Patching"
#$Group = "NCRA - Development Servers"
#################################################################################################################################
$servers = ""
$WSUSGroup = Read-Host "Enter Target Group Name"
#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
$Group_Folder = "$WSUSGroup-$Current_Month-Patching"
#$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\December-2019\$Group_Folder\CCXQ1-November-Prep-Files\$WSUSGroup-Target-Group-Computers-$Current_Month.csv | select -ExpandProperty FullDomainName
$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\December-2019\$WSUSGroup.csv | select -ExpandProperty "Server Name"
#$servers | Out-File $Location\Patching-Day\$Group_Folder\$WSUSGroup-Servers-Rebooting-$Dte.txt -ErrorAction SilentlyContinue
$servers | Out-File E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Servers-Rebooting-Backup-$Dte.txt -ErrorAction SilentlyContinue
#$servers = $servers | ? { $_ -ne "qadf001.ccx.carecentrix.com"}
#$Patch_Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue
$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue
Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Get-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue
Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Get-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue
#$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Collect-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Collect-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation
Foreach ($server in $servers) {
Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Remote" -ComputerName $server -ErrorAction SilentlyContinue
Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Remote" -ComputerName $server -ErrorAction SilentlyContinue
Invoke-Command $server -ErrorAction SilentlyContinue {
#New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Finished" -ErrorAction SilentlyContinue
#New-EventLog -LogName System -Source "Powershell-Reboot-After-Patching" -ErrorAction SilentlyContinue
Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Invoke" -ErrorAction SilentlyContinue
Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Invoke" -ErrorAction SilentlyContinue
}#endInvoke
Restart-Computer -ComputerName $server -Force -Verbose
}#endForeach
<#
$servers | % { $T = Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue
If($T) { Write-Host "Server $_ -- Responding" -ForegroundColor Green } Else { Write-Host "Server $_ -- Not Responding" -ForegroundColor Red }
}
#>
# $Servers | % { Get-EventLog -LogName System -ComputerName $_.computer | ? { $_.EventID -eq '7893' } }
# $Servers | % { gwmi win32_operatingsystem -ComputerName $_ | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}}

View File

@@ -0,0 +1,70 @@
<#
$ErrorActionPreference = "Ignore"
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob}
#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below.
#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}}
#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group"
Read-Host -Prompt "Press Enter to exit"
#>
#################################################################################################################################
#$ErrorActionPreference = "Ignore"
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
#$servers = "W2012A","W2012B","slfkjsdl"
#$WSUSGroup = "Test GGroupppppp"
$Location = Split-Path $MyInvocation.MyCommand.Path -Parent
$Dte = Get-Date -UFormat %m-%d-%Y
$Collect_Jobs = @()
$Patch_Job = @()
$servers | Out-File $Location\Patching-Day\"$WSUSGroup"-Server-Patching-Today-$Dte.txt
$servers | Out-File E:\WSUS_Scripts\Patching-Day\"$WSUSGroup"-Server-Patching-Today-Backup-$Dte.txt
Foreach ($server in $servers) {
New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -ComputerName $server
New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -ComputerName $server
New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -ComputerName $server
Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Remote" -ComputerName $server -ErrorAction SilentlyContinue
$Patch_Job += Start-Job -ScriptBlock { Param($server) Install-WindowsUpdate -ComputerName $server } -Name "$server-Patching" -ArgumentList $server
Invoke-Command $server -ErrorAction SilentlyContinue {
New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue
New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue
New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue
Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Invoke"
}#endInvoke
Install-WindowsUpdate -ComputerName $server -AsJob
}#endForeach
Get-Job
$Patch_Job | Export-Csv $Location\Patching-Day\Patching-Jobs-$Dte.csv -NoTypeInformation
$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\Collect-Patching-Jobs-$Dte.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\Jobs-ChildJobs-$Dte.csv -NoTypeInformation
$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv E:\WSUS_Scripts\Patching-Day\Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation

View File

@@ -0,0 +1,29 @@
$Location = Split-Path $MyInvocation.MyCommand.Path -Parent
$Dte = Get-Date -UFormat %m-%d-%Y
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
$servers | Out-File $Location\Patching-Day\"$WSUSGroup"-Servers-Rebooting-$Dte.txt -ErrorAction SilentlyContinue
$servers | Out-File E:\WSUS_Scripts\Patching-Day\"$WSUSGroup"-Servers-Rebooting-Backup-$Dte.txt -ErrorAction SilentlyContinue
$Patch_Job | Export-Csv $Location\Patching-Day\Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue
$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue
Get-Job | Export-Csv $Location\Patching-Day\Patching-Get-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue
Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Get-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue
$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\Patching-Collect-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Collect-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation
Foreach ($server in $servers) {
Invoke-Command $server -ErrorAction SilentlyContinue {
#New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Finished" -ErrorAction SilentlyContinue
#New-EventLog -LogName System -Source "Powershell-Reboot-After-Patching" -ErrorAction SilentlyContinue
Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished"
Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching"
}#endInvoke
Restart-Computer -ComputerName $server -Force -Verbose
}#endForeach

View File

@@ -0,0 +1,32 @@
$Location = Split-Path $MyInvocation.MyCommand.Path -Parent
$Dte = Get-Date -UFormat %m-%d-%Y
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
$servers | Out-File $Location\Patching-Day\"$WSUSGroup"-Servers-Rebooting-$Dte.txt -ErrorAction SilentlyContinue
$servers | Out-File E:\WSUS_Scripts\Patching-Day\"$WSUSGroup"-Servers-Rebooting-Backup-$Dte.txt -ErrorAction SilentlyContinue
$Patch_Job | Export-Csv $Location\Patching-Day\Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue
$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue
Get-Job | Export-Csv $Location\Patching-Day\Patching-Get-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue
Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Get-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue
$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\Patching-Collect-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Collect-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation
Foreach ($server in $servers) {
Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Remote" -ComputerName $server -ErrorAction SilentlyContinue
Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Remote" -ComputerName $server -ErrorAction SilentlyContinue
Invoke-Command $server -ErrorAction SilentlyContinue {
#New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Finished" -ErrorAction SilentlyContinue
#New-EventLog -LogName System -Source "Powershell-Reboot-After-Patching" -ErrorAction SilentlyContinue
Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Invoke" -ErrorAction SilentlyContinue
Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Invoke" -ErrorAction SilentlyContinue
}#endInvoke
Restart-Computer -ComputerName $server -Force -Verbose
}#endForeach

View File

@@ -0,0 +1,15 @@
#import correct file
#Uncomment Restart-Computer
$Server_Reboot_Before_Patching = Import-Csv E:\WSUS_Scripts\Files\PENDING-Reboots-10-08-2019.csv | ? { $_.RebootPending -eq "True" } | select computer
$Server_Reboot_Before_Patching.Computer | % {
Write-EventLog -LogName System -Source "Powershell-WSUS-Reboot-Before-Patching" -EntryType Information -EventId 7893 -Message "Reboot-Before-Patching-Remote" -ErrorAction SilentlyContinue
Invoke-Command $_ -ErrorAction SilentlyContinue {
New-EventLog -LogName System -Source "Reboot-Before-Patching" -ErrorAction SilentlyContinue
Write-EventLog -LogName System -Source "Reboot-Before-Patching" -EntryType Information -EventId 7893 -Message "Reboot-Before-Patching-Invoke" -ErrorAction SilentlyContinue
}#endInvoke
Restart-Computer $_ -Force -Verbose
}#end%

View File

@@ -0,0 +1,4 @@

$ServerName | % { Get-HotFix -ComputerName $_ | sort installedon -Descending | select -First 1 }

View File

@@ -0,0 +1,8 @@
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Target-Group-Computers-$Current_Month.csv | select -ExpandProperty FullDomainName
$servers | % { Get-HotFix -ComputerName $_ | ? { $_.InstalledOn} | sort installedon -Descending | select -First 1 }

View File

@@ -0,0 +1,32 @@
$Check_Jobs = Import-Csv "E:\WSUS_Scripts\Patching-Day\December-2019\Tier2B-December-Patching\ReRun\Tier2B-FAILED-Jobs-22-01-PM.csv" | select @{n="Server";e={$_.Name.split('#')[1]}},State,PSBeginTime
##$Completed_Jobs = $Check_Jobs | ? { $_.State -eq "Completed" }
##$Failed_Jobs = $Check_Jobs | ? { $_.State -eq "Failed" }
#$P_Job_Servers = @()
##### Reboot Completed Ones and Run patching again #####
#Restart-Computer $Completed_Jobs.Server -Force -Verbose
Foreach ($S in $Completed_Jobs.Server) {
#$S = $T.name
#$P_Job_Servers += Start-Job -ScriptBlock { Param($S) WindowsUpdate\Install-WindowsUpdate -ComputerName $S } -Name "$WSUSGroup-#$S#-Patching" -ArgumentList $S
}#endForeach
<#
$Tier2B_Servers."Server Name" | % { $T = Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue
If($T) { Write-Host "Server $_ -- Responding" -ForegroundColor Green } Else { Write-Host "Server $_ -- Not Responding" -ForegroundColor Red }
}
#######################################################################################################
$Tier2B_Servers."Server Name" | % { gwmi win32_operatingsystem -ComputerName $_ | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}} | ft -autosize
#>

View File

@@ -0,0 +1,60 @@
"Computer","CBServicing","WindowsUpdate","CCMClientSDK","PendComputerRename","PendFileRename","PendFileRenVal","RebootPending"
"DAPP006","True","True",,"False","True","System.String[]","True"
"DSQL001","False","False",,"False","False",,"False"
"DAPP012","True","True",,"False","True","System.String[]","True"
"DIIS004",,"False",,"False","True","System.String[]","True"
"DSQL002","False","False",,"False","False",,"False"
"DWHD001","False","False",,"False","False",,"False"
"DEDI001","False","False",,"False","False",,"False"
"DOWA001","False","False",,"False","True","System.String[]","True"
"DSWF001","False","False",,"False","False",,"False"
"DSAP001","False","False",,"False","True","System.String[]","True"
"DSQL009","False","False",,"False","True","System.String[]","True"
"DFNP009","True","True",,"False","False",,"True"
"DDOC001","True","True",,"False","False",,"True"
"DCPR001","False","False",,"False","False",,"False"
"DTABL001","False","False",,"False","True","System.String[]","True"
"DBTS001","False","False",,"False","False",,"False"
"DPGP001","False","False",,"False","False",,"False"
"DSSS001","False","False",,"False","True","System.String[]","True"
"DAPP001",,"False",,"False","True","System.String[]","True"
"DBIT901","True","True",,"False","True","System.String[]","True"
"DFNP002","True","True",,"False","False",,"True"
"DDWH001","False","False",,"False","False",,"False"
"DVRS001","True","True",,"False","False",,"True"
"DSHP001","False","False",,"False","False",,"False"
"DWHD003","False","False",,"False","True","System.String[]","True"
"DSRS001","False","False",,"False","True","System.String[]","True"
"DWTS001","False","False",,"False","False",,"False"
"DAPP003",,"False",,"False","True","System.String[]","True"
"DWAM002","True","True",,"False","True","System.String[]","True"
"DFNP001","True","True",,"False","True","System.String[]","True"
"DSIS001","False","False",,"False","False",,"False"
"DIIS003","False","False",,"False","True","System.String[]","True"
"DVB6001","True","True",,"False","True","System.String[]","True"
"DSQL006","False","False",,"False","False",,"False"
"DCTI001","True","True",,"False","True","System.String[]","True"
"DIIS002",,"False",,"False","True","System.String[]","True"
"DFNP020","True","True",,"False","True","System.String[]","True"
"DFNP014","True","True",,"False","False",,"True"
"DIAP001","True","True",,"False","True","System.String[]","True"
"DSQL027B","False","False",,"False","True","System.String[]","True"
"DSQL027A","False","False",,"False","True","System.String[]","True"
"DVVC004","True","True",,"False","True","System.String[]","True"
"DVCO001","True","True",,"False","True","System.String[]","True"
"DVVC003","True","True",,"False","True","System.String[]","True"
"DEDI113","False","False",,"False","True","System.String[]","True"
"DSQL000","False","False",,"False","True","System.String[]","True"
"DSQL028","False","False",,"False","True","System.String[]","True"
"DSIS003","False","False",,"False","False",,"False"
"DFAX011","False","False",,"False","True","System.String[]","True"
"DMQS001","False","False",,"False","True","System.String[]","True"
"DGAW001","False","False",,"False","True","System.String[]","True"
"DSQL004","False","False",,"False","True","System.String[]","True"
"DSQL029","False","False",,"False","True","System.String[]","True"
"DSQL030","False","False",,"False","True","System.String[]","True"
"DAPCAC001","False","False",,"False","True","System.String[]","True"
"DAPCAV001","False","False",,"False","True","System.String[]","True"
"DAPCAC002","False","False",,"False","False",,"False"
"DAPVRNS001","False","False",,"False","True","System.String[]","True"
"DAPSEP001","False","False",,"False","True","System.String[]","True"
1 Computer CBServicing WindowsUpdate CCMClientSDK PendComputerRename PendFileRename PendFileRenVal RebootPending
2 DAPP006 True True False True System.String[] True
3 DSQL001 False False False False False
4 DAPP012 True True False True System.String[] True
5 DIIS004 False False True System.String[] True
6 DSQL002 False False False False False
7 DWHD001 False False False False False
8 DEDI001 False False False False False
9 DOWA001 False False False True System.String[] True
10 DSWF001 False False False False False
11 DSAP001 False False False True System.String[] True
12 DSQL009 False False False True System.String[] True
13 DFNP009 True True False False True
14 DDOC001 True True False False True
15 DCPR001 False False False False False
16 DTABL001 False False False True System.String[] True
17 DBTS001 False False False False False
18 DPGP001 False False False False False
19 DSSS001 False False False True System.String[] True
20 DAPP001 False False True System.String[] True
21 DBIT901 True True False True System.String[] True
22 DFNP002 True True False False True
23 DDWH001 False False False False False
24 DVRS001 True True False False True
25 DSHP001 False False False False False
26 DWHD003 False False False True System.String[] True
27 DSRS001 False False False True System.String[] True
28 DWTS001 False False False False False
29 DAPP003 False False True System.String[] True
30 DWAM002 True True False True System.String[] True
31 DFNP001 True True False True System.String[] True
32 DSIS001 False False False False False
33 DIIS003 False False False True System.String[] True
34 DVB6001 True True False True System.String[] True
35 DSQL006 False False False False False
36 DCTI001 True True False True System.String[] True
37 DIIS002 False False True System.String[] True
38 DFNP020 True True False True System.String[] True
39 DFNP014 True True False False True
40 DIAP001 True True False True System.String[] True
41 DSQL027B False False False True System.String[] True
42 DSQL027A False False False True System.String[] True
43 DVVC004 True True False True System.String[] True
44 DVCO001 True True False True System.String[] True
45 DVVC003 True True False True System.String[] True
46 DEDI113 False False False True System.String[] True
47 DSQL000 False False False True System.String[] True
48 DSQL028 False False False True System.String[] True
49 DSIS003 False False False False False
50 DFAX011 False False False True System.String[] True
51 DMQS001 False False False True System.String[] True
52 DGAW001 False False False True System.String[] True
53 DSQL004 False False False True System.String[] True
54 DSQL029 False False False True System.String[] True
55 DSQL030 False False False True System.String[] True
56 DAPCAC001 False False False True System.String[] True
57 DAPCAV001 False False False True System.String[] True
58 DAPCAC002 False False False False False
59 DAPVRNS001 False False False True System.String[] True
60 DAPSEP001 False False False True System.String[] True

View File

@@ -0,0 +1,91 @@
"Computer","CBServicing","WindowsUpdate","CCMClientSDK","PendComputerRename","PendFileRename","PendFileRenVal","RebootPending"
"Q1FNP003","False","False",,"False","False",,"False"
"Q1SQL022","False","False",,"False","True","System.String[]","True"
"Q1SQL024","False","False",,"False","True","System.String[]","True"
"Q2FNP003","False","False",,"False","False",,"False"
"Q2SQL022","False","False",,"False","True","System.String[]","True"
"Q3FNP003","False","False",,"False","False",,"False"
"Q3SQL022","False","False",,"False","True","System.String[]","True"
"Q4FNP003","False","False",,"False","False",,"False"
"Q4SQL022","False","False",,"False","True","System.String[]","True"
"Q4SQL022B","False","False",,"False","True","System.String[]","True"
"Q4SQL024","False","False",,"False","True","System.String[]","True"
"Q5FNP003","False","False",,"False","False",,"False"
"Q5SQL022","False","False",,"False","True","System.String[]","True"
"QADF001","False","False",,"False","True","System.String[]","True"
"QAPP011","False","False",,"False","True","System.String[]","True"
"QAPP021","False","False",,"False","True","System.String[]","True"
"QAPP031","False","False",,"False","True","System.String[]","True"
"QAPP041","False","False",,"False","True","System.String[]","True"
"QAPP051","False","False",,"False","True","System.String[]","True"
"QBIZ111","False","False",,"False","True","System.String[]","True"
"QBIZ112","False","False",,"False","True","System.String[]","True"
"QBIZ121","True","True",,"False","True","System.String[]","True"
"QBIZ122","False","False",,"False","True","System.String[]","True"
"QBIZ131","False","False",,"False","True","System.String[]","True"
"QBIZ132","False","False",,"False","True","System.String[]","True"
"QBIZ141","False","False",,"False","True","System.String[]","True"
"QBIZ142","False","False",,"False","True","System.String[]","True"
"QBIZ151","False","False",,"False","True","System.String[]","True"
"QBIZ152","False","False",,"False","True","System.String[]","True"
"QCMX001","False","False",,"False","True","System.String[]","True"
"QDRF001","False","False",,"False","True","System.String[]","True"
"QEDI111","False","False",,"False","True","System.String[]","True"
"QEDI112","False","False",,"False","True","System.String[]","True"
"QEDI113","False","False",,"False","True","System.String[]","True"
"QEDI151","False","False",,"False","True","System.String[]","True"
"QEDI152","False","False",,"False","True","System.String[]","True"
"QEDI153","False","False",,"False","True","System.String[]","True"
"QFNP001","False","False",,"False","True","System.String[]","True"
"QFNP003","False","False",,"False","True","System.String[]","True"
"QFNP007","False","False",,"False","True","System.String[]","True"
"QFNP008","False","False",,"False","False",,"False"
"QFNP009","False","False",,"False","False",,"False"
"QIIS005","False","False",,"False","True","System.String[]","True"
"QMFT001","False","False",,"False","True","System.String[]","True"
"QMHB001","False","False",,"False","True","System.String[]","True"
"QMHB002","False","False",,"False","True","System.String[]","True"
"QMHB003","False","False",,"False","True","System.String[]","True"
"QMHB004","False","False",,"False","True","System.String[]","True"
"QNCRASPAPP01","False","False",,"False","False",,"False"
"QNCRASPAPP02","False","False",,"False","False",,"False"
"QNCRASPDC01","False","False",,"False","False",,"False"
"QNCRASPDC02","False","False",,"False","False",,"False"
"QNCRASPOWA01","False","False",,"False","True","System.String[]","True"
"QNCRASPSEA01","False","False",,"False","False",,"False"
"QNCRASPSEA02","False","False",,"False","False",,"False"
"QNCRASPWFE01","False","False",,"False","False",,"False"
"QNCRASPWFE02","False","False",,"False","False",,"False"
"QQATEST01","False","False",,"False","True","System.String[]","True"
"QRDS001","False","False",,"False","True","System.String[]","True"
"QRDS002","False","False",,"False","True","System.String[]","True"
"QRSH001","False","False",,"False","True","System.String[]","True"
"QRSH002","False","False",,"False","True","System.String[]","True"
"QRSH021","False","False",,"False","True","System.String[]","True"
"QRSH022","False","False",,"False","True","System.String[]","True"
"QRSH023","False","False",,"False","True","System.String[]","True"
"QRSH031","False","False",,"False","True","System.String[]","True"
"QRSH041","False","False",,"False","False",,"False"
"QRSH051","False","False",,"False","True","System.String[]","True"
"QRSH101","False","False",,"False","True","System.String[]","True"
"QRSH111","False","False",,"False","True","System.String[]","True"
"QRSH112","False","False",,"False","False",,"False"
"QSCH011","False","False",,"False","False",,"False"
"QSCH012","False","False",,"False","False",,"False"
"QSCH013","False","False",,"False","False",,"False"
"QSCH014","False","False",,"False","False",,"False"
"QSIS001","False","False",,"False","False",,"False"
"QSIS002","False","False",,"False","False",,"False"
"QSIS003","False","False",,"False","True","System.String[]","True"
"QSQL006","False","False",,"False","True","System.String[]","True"
"QSQL028","False","False",,"False","True","System.String[]","True"
"QSQL029","False","False",,"False","True","System.String[]","True"
"QSQL030","False","False",,"False","True","System.String[]","True"
"QSRS001","False","False",,"False","False",,"False"
"QSRS004","False","False",,"False","True","System.String[]","True"
"QTABL001","False","False",,"False","True","System.String[]","True"
"QUTL012","False","False",,"False","False",,"False"
"QVST011","False","False",,"False","True","System.String[]","True"
"QVST012","False","False",,"False","True","System.String[]","True"
"QVST021","False","False",,"False","True","System.String[]","True"
"QVST022","False","False",,"False","True","System.String[]","True"
1 Computer CBServicing WindowsUpdate CCMClientSDK PendComputerRename PendFileRename PendFileRenVal RebootPending
2 Q1FNP003 False False False False False
3 Q1SQL022 False False False True System.String[] True
4 Q1SQL024 False False False True System.String[] True
5 Q2FNP003 False False False False False
6 Q2SQL022 False False False True System.String[] True
7 Q3FNP003 False False False False False
8 Q3SQL022 False False False True System.String[] True
9 Q4FNP003 False False False False False
10 Q4SQL022 False False False True System.String[] True
11 Q4SQL022B False False False True System.String[] True
12 Q4SQL024 False False False True System.String[] True
13 Q5FNP003 False False False False False
14 Q5SQL022 False False False True System.String[] True
15 QADF001 False False False True System.String[] True
16 QAPP011 False False False True System.String[] True
17 QAPP021 False False False True System.String[] True
18 QAPP031 False False False True System.String[] True
19 QAPP041 False False False True System.String[] True
20 QAPP051 False False False True System.String[] True
21 QBIZ111 False False False True System.String[] True
22 QBIZ112 False False False True System.String[] True
23 QBIZ121 True True False True System.String[] True
24 QBIZ122 False False False True System.String[] True
25 QBIZ131 False False False True System.String[] True
26 QBIZ132 False False False True System.String[] True
27 QBIZ141 False False False True System.String[] True
28 QBIZ142 False False False True System.String[] True
29 QBIZ151 False False False True System.String[] True
30 QBIZ152 False False False True System.String[] True
31 QCMX001 False False False True System.String[] True
32 QDRF001 False False False True System.String[] True
33 QEDI111 False False False True System.String[] True
34 QEDI112 False False False True System.String[] True
35 QEDI113 False False False True System.String[] True
36 QEDI151 False False False True System.String[] True
37 QEDI152 False False False True System.String[] True
38 QEDI153 False False False True System.String[] True
39 QFNP001 False False False True System.String[] True
40 QFNP003 False False False True System.String[] True
41 QFNP007 False False False True System.String[] True
42 QFNP008 False False False False False
43 QFNP009 False False False False False
44 QIIS005 False False False True System.String[] True
45 QMFT001 False False False True System.String[] True
46 QMHB001 False False False True System.String[] True
47 QMHB002 False False False True System.String[] True
48 QMHB003 False False False True System.String[] True
49 QMHB004 False False False True System.String[] True
50 QNCRASPAPP01 False False False False False
51 QNCRASPAPP02 False False False False False
52 QNCRASPDC01 False False False False False
53 QNCRASPDC02 False False False False False
54 QNCRASPOWA01 False False False True System.String[] True
55 QNCRASPSEA01 False False False False False
56 QNCRASPSEA02 False False False False False
57 QNCRASPWFE01 False False False False False
58 QNCRASPWFE02 False False False False False
59 QQATEST01 False False False True System.String[] True
60 QRDS001 False False False True System.String[] True
61 QRDS002 False False False True System.String[] True
62 QRSH001 False False False True System.String[] True
63 QRSH002 False False False True System.String[] True
64 QRSH021 False False False True System.String[] True
65 QRSH022 False False False True System.String[] True
66 QRSH023 False False False True System.String[] True
67 QRSH031 False False False True System.String[] True
68 QRSH041 False False False False False
69 QRSH051 False False False True System.String[] True
70 QRSH101 False False False True System.String[] True
71 QRSH111 False False False True System.String[] True
72 QRSH112 False False False False False
73 QSCH011 False False False False False
74 QSCH012 False False False False False
75 QSCH013 False False False False False
76 QSCH014 False False False False False
77 QSIS001 False False False False False
78 QSIS002 False False False False False
79 QSIS003 False False False True System.String[] True
80 QSQL006 False False False True System.String[] True
81 QSQL028 False False False True System.String[] True
82 QSQL029 False False False True System.String[] True
83 QSQL030 False False False True System.String[] True
84 QSRS001 False False False False False
85 QSRS004 False False False True System.String[] True
86 QTABL001 False False False True System.String[] True
87 QUTL012 False False False False False
88 QVST011 False False False True System.String[] True
89 QVST012 False False False True System.String[] True
90 QVST021 False False False True System.String[] True
91 QVST022 False False False True System.String[] True

View File

@@ -0,0 +1,308 @@
"Computer","CBServicing","WindowsUpdate","CCMClientSDK","PendComputerRename","PendFileRename","PendFileRenVal","RebootPending"
"PMON003","False","False",,"False","False",,"False"
"PMHB002","False","False",,"False","True","System.String[]","True"
"PSKY001","False","False",,"False","True","System.String[]","True"
"NYMEPALT001","False","False",,"False","False",,"False"
"PLNC001","False","False",,"False","False",,"False"
"PFNP009","False","False",,"False","True","System.String[]","True"
"PFAX002",,"False",,"False","False",,"False"
"PVTS002",,"False",,"False","False",,"False"
"PFNP003","False","False",,"False","False",,"False"
"POCS002","False","False",,"False","False",,"False"
"PARM001","False","False",,"False","True","System.String[]","True"
"PSHP002","False","False",,"False","False",,"False"
"PSSS001","False","False",,"False","True","System.String[]","True"
"PAPC001","False","False",,"False","False",,"False"
"PFNP001","False","False",,"False","False",,"False"
"PFNP005","False","False",,"False","False",,"False"
"PSQL006","False","False",,"False","False",,"False"
"PSPT002","False","False",,"False","False",,"False"
"PVTS003",,"False",,"False","False",,"False"
"PSUF001","False","False",,"False","True","System.String[]","True"
"PFAX005",,"False",,"False","False",,"False"
"PTABL001","False","False",,"False","True","System.String[]","True"
"PIIS006",,"False",,"False","False",,"False"
"PWTS041","False","False",,"False","True","System.String[]","True"
"CTHAPALT001","False","False",,"False","True","System.String[]","True"
"PATV001","False","False",,"False","True","System.String[]","True"
"PSQL001","False","False",,"False","False",,"False"
"PWHD003","False","False",,"False","True","System.String[]","True"
"PMON008","False","False",,"False","False",,"False"
"PVSS011","False","False",,"False","True","System.String[]","True"
"PFNP007","False","False",,"False","False",,"False"
"PSQL014","False","False",,"False","False",,"False"
"PSEV011","False","False",,"False","False",,"False"
"PIIS001",,"False",,"False","False",,"False"
"PUTL005","False","False",,"False","True","System.String[]","True"
"PBIT901","False","False",,"False","True","System.String[]","True"
"PWTS040","False","False",,"False","True","System.String[]","True"
"PSRS001","False","False",,"False","False",,"False"
"PFAX003",,"False",,"False","False",,"False"
"PFAX007","False","False",,"False","True","System.String[]","True"
"PVRS001","False","False",,"False","False",,"False"
"PSEV016","False","False",,"False","False",,"False"
"PPKI004","False","False",,"False","False",,"False"
"PCVV001","False","False",,"False","False",,"False"
"PPCH001","False","False",,"False","False",,"False"
"PSQL007","False","False",,"False","False",,"False"
"PVEO002","False","False",,"False","True","System.String[]","True"
"PSEC002","False","False",,"False","True","System.String[]","True"
"PPGP001","False","False",,"False","False",,"False"
"PFNP011","False","False",,"False","True","System.String[]","True"
"PSEV012","False","False",,"False","True","System.String[]","True"
"PSEV014","False","False",,"False","True","System.String[]","True"
"PPDQ001","False","False",,"False","True","System.String[]","True"
"PVEO001","False","False",,"False","False",,"False"
"PSKY003","False","False",,"False","False",,"False"
"CTHAPALT002","False","False",,"False","False",,"False"
"PSQL008","False","False",,"False","True","System.String[]","True"
"PVTS006",,"False",,"False","False",,"False"
"PVTS004",,"False",,"False","False",,"False"
"PDFS001","False","False",,"False","False",,"False"
"PVVC013","False","False",,"False","False",,"False"
"PSHP001","False","False",,"False","False",,"False"
"PRAD002","False","False",,"False","True","System.String[]","True"
"PIIS002",,"False",,"False","False",,"False"
"CTSTPALT001","False","False",,"False","False",,"False"
"KSOVEPAPP010",,"False",,"False","False",,"False"
"PSQL016","False","False",,"False","True","System.String[]","True"
"PSIS002","False","False",,"False","True","System.String[]","True"
"PVVC015","False","False",,"False","False",,"False"
"PVVC011","False","False",,"False","False",,"False"
"PFNP010","False","False",,"False","True","System.String[]","True"
"PLNC002","False","False",,"False","False",,"False"
"AZPHPALT001","False","False",,"False","False",,"False"
"PCPR001","False","False",,"False","False",,"False"
"PSQL015","False","False",,"False","True","System.String[]","True"
"PDFS002","False","False",,"False","False",,"False"
"PBTS001","False","False",,"False","False",,"False"
"PBLD001","False","False",,"False","True","System.String[]","True"
"KSOPPALT001","False","False",,"False","False",,"False"
"PEZP001","False","False",,"False","True","System.String[]","True"
"PSUF002","False","False",,"False","False",,"False"
"PKEY001","False","False",,"False","True","System.String[]","True"
"PVTS005",,"False",,"False","False",,"False"
"PADF001","False","False",,"False","False",,"False"
"PALT001","False","False",,"False","False",,"False"
"PPCS001","False","False",,"False","False",,"False"
"PSRS003","False","False",,"False","False",,"False"
"PALM001","False","False",,"False","False",,"False"
"PSQL013","False","False",,"False","True","System.String[]","True"
"PVVC014","False","False",,"False","False",,"False"
"PIPM001","False","False",,"False","False",,"False"
"PSRS002","False","False",,"False","False",,"False"
"PSIS001","False","False",,"False","False",,"False"
"PVTS001",,"False",,"False","False",,"False"
"PDFS003","False","False",,"False","False",,"False"
"PMHB001","False","False",,"False","False",,"False"
"PFNP012","False","False",,"False","True","System.String[]","True"
"PDOC001","False","False",,"False","False",,"False"
"PFNP008","False","False",,"False","True","System.String[]","True"
"FLT2PALT001","False","False",,"False","False",,"False"
"PUTL006","False","False",,"False","True","System.String[]","True"
"PIIS003","False","False",,"False","False",,"False"
"PSEV010","False","False",,"False","False",,"False"
"PSEV013","False","False",,"False","False",,"False"
"PUTL011","False","False",,"False","True","System.String[]","True"
"PFAX004",,"False",,"False","False",,"False"
"PSNW001","False","False",,"False","False",,"False"
"PMON007","False","False",,"False","True","System.String[]","True"
"PSQL010","False","False",,"False","True","System.String[]","True"
"PDWH002","False","False",,"False","False",,"False"
"PSQL009","False","False",,"False","True","System.String[]","True"
"PVVC016","False","False",,"False","False",,"False"
"PVCO001","False","False",,"False","False",,"False"
"PFNP002","False","False",,"False","True","System.String[]","True"
"PWHD004","False","False",,"False","False",,"False"
"PDEP001","False","False",,"False","False",,"False"
"PVVC012","False","False",,"False","False",,"False"
"PVSS012","False","False",,"False","False",,"False"
"PVAV001","False","False",,"False","True","System.String[]","True"
"PGAW001","False","False",,"False","True","System.String[]","True"
"PAPP011","False","False",,"False","True","System.String[]","True"
"PSWF001","False","False",,"False","True","System.String[]","True"
"PVRS012","False","False",,"False","True","System.String[]","True"
"PSAP001","False","False",,"False","True","System.String[]","True"
"PFNP006","False","False",,"False","True","System.String[]","True"
"PSQL012","False","False",,"False","True","System.String[]","True"
"PKEY002","False","False",,"False","True","System.String[]","True"
"PSRS004","False","False",,"False","True","System.String[]","True"
"PSEV022","False","False",,"False","False",,"False"
"PSEV015","False","False",,"False","False",,"False"
"PCCR001","False","False",,"False","True","System.String[]","True"
"PSQL026","False","False",,"False","True","System.String[]","True"
"PVRS011","False","False",,"False","True","System.String[]","True"
"PFNP015","False","False",,"False","False",,"False"
"PSEV024","False","False",,"False","False",,"False"
"PVRT006","False","False",,"False","False",,"False"
"PRSH016","False","False",,"False","False",,"False"
"PRSH033","False","False",,"False","False",,"False"
"PRSH036","False","False",,"False","False",,"False"
"PRSH040","False","False",,"False","False",,"False"
"PRSH021","False","False",,"False","False",,"False"
"PRSH032","False","False",,"False","False",,"False"
"PRSH027","False","False",,"False","True","System.String[]","True"
"PRSH182","False","False",,"False","True","System.String[]","True"
"PRSH028","False","False",,"False","False",,"False"
"PRSH175","False","False",,"False","True","System.String[]","True"
"PEDI116","False","False",,"False","True","System.String[]","True"
"PRSH029","False","False",,"False","False",,"False"
"PVRT003","False","False",,"False","False",,"False"
"PRSH014","False","False",,"False","False",,"False"
"PRSH018","False","False",,"False","False",,"False"
"PRSH002","False","False",,"False","False",,"False"
"PRSH005","False","False",,"False","False",,"False"
"PRSH162","False","False",,"False","True","System.String[]","True"
"PRSH176","False","False",,"False","True","System.String[]","True"
"PBIZ112","False","False",,"False","False",,"False"
"PBIZ111","False","False",,"False","False",,"False"
"PRSH000","False","False",,"False","False",,"False"
"PRSH026","False","False",,"False","False",,"False"
"PVRT005","False","False",,"False","False",,"False"
"PRSH030","False","False",,"False","False",,"False"
"PRSH174","False","False",,"False","True","System.String[]","True"
"PRSH013","False","False",,"False","False",,"False"
"PRSH004","False","False",,"False","False",,"False"
"PRSH039","False","False",,"False","False",,"False"
"PRSH008","False","False",,"False","False",,"False"
"PRSH022","False","False",,"False","False",,"False"
"PRSH015","False","False",,"False","False",,"False"
"PRSH019","False","False",,"False","False",,"False"
"PRSH012","False","False",,"False","False",,"False"
"PEDI113","False","False",,"False","True","System.String[]","True"
"PRSH003","False","False",,"False","False",,"False"
"PRSH011","False","False",,"False","False",,"False"
"PRSH102","False","False",,"False","True","System.String[]","True"
"PRSH017","False","False",,"False","False",,"False"
"PRDS001","False","False",,"False","False",,"False"
"PRSH010","False","False",,"False","False",,"False"
"PRSH025","False","False",,"False","False",,"False"
"PRSH181","False","False",,"False","False",,"False"
"PRSH006","False","False",,"False","False",,"False"
"PRSH151","False","False",,"False","True","System.String[]","True"
"PRSH007","False","False",,"False","False",,"False"
"PRSH035","False","False",,"False","False",,"False"
"PRSH037","False","False",,"False","False",,"False"
"PVRT004","False","False",,"False","False",,"False"
"PRSH031","False","False",,"False","False",,"False"
"PRSH009","False","False",,"False","False",,"False"
"PRSH020","False","False",,"False","False",,"False"
"PRSH172","False","False",,"False","True","System.String[]","True"
"PRSH034","False","False",,"False","False",,"False"
"PRSH023","False","False",,"False","False",,"False"
"PEDI112","False","False",,"False","True","System.String[]","True"
"PRSH101","False","False",,"False","True","System.String[]","True"
"PRSH024","False","False",,"False","False",,"False"
"PRSH001","False","False",,"False","False",,"False"
"PRSH038","False","False",,"False","False",,"False"
"PRSH161","False","False",,"False","True","System.String[]","True"
"PVRT001","False","False",,"False","False",,"False"
"PVRT002","False","False",,"False","False",,"False"
"PRSH051","False","False",,"False","False",,"False"
"PSQL025","False","False",,"False","False",,"False"
"PEDI114","False","False",,"False","True","System.String[]","True"
"PEDI111","False","False",,"False","True","System.String[]","True"
"PEDI115","False","False",,"False","True","System.String[]","True"
"PRSH056","False","False",,"False","False",,"False"
"PRSH053","False","False",,"False","False",,"False"
"PRSH173","False","False",,"False","True","System.String[]","True"
"PRDS002","False","False",,"False","True","System.String[]","True"
"PRSH059","False","False",,"False","False",,"False"
"PRSH054","False","False",,"False","False",,"False"
"PRSH058","False","False",,"False","False",,"False"
"PRSH057","False","False",,"False","False",,"False"
"PRSH171","False","False",,"False","True","System.String[]","True"
"PRSH052","False","False",,"False","False",,"False"
"PRSH060","False","False",,"False","False",,"False"
"PRSH050","False","False",,"False","False",,"False"
"PRSH049","False","False",,"False","True","System.String[]","True"
"PRSH055","False","False",,"False","False",,"False"
"KSOVEPOPS001",,"False",,"False","False",,"False"
"PDISKTEST1","False","False",,"False","True","System.String[]","True"
"PAPP001","False","False",,"False","True","System.String[]","True"
"PFNP013","False","False",,"False","True","System.String[]","True"
"PVAV002","False","False",,"False","True","System.String[]","True"
"PVCO007","False","False",,"False","True","System.String[]","True"
"PDMC006","False","False",,"False","True","System.String[]","True"
"FLT2PDMC001","False","False",,"False","True","System.String[]","True"
"CTSTPDMC001","False","False",,"False","False",,"False"
"FLT2PDMC002","False","False",,"False","False",,"False"
"PDMC005","False","False",,"False","True","System.String[]","True"
"KSOPPDMC001","False","False",,"False","False",,"False"
"CTHAPDMC001","False","False",,"False","True","System.String[]","True"
"NYMEPDMC001","False","False",,"False","True","System.String[]","True"
"PDMC004","False","False",,"False","True","System.String[]","True"
"AZPHPDMC001","False","False",,"False","True","System.String[]","True"
"PIAM001","False","False",,"False","True","System.String[]","True"
"PIAM002","False","False",,"False","True","System.String[]","True"
"PIAC001","False","False",,"False","True","System.String[]","True"
"PIWM001","False","False",,"False","True","System.String[]","True"
"PIWM002","False","False",,"False","True","System.String[]","True"
"PICO001","True","False",,"False","True","System.String[]","True"
"POWA001","False","False",,"False","True","System.String[]","True"
"PVAV003","False","False",,"False","True","System.String[]","True"
"PSPT001","False","False",,"False","True","System.String[]","True"
"PBIZ122","False","False",,"False","False",,"False"
"PBIZ124","False","False",,"False","False",,"False"
"PBIZ125","False","False",,"False","False",,"False"
"PBIZ126","False","False",,"False","False",,"False"
"PBIZ123","False","False",,"False","False",,"False"
"PSLK001","False","False",,"False","False",,"False"
"PBIZ121","False","False",,"False","False",,"False"
"PFAX014","False","False",,"False","False",,"False"
"PDRF001","False","False",,"False","True","System.String[]","True"
"PSNX001","False","False",,"False","True","System.String[]","True"
"PIAP002","False","False",,"False","True","System.String[]","True"
"PFNP014","False","False",,"False","False",,"False"
"PFAX013","False","False",,"False","False",,"False"
"PMFT001","False","False",,"False","True","System.String[]","True"
"PFAX015","False","False",,"False","True","System.String[]","True"
"PIAP001","False","False",,"False","True","System.String[]","True"
"PMON006","False","False",,"False","True","System.String[]","True"
"PMQS001","False","False",,"False","True","System.String[]","True"
"PFOG001","False","False",,"False","True","System.String[]","True"
"PADS001","False","False",,"False","False",,"False"
"PFAX012","False","False",,"False","False",,"False"
"PRMS002","False","False",,"False","False",,"False"
"PRMS001","False","False",,"False","False",,"False"
"PFAX011","False","False",,"False","True","System.String[]","True"
"PFNP016","False","False",,"False","False",,"False"
"PFNP017","False","False",,"False","False",,"False"
"PJMP001","False","False",,"False","True","System.String[]","True"
"PKEY003","False","False",,"False","True","System.String[]","True"
"PUTL012","False","False",,"False","True","System.String[]","True"
"PIQV001","False","False",,"False","True","System.String[]","True"
"PSUS001","False","False",,"False","True","System.String[]","True"
"PSQL022","False","False",,"False","True","System.String[]","True"
"PSQL023B","False","False",,"False","True","System.String[]","True"
"PSQL022B","False","False",,"False","True","System.String[]","True"
"PSQL023","False","False",,"False","True","System.String[]","True"
"PSQL024","False","False",,"False","True","System.String[]","True"
"PSQL028B","False","False",,"False","True","System.String[]","True"
"PSIS003","False","False",,"False","False",,"False"
"PSQL029A","False","False",,"False","True","System.String[]","True"
"PSQL029B","False","False",,"False","True","System.String[]","True"
"PSQL028A","False","False",,"False","True","System.String[]","True"
"PCMX001","False","False",,"False","True","System.String[]","True"
"PSSP001","False","False",,"False","True","System.String[]","True"
"PSSP002","False","False",,"False","True","System.String[]","True"
"PSQL030A","False","False",,"False","True","System.String[]","True"
"PSQL030B","False","False",,"False","True","System.String[]","True"
"PAPJNKSSLA201","False","False",,"False","True","System.String[]","True"
"PNCRAFILE001","False","False",,"False","True","System.String[]","True"
"PSSP004","False","False",,"False","True","System.String[]","True"
"PSSP003","False","False",,"False","True","System.String[]","True"
"PNCRAFILE005","False","False",,"False","True","System.String[]","True"
"FLT2VEB002","False","False",,"False","False",,"False"
"PNCRAFILE003","False","False",,"False","True","System.String[]","True"
"PNCRANTRX002","False","False",,"False","False",,"False"
"FLT2VEB003","False","False",,"False","False",,"False"
"PNCRAVERIDX003","False","False",,"False","False",,"False"
"PNCRAVERVLT002","False","False",,"False","True","System.String[]","True"
"PNCRAMSMQ001","False","False",,"False","True","System.String[]","True"
"PNCRAVERVLT003","False","False",,"False","False",,"False"
"PNCRAVERVLT001","False","False",,"False","True","System.String[]","True"
"PNCRAVERIDX002","False","False",,"False","False",,"False"
"PNCRAVERIDX001","False","False",,"False","False",,"False"
"PNCRAVERDA001","False","False",,"False","False",,"False"
"PRSH152","False","False",,"False","True","System.String[]","True"
1 Computer CBServicing WindowsUpdate CCMClientSDK PendComputerRename PendFileRename PendFileRenVal RebootPending
2 PMON003 False False False False False
3 PMHB002 False False False True System.String[] True
4 PSKY001 False False False True System.String[] True
5 NYMEPALT001 False False False False False
6 PLNC001 False False False False False
7 PFNP009 False False False True System.String[] True
8 PFAX002 False False False False
9 PVTS002 False False False False
10 PFNP003 False False False False False
11 POCS002 False False False False False
12 PARM001 False False False True System.String[] True
13 PSHP002 False False False False False
14 PSSS001 False False False True System.String[] True
15 PAPC001 False False False False False
16 PFNP001 False False False False False
17 PFNP005 False False False False False
18 PSQL006 False False False False False
19 PSPT002 False False False False False
20 PVTS003 False False False False
21 PSUF001 False False False True System.String[] True
22 PFAX005 False False False False
23 PTABL001 False False False True System.String[] True
24 PIIS006 False False False False
25 PWTS041 False False False True System.String[] True
26 CTHAPALT001 False False False True System.String[] True
27 PATV001 False False False True System.String[] True
28 PSQL001 False False False False False
29 PWHD003 False False False True System.String[] True
30 PMON008 False False False False False
31 PVSS011 False False False True System.String[] True
32 PFNP007 False False False False False
33 PSQL014 False False False False False
34 PSEV011 False False False False False
35 PIIS001 False False False False
36 PUTL005 False False False True System.String[] True
37 PBIT901 False False False True System.String[] True
38 PWTS040 False False False True System.String[] True
39 PSRS001 False False False False False
40 PFAX003 False False False False
41 PFAX007 False False False True System.String[] True
42 PVRS001 False False False False False
43 PSEV016 False False False False False
44 PPKI004 False False False False False
45 PCVV001 False False False False False
46 PPCH001 False False False False False
47 PSQL007 False False False False False
48 PVEO002 False False False True System.String[] True
49 PSEC002 False False False True System.String[] True
50 PPGP001 False False False False False
51 PFNP011 False False False True System.String[] True
52 PSEV012 False False False True System.String[] True
53 PSEV014 False False False True System.String[] True
54 PPDQ001 False False False True System.String[] True
55 PVEO001 False False False False False
56 PSKY003 False False False False False
57 CTHAPALT002 False False False False False
58 PSQL008 False False False True System.String[] True
59 PVTS006 False False False False
60 PVTS004 False False False False
61 PDFS001 False False False False False
62 PVVC013 False False False False False
63 PSHP001 False False False False False
64 PRAD002 False False False True System.String[] True
65 PIIS002 False False False False
66 CTSTPALT001 False False False False False
67 KSOVEPAPP010 False False False False
68 PSQL016 False False False True System.String[] True
69 PSIS002 False False False True System.String[] True
70 PVVC015 False False False False False
71 PVVC011 False False False False False
72 PFNP010 False False False True System.String[] True
73 PLNC002 False False False False False
74 AZPHPALT001 False False False False False
75 PCPR001 False False False False False
76 PSQL015 False False False True System.String[] True
77 PDFS002 False False False False False
78 PBTS001 False False False False False
79 PBLD001 False False False True System.String[] True
80 KSOPPALT001 False False False False False
81 PEZP001 False False False True System.String[] True
82 PSUF002 False False False False False
83 PKEY001 False False False True System.String[] True
84 PVTS005 False False False False
85 PADF001 False False False False False
86 PALT001 False False False False False
87 PPCS001 False False False False False
88 PSRS003 False False False False False
89 PALM001 False False False False False
90 PSQL013 False False False True System.String[] True
91 PVVC014 False False False False False
92 PIPM001 False False False False False
93 PSRS002 False False False False False
94 PSIS001 False False False False False
95 PVTS001 False False False False
96 PDFS003 False False False False False
97 PMHB001 False False False False False
98 PFNP012 False False False True System.String[] True
99 PDOC001 False False False False False
100 PFNP008 False False False True System.String[] True
101 FLT2PALT001 False False False False False
102 PUTL006 False False False True System.String[] True
103 PIIS003 False False False False False
104 PSEV010 False False False False False
105 PSEV013 False False False False False
106 PUTL011 False False False True System.String[] True
107 PFAX004 False False False False
108 PSNW001 False False False False False
109 PMON007 False False False True System.String[] True
110 PSQL010 False False False True System.String[] True
111 PDWH002 False False False False False
112 PSQL009 False False False True System.String[] True
113 PVVC016 False False False False False
114 PVCO001 False False False False False
115 PFNP002 False False False True System.String[] True
116 PWHD004 False False False False False
117 PDEP001 False False False False False
118 PVVC012 False False False False False
119 PVSS012 False False False False False
120 PVAV001 False False False True System.String[] True
121 PGAW001 False False False True System.String[] True
122 PAPP011 False False False True System.String[] True
123 PSWF001 False False False True System.String[] True
124 PVRS012 False False False True System.String[] True
125 PSAP001 False False False True System.String[] True
126 PFNP006 False False False True System.String[] True
127 PSQL012 False False False True System.String[] True
128 PKEY002 False False False True System.String[] True
129 PSRS004 False False False True System.String[] True
130 PSEV022 False False False False False
131 PSEV015 False False False False False
132 PCCR001 False False False True System.String[] True
133 PSQL026 False False False True System.String[] True
134 PVRS011 False False False True System.String[] True
135 PFNP015 False False False False False
136 PSEV024 False False False False False
137 PVRT006 False False False False False
138 PRSH016 False False False False False
139 PRSH033 False False False False False
140 PRSH036 False False False False False
141 PRSH040 False False False False False
142 PRSH021 False False False False False
143 PRSH032 False False False False False
144 PRSH027 False False False True System.String[] True
145 PRSH182 False False False True System.String[] True
146 PRSH028 False False False False False
147 PRSH175 False False False True System.String[] True
148 PEDI116 False False False True System.String[] True
149 PRSH029 False False False False False
150 PVRT003 False False False False False
151 PRSH014 False False False False False
152 PRSH018 False False False False False
153 PRSH002 False False False False False
154 PRSH005 False False False False False
155 PRSH162 False False False True System.String[] True
156 PRSH176 False False False True System.String[] True
157 PBIZ112 False False False False False
158 PBIZ111 False False False False False
159 PRSH000 False False False False False
160 PRSH026 False False False False False
161 PVRT005 False False False False False
162 PRSH030 False False False False False
163 PRSH174 False False False True System.String[] True
164 PRSH013 False False False False False
165 PRSH004 False False False False False
166 PRSH039 False False False False False
167 PRSH008 False False False False False
168 PRSH022 False False False False False
169 PRSH015 False False False False False
170 PRSH019 False False False False False
171 PRSH012 False False False False False
172 PEDI113 False False False True System.String[] True
173 PRSH003 False False False False False
174 PRSH011 False False False False False
175 PRSH102 False False False True System.String[] True
176 PRSH017 False False False False False
177 PRDS001 False False False False False
178 PRSH010 False False False False False
179 PRSH025 False False False False False
180 PRSH181 False False False False False
181 PRSH006 False False False False False
182 PRSH151 False False False True System.String[] True
183 PRSH007 False False False False False
184 PRSH035 False False False False False
185 PRSH037 False False False False False
186 PVRT004 False False False False False
187 PRSH031 False False False False False
188 PRSH009 False False False False False
189 PRSH020 False False False False False
190 PRSH172 False False False True System.String[] True
191 PRSH034 False False False False False
192 PRSH023 False False False False False
193 PEDI112 False False False True System.String[] True
194 PRSH101 False False False True System.String[] True
195 PRSH024 False False False False False
196 PRSH001 False False False False False
197 PRSH038 False False False False False
198 PRSH161 False False False True System.String[] True
199 PVRT001 False False False False False
200 PVRT002 False False False False False
201 PRSH051 False False False False False
202 PSQL025 False False False False False
203 PEDI114 False False False True System.String[] True
204 PEDI111 False False False True System.String[] True
205 PEDI115 False False False True System.String[] True
206 PRSH056 False False False False False
207 PRSH053 False False False False False
208 PRSH173 False False False True System.String[] True
209 PRDS002 False False False True System.String[] True
210 PRSH059 False False False False False
211 PRSH054 False False False False False
212 PRSH058 False False False False False
213 PRSH057 False False False False False
214 PRSH171 False False False True System.String[] True
215 PRSH052 False False False False False
216 PRSH060 False False False False False
217 PRSH050 False False False False False
218 PRSH049 False False False True System.String[] True
219 PRSH055 False False False False False
220 KSOVEPOPS001 False False False False
221 PDISKTEST1 False False False True System.String[] True
222 PAPP001 False False False True System.String[] True
223 PFNP013 False False False True System.String[] True
224 PVAV002 False False False True System.String[] True
225 PVCO007 False False False True System.String[] True
226 PDMC006 False False False True System.String[] True
227 FLT2PDMC001 False False False True System.String[] True
228 CTSTPDMC001 False False False False False
229 FLT2PDMC002 False False False False False
230 PDMC005 False False False True System.String[] True
231 KSOPPDMC001 False False False False False
232 CTHAPDMC001 False False False True System.String[] True
233 NYMEPDMC001 False False False True System.String[] True
234 PDMC004 False False False True System.String[] True
235 AZPHPDMC001 False False False True System.String[] True
236 PIAM001 False False False True System.String[] True
237 PIAM002 False False False True System.String[] True
238 PIAC001 False False False True System.String[] True
239 PIWM001 False False False True System.String[] True
240 PIWM002 False False False True System.String[] True
241 PICO001 True False False True System.String[] True
242 POWA001 False False False True System.String[] True
243 PVAV003 False False False True System.String[] True
244 PSPT001 False False False True System.String[] True
245 PBIZ122 False False False False False
246 PBIZ124 False False False False False
247 PBIZ125 False False False False False
248 PBIZ126 False False False False False
249 PBIZ123 False False False False False
250 PSLK001 False False False False False
251 PBIZ121 False False False False False
252 PFAX014 False False False False False
253 PDRF001 False False False True System.String[] True
254 PSNX001 False False False True System.String[] True
255 PIAP002 False False False True System.String[] True
256 PFNP014 False False False False False
257 PFAX013 False False False False False
258 PMFT001 False False False True System.String[] True
259 PFAX015 False False False True System.String[] True
260 PIAP001 False False False True System.String[] True
261 PMON006 False False False True System.String[] True
262 PMQS001 False False False True System.String[] True
263 PFOG001 False False False True System.String[] True
264 PADS001 False False False False False
265 PFAX012 False False False False False
266 PRMS002 False False False False False
267 PRMS001 False False False False False
268 PFAX011 False False False True System.String[] True
269 PFNP016 False False False False False
270 PFNP017 False False False False False
271 PJMP001 False False False True System.String[] True
272 PKEY003 False False False True System.String[] True
273 PUTL012 False False False True System.String[] True
274 PIQV001 False False False True System.String[] True
275 PSUS001 False False False True System.String[] True
276 PSQL022 False False False True System.String[] True
277 PSQL023B False False False True System.String[] True
278 PSQL022B False False False True System.String[] True
279 PSQL023 False False False True System.String[] True
280 PSQL024 False False False True System.String[] True
281 PSQL028B False False False True System.String[] True
282 PSIS003 False False False False False
283 PSQL029A False False False True System.String[] True
284 PSQL029B False False False True System.String[] True
285 PSQL028A False False False True System.String[] True
286 PCMX001 False False False True System.String[] True
287 PSSP001 False False False True System.String[] True
288 PSSP002 False False False True System.String[] True
289 PSQL030A False False False True System.String[] True
290 PSQL030B False False False True System.String[] True
291 PAPJNKSSLA201 False False False True System.String[] True
292 PNCRAFILE001 False False False True System.String[] True
293 PSSP004 False False False True System.String[] True
294 PSSP003 False False False True System.String[] True
295 PNCRAFILE005 False False False True System.String[] True
296 FLT2VEB002 False False False False False
297 PNCRAFILE003 False False False True System.String[] True
298 PNCRANTRX002 False False False False False
299 FLT2VEB003 False False False False False
300 PNCRAVERIDX003 False False False False False
301 PNCRAVERVLT002 False False False True System.String[] True
302 PNCRAMSMQ001 False False False True System.String[] True
303 PNCRAVERVLT003 False False False False False
304 PNCRAVERVLT001 False False False True System.String[] True
305 PNCRAVERIDX002 False False False False False
306 PNCRAVERIDX001 False False False False False
307 PNCRAVERDA001 False False False False False
308 PRSH152 False False False True System.String[] True

View File

@@ -0,0 +1,6 @@
"Computer","CBServicing","WindowsUpdate","CCMClientSDK","PendComputerRename","PendFileRename","PendFileRenVal","RebootPending"
"Q2FNP003","False","False",,"False","False",,"False"
"QRSH022","False","False",,"False","True","System.String[]","True"
"QRSH021","False","False",,"False","False",,"False"
"QRSH023","False","False",,"False","False",,"False"
"Q2SQL022","False","False",,"False","True","System.String[]","True"
1 Computer CBServicing WindowsUpdate CCMClientSDK PendComputerRename PendFileRename PendFileRenVal RebootPending
2 Q2FNP003 False False False False False
3 QRSH022 False False False True System.String[] True
4 QRSH021 False False False False False
5 QRSH023 False False False False False
6 Q2SQL022 False False False True System.String[] True

View File

@@ -0,0 +1,8 @@
"Computer","CBServicing","WindowsUpdate","CCMClientSDK","PendComputerRename","PendFileRename","PendFileRenVal","RebootPending"
"QBIZ142","False","False",,"False","False",,"False"
"QBIZ141","False","False",,"False","False",,"False"
"QAPP041","False","False",,"False","True","System.String[]","True"
"QRSH041","False","False",,"False","False",,"False"
"Q4SQL022B","False","False",,"False","True","System.String[]","True"
"Q4FNP003","False","False",,"False","False",,"False"
"Q4SQL022","False","False",,"False","True","System.String[]","True"
1 Computer CBServicing WindowsUpdate CCMClientSDK PendComputerRename PendFileRename PendFileRenVal RebootPending
2 QBIZ142 False False False False False
3 QBIZ141 False False False False False
4 QAPP041 False False False True System.String[] True
5 QRSH041 False False False False False
6 Q4SQL022B False False False True System.String[] True
7 Q4FNP003 False False False False False
8 Q4SQL022 False False False True System.String[] True

View File

@@ -0,0 +1,6 @@
"Computer","CBServicing","WindowsUpdate","CCMClientSDK","PendComputerRename","PendFileRename","PendFileRenVal","RebootPending"
"QAPP051","False","False",,"False","True","System.String[]","True"
"QRSH051","False","False",,"False","False",,"False"
"Q5FNP003","False","False",,"False","False",,"False"
"QBIZ152","False","False",,"False","True","System.String[]","True"
"Q5SQL022","False","False",,"False","True","System.String[]","True"
1 Computer CBServicing WindowsUpdate CCMClientSDK PendComputerRename PendFileRename PendFileRenVal RebootPending
2 QAPP051 False False False True System.String[] True
3 QRSH051 False False False False False
4 Q5FNP003 False False False False False
5 QBIZ152 False False False True System.String[] True
6 Q5SQL022 False False False True System.String[] True

View File

@@ -0,0 +1,76 @@
<#
$ErrorActionPreference = "Ignore"
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob}
#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below.
#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}}
#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group"
Read-Host -Prompt "Press Enter to exit"
#>
#################################################################################################################################
#$ErrorActionPreference = "Ignore"
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
#$servers = "W2012A","W2012B","slfkjsdl"
#$WSUSGroup = "Test GGroupp"
$Location = Split-Path $MyInvocation.MyCommand.Path -Parent
$Dte = Get-Date -UFormat %m-%d-%Y
$Collect_Jobs = @()
$Patch_Job = @()
$servers | Out-File $Location\Patching-Day\"$WSUSGroup"-Server-Patching-Today-$Dte.txt
$servers | Out-File E:\WSUS_Scripts\Patching-Day\"$WSUSGroup"-Server-Patching-Today-Backup-$Dte.txt
Foreach ($server in $servers) {
$Patch_Job += Start-Job -ScriptBlock { Param($server) Install-WindowsUpdate -ComputerName $server } -Name "$server-Patching" -ArgumentList $server
Invoke-Command $server -ErrorAction SilentlyContinue {
New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue
New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue
New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue
Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell"
}#endInvoke
#Install-WindowsUpdate -ComputerName $server -AsJob
}#endForeach
Get-Job
$Patch_Job | Export-Csv $Location\Patching-Day\Patching-Jobs-$Dte.csv -NoTypeInformation
$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\Collect-Patching-Jobs-$Dte.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\Jobs-ChildJobs-$Dte.csv -NoTypeInformation
$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv E:\WSUS_Scripts\Patching-Day\Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation
#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below.
#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}}
#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group"

View File

View File

@@ -0,0 +1,26 @@
$WSUSGroup = Read-Host "Enter Target Group Name"
$Computers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
foreach ($computer in $computers){
if(!(Test-Connection -Cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet))
{write-host "cannot reach $computer" -f red}
else {$Session = New-Object -ComObject "Microsoft.Update.Session"
$Searcher = $Session.CreateUpdateSearcher()
$historyCount = $Searcher.GetTotalHistoryCount()
$Searcher.QueryHistory(0, $historyCount) | Select-Object @{Name="Computer"; Expression={$Computer}}, Date,
@{name="Operation"; expression={switch($_.operation){
1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}},
@{name="Status"; expression={switch($_.resultcode){
1 {"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"};
4 {"Failed"}; 5 {"Aborted"}
}}},Title| Where {$_.Status -eq "Failed"}|Write-Host|Export-Csv -NoType "$Env:userprofile\Desktop\$wsusgroup-Failed-WindowsUpdates.csv" -Append}}

View File

@@ -0,0 +1,26 @@
$WSUSGroup = Read-Host "Enter Target Group Name"
$Computers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
foreach ($computer in $computers){
if(!(Test-Connection -Cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet))
{write-host "cannot reach $computer" -f red}
else {$Session = New-Object -ComObject "Microsoft.Update.Session"
$Searcher = $Session.CreateUpdateSearcher()
$historyCount = $Searcher.GetTotalHistoryCount()
$Searcher.QueryHistory(0, $historyCount) | Select-Object @{Name="Computer"; Expression={$Computer}}, Date,
@{name="Operation"; expression={switch($_.operation){
1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}},
@{name="Status"; expression={switch($_.resultcode){
1 {"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"};
4 {"Failed"}; 5 {"Aborted"}
}}},Title| Where {$_.Status -eq "In Progress"}|Write-Host}}

View File

@@ -0,0 +1,26 @@
$WSUSGroup = Read-Host "Enter Target Group Name"
$Computers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
foreach ($computer in $computers){
if(!(Test-Connection -Cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet))
{write-host "cannot reach $computer" -f red}
else {$Session = New-Object -ComObject "Microsoft.Update.Session"
$Searcher = $Session.CreateUpdateSearcher()
$historyCount = $Searcher.GetTotalHistoryCount()
$Searcher.QueryHistory(0, $historyCount) | Select-Object @{Name="Computer"; Expression={$Computer}}, Date,
@{name="Operation"; expression={switch($_.operation){
1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}},
@{name="Status"; expression={switch($_.resultcode){
1 {"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"};
4 {"Failed"}; 5 {"Aborted"}
}}},Title| Where {$_.Status -eq "In Progress"}|Write-Host}}

View File

@@ -0,0 +1,28 @@
#https://gallery.technet.microsoft.com/scriptcenter/Get-Installed-FailedWindows-9f28742a
$WSUSGroup = Read-Host "Enter Target Group Name"
$Computers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
foreach ($computer in $computers){
if(!(Test-Connection -Cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet))
{write-host "cannot reach $computer" -f red}
else {$Session = New-Object -ComObject "Microsoft.Update.Session"
$Searcher = $Session.CreateUpdateSearcher()
$historyCount = $Searcher.GetTotalHistoryCount()
$Searcher.QueryHistory(0, $historyCount) | Select-Object @{Name="Computer"; Expression={$Computer}}, Date,
@{name="Operation"; expression={switch($_.operation){
1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}},
@{name="Status"; expression={switch($_.resultcode){
1 {"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"};
4 {"Failed"}; 5 {"Aborted"}
}}},Title| Where {$_.Status -eq "In Progress"}}}

View File

@@ -0,0 +1,19 @@
Import-Module ActiveDirectory
Import-Module WindowsUpdate
$ServerList = Import-Csv 'C:\Users\abamaso-ccxadmin\Desktop\CompletedProd_WindowsServers - Classifications.csv'
foreach ($Server in $ServerList) {
$patchingtier = $Server.Classification
switch ($patchingtier){
"Tier0 - Infrastructure" {Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server.'Server Name'| Add-WsusComputer -TargetGroupName "Tier0 - Infrastructure"}
"Tier1 - Critical Infrastructure" {Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server.'Server Name'| Add-WsusComputer -TargetGroupName "Tier1 - Critical Infrastructure"}
"Tier2 - File Servers" {Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server.'Server Name'| Add-WsusComputer -TargetGroupName "Tier2 - File Servers"}
"Tier2 - Application Servers" {Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server.'Server Name'| Add-WsusComputer -TargetGroupName "Tier2 - Application Servers"}
}
Write-host $Server.'Server Name'" Sorted into Group"
}

Binary file not shown.

View File

@@ -0,0 +1,603 @@
#
# WSUS_Sorting_HAT.PS1
#
#DOCUMENTATION:
#Written by Kevin Trent, kevin.trent@carecentrix.com
#CHANGE LOG:
#Version 1.0 6/12/2018 - First functional edition - Kevin Trent
#UPGRADES:
# Planned:
# Add auto detection of new OU and auto creation of new function. - KJT
#DESCRIPTION:
#WSUS Server-Side targeting chosen to enable flexibility with group assignment. Sorting Hat, takes the place of client-side targeting in a GPO.
#Servers are still added to the unassigned computers group via linked GPO:
#(Prod Server SUS 2016 - PSUS002 - Server Side Targeting, DEV Server SUS 2016 - PSUS002 - Server Side Targeting, QA Server SUS 2016 - PSUS002 - Server Side Targeting)
#Each function sorts systems from the WSUS unassigned computers group to an appropriate target group based on the AD OU.
#MAINTENANCE:
#NEW Active Directory OUs require reciprocal functions to be added.
#New Function Copy/Paste existing function and make these required changes:
#Function name = WSUS Group Name, remove spaces - between each word.
#Variable name - WSUS Group Name, remove spaces change - to _. TargetGroupName = WSUS Group name.
#Canonicalname = OU with wildcard (*) in place of machine name(s).
#Find Canonicalname of a group by running the following command against a machine in that OU: Get-ADComputer -Identity qbiz111 -Properties *|select CanonicalName
#Add Group function to the Run function: (If $newservers.count -gt 0) Scriptblock near the bottom, so that the new function is called when the script is executed.
#Add comment to the ChangeLog remark above
#Module Import. This Script requires RSAT and PowerShell v3.0 or higher on the executing system.
Import-Module ActiveDirectory
Import-Module WindowsUpdate
#System Collection:
#Building the collections to be sorted from the WSUS unassigned computers group removes the need to validate each member.
#Each array memeber can only be in the collection if it passed cetificate, protocol, and connectivity requirements.
$newserversfull = Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -ComputerTargetGroups "Unassigned Computers"|select Fulldomainname -ExpandProperty Fulldomainname
#Shortening the array member names to a useable Get-ADComputer Identity
$newservers = Foreach ($server in $newserversfull) {$server.split(.)[0]}
#SORTING FUNCTIONS:
#Each function runs each memeber of the collection through a loop that contains an AD-OU query. If the member(s) are in the specified AD-OU they are inserted into the WSUS Target Group.
#For simplified locating; functions are grouped under comments with the WSUS group parent name. Example, NCRA QUALITY ASSURANCE SERVERS or CTHA PRODUCTION SERVERS
#CTHA PRODUCTION SERVERS
Function CTHA-Verint-PROD {
$CTHA_Verint_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/CTHA/Servers/Production Servers/Verint Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $CTHA_Verint_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "CTHA - Verint - PROD"
}
}
#KSOP PRODUCTION SERVERS
Function KSOP-Verint-PROD {
$KSOP_Verint_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/KSOP/Servers/Production Servers/Verint Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $KSOP_Verint_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "KSOP - Verint - PROD"
}
}
#AZPH PRODUCTION SERVERS
Function AZPH-Verint-PROD {
$AZPH_Verint_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/AZPH/Servers/Production Servers/Verint Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $AZPH_Verint_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "AZPH - Verint - PROD"
}
}
#FLT2 PRODUCTION SERVERS
Function FLT2-Application-PROD {
$FLT2_Application_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/FLT2/Servers/Production Servers/Application Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $FLT2_Application_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "FLT2 - Application - PROD"
}
}
Function FLT2-Verint-PROD {
$FLT2_Verint_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/FLT2/Servers/Production Servers/Verint Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $FLT2_Verint_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "FLT2 - Verint - PROD"
}
}
Function FLT2-Voice-PROD {
$FLT2_Voice_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/FLT2/Servers/Production Servers/Voice Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $FLT2_Voice_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "FLT2 - Voice - PROD"
}
}
#NCRA DEVELOPMENT SERVERS
Function NCRA-Application-DEV {
$NCRA_Application_DEV = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/Application Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Application_DEV) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Application - DEV"
}
}
Function NCRA-BizTalk-DEV {
$NCRA_BizTalk_DEV = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/BizTalk Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_BizTalk_DEV) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - BizTalk - DEV"
}
}
Function NCRA-Edifecs-DEV {
$NCRA_Edifecs_DEV = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/Edifecs Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Edifecs_DEV) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Edifecs - DEV"
}
}
Function NCRA-Remote-Desktop-DEV{
$NCRA_Remote_Desktop_DEV = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/Remote Desktop Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Remote_Desktop_DEV) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Remote Desktop - DEV"
}
}
Function NCRA-SQL-DEV {
$NCRA_SQL_DEV = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/SQL Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_SQL_DEV) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - SQL - DEV"
}
}
Function NCRA-Terminal-Servers-DEV {
$NCRA_Terminal_Servers_DEV = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/Terminal Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Application_DEV) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Terminal Servers - DEV"
}
}
Function NCRA-Voice-DEV {
$NCRA_Voice_DEV = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/Voice Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Voice_DEV) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Voice - DEV"
}
}
Function NCRA-Web-DEV {
$NCRA_Web_DEV = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Development Servers/Web Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Web_DEV) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Web - DEV"
}
}
#NCRA PRODUCTION SERVERS:
Function NCRA-Application-PROD {
$NCRA_Application_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Application Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Application_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Application - PROD"
}
}
Function NCRA-BizTalk-PROD {
$NCRA_BizTalk_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/BizTalk Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_BizTalk_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - BizTalk - PROD"
}
}
Function NCRA-Edifecs-PROD {
$NCRA_Edifecs_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Edifecs Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Edifecs_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Edifecs - PROD"
}
}
Function NCRA-Exchange-PROD {
$NCRA_Exchange_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Exchange Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Exchange_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Exchange - PROD"
}
}
Function NCRA-Mail-Terminal-Servers-PROD {
$NCRA_Mail_Terminal_Servers_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Mail Terminal Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Mail_Terminal_Servers_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Mail Terminal Servers - PROD"
}
}
Function NCRA-Remote-Desktop-Prod {
$NCRA_Remote_Desktop_Prod = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Remote Desktop Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Remote_Desktop_Prod) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Remote Desktop - PROD"
}
}
Function NCRA-SQL-PROD {
$NCRA_SQL_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/SQL Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_SQL_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - SQL - PROD"
}
}
Function NCRA-Terminal-Servers-PROD {
$NCRA_Terminal_Servers_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Terminal Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Terminal_Servers_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Terminal Servers - PROD"
}
}
Function NCRA-Tidal-PROD {
$NCRA_Tidal_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Tidal Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Tidal_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Tidal - PROD"
}
}
Function NCRA-Verint-PROD {
$NCRA_Verint_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Verint Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Verint_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Verint - PROD"
}
}
Function NCRA-Vistar-Terminal-Servers-PROD {
$NCRA_Vistar_Terminal_Servers_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Vistar Terminal Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Vistar_Terminal_Servers_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Vistar Terminal Servers - PROD"
}
}
Function NCRA-Voice-PROD {
$NCRA_Voice_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Voice Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Voice_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Voice - PROD"
}
}
Function NCRA-Web-PROD {
$NCRA_Web_PROD = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/Production Servers/Web Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Web_PROD) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Web - PROD"
}
}
#NCRA QUALITY ASSURANCE SERVERS:
Function NCRA-Application-QA {
$NCRA_Application_QA = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/Application Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Application_QA) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Application - QA"
}
}
Function NCRA-BizTalk-QA {
$NCRA_BizTalk_QA = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/BizTalk Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_BizTalk_QA) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - BizTalk - QA"
}
}
Function NCRA-Edifecs-QA {
$NCRA_Edifecs_QA = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/Edifecs Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Edifecs_QA) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Edifecs - QA"
}
}
Function NCRA-Remote-Desktop-QA {
$NCRA_Remote_Desktop_QA = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/Remote Desktop Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Remote_Desktop_QA) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Remote Desktop - QA"
}
}
Function NCRA-SQL-QA {
$NCRA_SQL_QA = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/Remote Desktop Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_SQL_QA) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - SQL - QA"
}
}
Function NCRA-Terminal-Servers-QA {
$NCRA_Terminal_Servers_QA = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/Remote Desktop Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Terminal_Servers_QA) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Terminal Servers - QA"
}
}
Function NCRA-Tidal-QA {
$NCRA_Tidal_QA = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/Tidal Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Tidal_QA) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - Tidal - QA"
}
}
Function NCRA-Web-QA {
$NCRA_Web_QA = Foreach ($server in $newservers) {
Get-ADComputer -Identity $server -Properties * |
Select dnshostname,canonicalname -ExpandProperty canonicalname|
Where canonicalname -Like "ccx.carecentrix.com/NCRA/Servers/QA Servers/Web Servers/*"|
Select dnshostname -ExpandProperty dnshostname
}
Foreach ($server in $NCRA_Web_QA) {
Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server|Add-WsusComputer -TargetGroupName "NCRA - WEb - QA"
}
}
#RUN:
# This function executes the script if there are new/unsorted servers in the Unassigned Computers group on the WSUS server
Function Run {
If ($newservers.Count -gt 0)
{
CTHA-Verint-PROD
KSOP-Verint-PROD
AZPH-Verint-PROD
FLT2-Application-PROD
FLT2-Verint-PROD
FLT2-Voice-PROD
NCRA-Application-DEV
NCRA-BizTalk-DEV
NCRA-Edifecs-DEV
NCRA-Remote-Desktop-DEV
NCRA-SQL-DEV
NCRA-Terminal-Servers-DEV
NCRA-Voice-DEV
NCRA-Web-DEV
NCRA-Application-PROD
NCRA-BizTalk-PROD
NCRA-Edifecs-PROD
NCRA-Exchange-PROD
NCRA-Mail-Terminal-Servers-PROD
NCRA-Remote-Desktop-Prod
NCRA-SQL-PROD
NCRA-Terminal-Servers-PROD
NCRA-Tidal-PROD
NCRA-Verint-PROD
NCRA-Vistar-Terminal-Servers-PROD
NCRA-Voice-PROD
NCRA-Web-PROD
NCRA-Application-QA
NCRA-BizTalk-QA
NCRA-Edifecs-QA
NCRA-Remote-Desktop-QA
NCRA-SQL-QA
NCRA-Terminal-Servers-QA
NCRA-Tidal-QA
NCRA-Web-QA
}
Else {Send-MailMessage -SmtpServer smtp.ccx.carecentrix.com -From WSUS-Sorting-Hat@carecentrix.com -To kevin.trent@carecentrix.com -Subject "No new unassigned computers"
-Body "Sorting Hat did not dectect any new servers in the WSUS unassigned computers group. No action was taken."}
}
Run
#REPORTING:
#Still working on this section. Sudo-code below.
#Servers Not Registered with WSUS:
#$wsus = get-wsusserver -name psus002 -portnumber 8530|get-wsuscomputer|select -ExpandProperty Fulldomainname
#$windows = Get-ADComputer -Properties * -Filter {(OperatingSystem -like "*Windows Server*")}|Select DNSHostName -ExpandProperty DNSHostName
#$nonreg = Compare-Object $wsus $windows|ForEach-Object {$_.InputObject}
#Servers still in the Unassigned Group
#$unassed = Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -ComputerTargetGroups "Unassigned Computers"|select Fulldomainname -ExpandProperty Fulldomainname

View File

@@ -0,0 +1,7 @@
#Enable VEEAM Job Scheduler at the end of maintenance
Add-PSSnapin -Name VeeamPSSnapIn
Connect-VBRServer -Server PVEB001
Get-VBRJob | where {$_.JobTargetType -eq "Backup" -and $_.IsScheduleEnabled -eq $true} | Enable-VBRJobSchedule
Disconnect-VBRServer
Send-MailMessage -SmtpServer smtp.ccx.carecentrix.com -To windows-admins@carecentrix.com -From backups@carecentrix.com -Subject "Veeam Backups Started" -Body "The Veeam Backup Jobs have been rescheduled after the infrastructure weekend.Please verify they are running as expected."
Exit

View File

@@ -0,0 +1,6 @@
#Disable VEEAM Job Schedule - Schedule to Run at 7pm on maintenance day
Add-PSSnapin -Name VeeamPSSnapIn
Connect-VBRServer -Server PVEB001
Get-VBRJob | where {$_.JobTargetType -eq "Backup" -and $_.IsScheduleEnabled -eq $true} | Disable-VBRJobSchedule
Disconnect-VBRServer

View File

@@ -0,0 +1,68 @@
<#
$ErrorActionPreference = "Ignore"
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob}
#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below.
#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}}
#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group"
Read-Host -Prompt "Press Enter to exit"
#>
#################################################################################################################################
#$ErrorActionPreference = "Ignore"
#$WSUSGroup = Read-Host "Enter Target Group Name"
#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
$servers = "W2012A","W2012B","slfkjsdl"
$WSUSGroup = "Test GGroupp"
$Location = Split-Path $MyInvocation.MyCommand.Path -Parent
$Dte = Get-Date -UFormat %m-%d-%Y
$Collect_Jobs = @()
$Patch_Job = @()
$servers | Out-File $Location\Patching-Day\"$WSUSGroup"-Server-Patching-Today-$Dte.txt
$servers | Out-File E:\WSUS_Scripts\Patching-Day\"$WSUSGroup"-Server-Patching-Today-$Dte.txt
Foreach ($server in $servers) {
Invoke-Command $server -ErrorAction SilentlyContinue {
New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Started" -ErrorAction SilentlyContinue
New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Finished" -ErrorAction SilentlyContinue
New-EventLog -LogName System -Source "Powershell-Reboot-After-Patching" -ErrorAction SilentlyContinue
Write-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell"
}#endInvoke
#Install-WindowsUpdate -ComputerName $server -AsJob
$Patch_Job += Start-Job -ScriptBlock { Param($server) Install-WindowsUpdate -ComputerName $server } -Name "$server-Patching" -ArgumentList $server
}#endForeach
$Patch_Job | Export-Csv $Location\Patching-Day\Patching-Jobs-$Dte.csv -NoTypeInformation
$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\Collect-Patching-Jobs-$Dte.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\Jobs-ChildJobs-$Dte.csv -NoTypeInformation
$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv E:\WSUS_Scripts\Patching-Day\Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation
#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below.
#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}}
#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group"
$servers | % { Get-EventLog -LogName Application -ComputerName $_ -ErrorAction SilentlyContinue | ? { $_.EventID -eq '7890' -and $_.TimeWritten -like "*$Dte*" } }
#Collect event log

View File

@@ -0,0 +1,35 @@
Import-Module ActiveDirectory
Import-Module WindowsUpdate
$ServerList = Import-Csv 'C:\Users\abamaso-ccxadmin\Desktop\CompletedProd_WindowsServers - Classifications.csv'
$AllServers = @()
foreach ($Server in $ServerList) {
$patchingtier = $Server.Classification
$ServerObject = New-Object psobject
$ComputerValidation = $null
$WSUSComputerObject = Get-WsusServer -Name psus002 -PortNumber 8530|Get-WsusComputer -NameIncludes $server.'Server Name'
$ComputerValidation = $wsuscomputerobject.FullDomainName
$ServerObject | Add-Member -MemberType NoteProperty -Name "Server Name" -Value $server.'Server Name'
$ServerObject | Add-Member -MemberType NoteProperty -Name "Operating System" -Value $server.'Operating System'
$ServerObject | Add-Member -MemberType NoteProperty -Name "Application" -Value $server.Application
if ($ComputerValidation -eq $null) {
$ServerObject | Add-Member -MemberType NoteProperty -Name "WSUS Status" -Value "Server is not in WSUS"
}
else {
$ServerObject | Add-Member -MemberType NoteProperty -Name "WSUS Status" -Value "Server is in WSUS"
}
$AllServers +=$ServerObject
Write-host $Server.'Server Name'" checked in WSUS"
}
$AllServers | export-csv C:\Users\abamaso-ccxadmin\Desktop\WSUSComputers.csv

View File

@@ -0,0 +1,110 @@
<#
$ErrorActionPreference = "Ignore"
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob}
#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below.
#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}}
#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group"
Read-Host -Prompt "Press Enter to exit"
#>
#################################################################################################################################
#$ErrorActionPreference = "Ignore"
#$servers = "W2012A","W2012B","slfkjsdl"
#$WSUSGroup = "Test GGroupppppp"
#################################################################################################################################
If(Test-Path E:\WSUS_Scripts\Lock_Script.txt) {
Write-Host "The Script is locked for protection. If you are not running it by mistake - Delete the file (E:\WSUS_Scripts\Lock_Script.txt) and run the Script again" -ForegroundColor Yellow
Break
}
Else { New-Item -Path E:\WSUS_Scripts -Name Lock_Script.txt -ItemType File }
#################################################################################################################################
Get-Job | Remove-Job
$Location = Split-Path $MyInvocation.MyCommand.Path -Parent
############################################################
#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt
$Current_Month = (Get-Date -UFormat %B)
############################################################
$Dte = Get-Date -UFormat %m-%d-%Y
$Collect_Jobs = @()
$Patch_Job = @()
$Failed_Jobs = @()
$Receive_Jobs = @()
If(!(Test-Path E:\WSUS_Scripts\Patching-Day\$WSUSGroup-$Current_Month-Patching)) { New-Item -Path "E:\WSUS_Scripts\Patching-Day" -ItemType Directory -Name $WSUSGroup-$Current_Month-Patching }
$servers = ""
$WSUSGroup = Read-Host "Enter Target Group Name"
#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select -ExpandProperty Fulldomainname
$Group_Folder = "$WSUSGroup-$Current_Month-Patching"
$Servers_Reboot_Only = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\CCXQ1-November-Prep-Files\Manual-$WSUSGroup-OperatingSystems-$Current_Month.csv
$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\CCXQ1-November-Prep-Files\$WSUSGroup-Target-Group-Computers-$Current_Month.csv | select -ExpandProperty FullDomainName
$servers = $servers | ? { $_ -notin $Servers_Reboot_Only.FullDomainName }
#$Failed_Ping_Test = gc $Location\Files\$WSUSGroup-Ping-Failed-$Current_Month.txt
#$servers = $servers | ? { $_ -notin $Failed_Ping_Test }
$servers | Out-File $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Today-$Dte.txt
$servers | Out-File E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Today-Backup-$Dte.txt
Foreach ($server in $servers) {
New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -ComputerName $server -verbose
New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -ComputerName $server -verbose
New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -ComputerName $server -verbose
Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Remote" -ComputerName $server -ErrorAction SilentlyContinue -verbose
$Patch_Job += Start-Job -ScriptBlock { Param($server) WindowsUpdate\Install-WindowsUpdate -ComputerName $server } -Name "$WSUSGroup-$server-Patching" -ArgumentList $server
Invoke-Command $server -ErrorAction SilentlyContinue {
New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -verbose
New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -verbose
New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -verbose
Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Invoke" -verbose
}#endInvoke
}#endForeach
#Get-Job
$Patch_Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte.csv -NoTypeInformation
$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Collect-Patching-Jobs-$Dte.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Jobs-ChildJobs-$Dte.csv -NoTypeInformation
$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation
<#
$Failed_Jobs += $Patch_Job | ? { $_.State -eq "Failed" }
$Failed_Jobs | ft -autosize
$Failed_Jobs | Export-Csv "E:\WSUS_Scripts\Patching-Day\NCRA - Quality Assurance Servers-November-Patching\failed-jobs.csv" -NoTypeInformation
#>
### Running Count
## ( $Patch_Job | ? { $_.State -eq "Running" } ).count
## ( $Patch_Job | ? { $_.State -eq "Completed" } ).count
## ( $Patch_Job | ? { $_.State -eq "Failed" } ).count

View File

@@ -0,0 +1,110 @@
<#
$ErrorActionPreference = "Ignore"
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob}
#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below.
#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}}
#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group"
Read-Host -Prompt "Press Enter to exit"
#>
#################################################################################################################################
#$ErrorActionPreference = "Ignore"
#$servers = "W2012A","W2012B","slfkjsdl"
#$WSUSGroup = "Test GGroupppppp"
#################################################################################################################################
If(Test-Path E:\WSUS_Scripts\Lock_Script.txt) {
Write-Host "The Script is locked for protection. If you are not running it by mistake - Delete the file (E:\WSUS_Scripts\Lock_Script.txt) and run the Script again" -ForegroundColor Yellow
Break
}
Else { New-Item -Path E:\WSUS_Scripts -Name Lock_Script.txt -ItemType File }
#################################################################################################################################
Get-Job | Remove-Job
$Location = Split-Path $MyInvocation.MyCommand.Path -Parent
############################################################
#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt
$Current_Month = (Get-Date -UFormat %B)
############################################################
$Dte = Get-Date -UFormat %m-%d-%Y
$Collect_Jobs = @()
$Patch_Job = @()
$Failed_Jobs = @()
$Receive_Jobs = @()
If(!(Test-Path E:\WSUS_Scripts\Patching-Day\$WSUSGroup-$Current_Month-Patching)) { New-Item -Path "E:\WSUS_Scripts\Patching-Day" -ItemType Directory -Name $WSUSGroup-$Current_Month-Patching }
$servers = ""
$WSUSGroup = Read-Host "Enter Target Group Name"
#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select -ExpandProperty Fulldomainname
$Group_Folder = "$WSUSGroup-$Current_Month-Patching"
$Servers_Reboot_Only = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\CCXQ1-November-Prep-Files\Manual-$WSUSGroup-OperatingSystems-$Current_Month.csv
$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\CCXQ1-November-Prep-Files\$WSUSGroup-Target-Group-Computers-$Current_Month.csv | select -ExpandProperty FullDomainName
$servers = $servers | ? { $_ -notin $Servers_Reboot_Only.FullDomainName }
#$Failed_Ping_Test = gc $Location\Files\$WSUSGroup-Ping-Failed-$Current_Month.txt
#$servers = $servers | ? { $_ -notin $Failed_Ping_Test }
$servers | Out-File $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Today-$Dte.txt
$servers | Out-File E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Today-Backup-$Dte.txt
Foreach ($server in $servers) {
New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -ComputerName $server -verbose
New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -ComputerName $server -verbose
New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -ComputerName $server -verbose
Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Remote" -ComputerName $server -ErrorAction SilentlyContinue -verbose
$Patch_Job += Start-Job -ScriptBlock { Param($server) WindowsUpdate\Install-WindowsUpdate -ComputerName $server } -Name "$WSUSGroup-$server-Patching" -ArgumentList $server
Invoke-Command $server -ErrorAction SilentlyContinue {
New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -verbose
New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -verbose
New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -verbose
Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Invoke" -verbose
}#endInvoke
}#endForeach
#Get-Job
$Patch_Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte.csv -NoTypeInformation
$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Collect-Patching-Jobs-$Dte.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Jobs-ChildJobs-$Dte.csv -NoTypeInformation
$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation
<#
$Failed_Jobs += $Patch_Job | ? { $_.State -eq "Failed" }
$Failed_Jobs | ft -autosize
$Failed_Jobs | Export-Csv "E:\WSUS_Scripts\Patching-Day\NCRA - Quality Assurance Servers-November-Patching\failed-jobs.csv" -NoTypeInformation
#>
### Running Count
## ( $Patch_Job | ? { $_.State -eq "Running" } ).count
## ( $Patch_Job | ? { $_.State -eq "Completed" } ).count
## ( $Patch_Job | ? { $_.State -eq "Failed" } ).count

View File

@@ -0,0 +1,70 @@
<#
$ErrorActionPreference = "Ignore"
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob}
#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below.
#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}}
#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group"
Read-Host -Prompt "Press Enter to exit"
#>
#################################################################################################################################
#$ErrorActionPreference = "Ignore"
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
#$servers = "W2012A","W2012B","slfkjsdl"
#$WSUSGroup = "Test GGroupppppp"
$Location = Split-Path $MyInvocation.MyCommand.Path -Parent
$Dte = Get-Date -UFormat %m-%d-%Y
$Collect_Jobs = @()
$Patch_Job = @()
$servers | Out-File $Location\Patching-Day\"$WSUSGroup"-Server-Patching-Today-$Dte.txt
$servers | Out-File E:\WSUS_Scripts\Patching-Day\"$WSUSGroup"-Server-Patching-Today-Backup-$Dte.txt
Foreach ($server in $servers) {
New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -ComputerName $server
New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -ComputerName $server
New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -ComputerName $server
Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Remote" -ComputerName $server -ErrorAction SilentlyContinue
$Patch_Job += Start-Job -ScriptBlock { Param($server) Install-WindowsUpdate -ComputerName $server } -Name "$server-Patching" -ArgumentList $server
Invoke-Command $server -ErrorAction SilentlyContinue {
New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue
New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue
New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue
Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Invoke"
}#endInvoke
Install-WindowsUpdate -ComputerName $server -AsJob
}#endForeach
Get-Job
$Patch_Job | Export-Csv $Location\Patching-Day\Patching-Jobs-$Dte.csv -NoTypeInformation
$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\Collect-Patching-Jobs-$Dte.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\Jobs-ChildJobs-$Dte.csv -NoTypeInformation
$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv E:\WSUS_Scripts\Patching-Day\Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation

View File

@@ -0,0 +1,48 @@
$Location = Split-Path $MyInvocation.MyCommand.Path -Parent
#################################################################################################################################
$Dte = Get-Date -UFormat %m-%d-%Y
$Current_Month = (Get-Date -UFormat %B)
$WSUSGroup = "NCRA - Development Servers"
$Group_Folder = "$WSUSGroup-$Current_Month-Patching"
$Group = "NCRA - Development Servers"
#################################################################################################################################
#$WSUSGroup = Read-Host "Enter Target Group Name"
#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
$servers = Import-Csv E:\WSUS_Scripts\Files\*$Group*.csv
#$servers = "w2012a","w2012b","testtest"
$servers | Out-File $Location\Patching-Day\$Group_Folder\$WSUSGroup-Servers-Rebooting-$Dte.txt -ErrorAction SilentlyContinue
$servers | Out-File E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Servers-Rebooting-Backup-$Dte.txt -ErrorAction SilentlyContinue
$Patch_Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue
$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue
Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Get-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue
Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Get-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue
$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Collect-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Collect-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation
Foreach ($server in $servers) {
Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Remote" -ComputerName $server.Computer -ErrorAction SilentlyContinue
Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Remote" -ComputerName $server.Computer -ErrorAction SilentlyContinue
Invoke-Command $server.Computer -ErrorAction SilentlyContinue {
#New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Finished" -ErrorAction SilentlyContinue
#New-EventLog -LogName System -Source "Powershell-Reboot-After-Patching" -ErrorAction SilentlyContinue
Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Invoke" -ErrorAction SilentlyContinue
Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Invoke" -ErrorAction SilentlyContinue
}#endInvoke
Restart-Computer -ComputerName $server.Computer -Force -Verbose
}#endForeach
<#
$servers.computer | % { $T = Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue
If($T) { Write-Host "Server $_ -- Responding" -ForegroundColor Green } Else { Write-Host "Server $_ -- Not Responding" -ForegroundColor Red }
}
#>

View File

@@ -0,0 +1,32 @@
$Location = Split-Path $MyInvocation.MyCommand.Path -Parent
$Dte = Get-Date -UFormat %m-%d-%Y
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
$servers | Out-File $Location\Patching-Day\"$WSUSGroup"-Servers-Rebooting-$Dte.txt -ErrorAction SilentlyContinue
$servers | Out-File E:\WSUS_Scripts\Patching-Day\"$WSUSGroup"-Servers-Rebooting-Backup-$Dte.txt -ErrorAction SilentlyContinue
$Patch_Job | Export-Csv $Location\Patching-Day\Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue
$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue
Get-Job | Export-Csv $Location\Patching-Day\Patching-Get-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue
Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Get-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue
$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\Patching-Collect-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\Patching-Collect-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation
Foreach ($server in $servers) {
Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Remote" -ComputerName $server -ErrorAction SilentlyContinue
Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Remote" -ComputerName $server -ErrorAction SilentlyContinue
Invoke-Command $server -ErrorAction SilentlyContinue {
#New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Finished" -ErrorAction SilentlyContinue
#New-EventLog -LogName System -Source "Powershell-Reboot-After-Patching" -ErrorAction SilentlyContinue
Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Invoke" -ErrorAction SilentlyContinue
Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Invoke" -ErrorAction SilentlyContinue
}#endInvoke
Restart-Computer -ComputerName $server -Force -Verbose
}#endForeach

View File

@@ -0,0 +1,10 @@
$ErrorActionPreference = "Ignore"
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob}
#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below.
#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}}
#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group"
Read-Host -Prompt "Press Enter to exit"

View File

@@ -0,0 +1,3 @@
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}

View File

@@ -0,0 +1,141 @@
$ServerList1 = Get-ADComputer -Filter {(Enabled -eq $true)} -SearchBase "OU=Servers,OU=NCRA,DC=ccx,DC=carecentrix,DC=com" | Select-Object DNSHostName
$ServerList2 = Get-ADComputer -Filter {(Enabled -eq $true)} -SearchBase "OU=Servers,OU=FLT2,DC=ccx,DC=carecentrix,DC=com" | Select-Object DNSHostName
$ServerList3 = Get-ADComputer -Filter {(Enabled -eq $true)} -SearchBase "OU=Servers,OU=AZPH,DC=ccx,DC=carecentrix,DC=com" | Select-Object DNSHostName
$ServerList4 = Get-ADComputer -Filter {(Enabled -eq $true)} -SearchBase "OU=Servers,OU=CLVA1,DC=ccx,DC=carecentrix,DC=com" | Select-Object DNSHostName
$ServerList5 = Get-ADComputer -Filter {(Enabled -eq $true)} -SearchBase "OU=Servers,OU=CTHA,DC=ccx,DC=carecentrix,DC=com" | Select-Object DNSHostName
$ServerList6 = Get-ADComputer -Filter {(Enabled -eq $true)} -SearchBase "OU=Servers,OU=KSOP,DC=ccx,DC=carecentrix,DC=com" | Select-Object DNSHostName
$ServerList = $ServerList1+$ServerList2+$ServerList3+$ServerList4+$ServerList5+$ServerList6
$ServerReport = @()
$port1 = "8530"
$port2 = "8531"
$wsusserver = "psus002.ccx.carecentrix.com"
foreach ($Server in $ServerList) {
$ServerName = $Server.DNSHostName
$pssession = New-PSSession -ComputerName $ServerName -ErrorAction SilentlyContinue
$CurrentServer = New-Object System.Object
$CurrentServer | Add-Member -MemberType NoteProperty -Name "Name" -Value $ServerName
#Enter-PSSession $pssession
if ($null -ne $pssession){
write-host "Connected to $ServerName"
$CurrentServer | Add-Member -MemberType NoteProperty -Name "Status" -Value "Accessible"
$CurrentServer.Name = $ServerName
#Check HTTP Port
#Clear Port Variables
$port8530= @()
$port8531= @()
$port8530 = Invoke-Command -Session $pssession -ScriptBlock {invoke-webrequest http://psus002.ccx.carecentrix.com:8530/CLientWebService/Client.asmx -UseBasicParsing} -ErrorAction SilentlyContinue
if ($port8530.StatusCode -eq "200"){
Write-host "Port 8530 Accessible"
$CurrentServer | Add-Member -MemberType NoteProperty -Name "8530" -Value "Open"
}
elseif ($null -eq $port8530) {
$TestNetConnection = New-Object Net.Sockets.TcpClient
$testnetconnection.connect($wsusserver,$port1)
if ($testnetconnection.Connected){
$TestNetConnection.Close()
$CurrentServer | Add-Member -MemberType NoteProperty -Name "8530" -Value "Open"
}
else {
$CurrentServer | Add-Member -MemberType NoteProperty -Name "8530" -Value "Unable to Verify"
Write-host "Invoke Webrequest not recognized"
}
}
else {
$CurrentServer | Add-Member -MemberType NoteProperty -Name "8530" -Value "Closed"
Write-host "Port 8531 Inaccessible"
}
# Check HTTPS Port
$port8531 = Invoke-Command -Session $pssession -ScriptBlock {invoke-webrequest https://psus002.ccx.carecentrix.com:8531/CLientWebService/Client.asmx -UseBasicParsing} -ErrorAction SilentlyContinue
if ($port8531.StatusCode -eq "200"){
$CurrentServer | Add-Member -MemberType NoteProperty -Name "8531" -Value "Open"
Write-host "Port 8531 Accessible"
}
elseif ($null -eq $port8531) {
$TestNetConnection = New-Object Net.Sockets.TcpClient
$testnetconnection.connect($wsusserver,$port2)
if ($testnetconnection.Connected){
$TestNetConnection.Close()
$CurrentServer | Add-Member -MemberType NoteProperty -Name "8531" -Value "Open"
}
else{
$CurrentServer | Add-Member -MemberType NoteProperty -Name "8531" -Value "Unable to Verify"
Write-host "Invoke Webrequest not recognized"
}
}
else {
$CurrentServer | Add-Member -MemberType NoteProperty -Name "8531" -Value "Blocked"
Write-host "Port 8531 Inaccessible"
}
#Check C: Drive Space
$DriveCheck =Invoke-Command -Session $pssession -ScriptBlock {get-WmiObject win32_logicaldisk -Filter "DeviceID='C:'"}
$HDFreespace = [Math]::Round($DriveCheck.Freespace / 1GB)
$HDSize =[Math]::Round($DriveCheck.Size / 1GB)
$CurrentServer | Add-Member -MemberType NoteProperty -Name "C: Size" -Value $HDSize
$CurrentServer | Add-Member -MemberType NoteProperty -Name "C: Freespace" -Value $HDFreespace
if ($HDFreespace -lt 5) {
$CurrentServer | Add-Member -MemberType NoteProperty -Name "SpaceCheck" -Value "Consider adding Space to C:"
Write-host "C: Drive does not have enough space"
}
else {
$CurrentServer | Add-Member -MemberType NoteProperty -Name "SpaceCheck" -Value "Server has sufficient space for Windows Updates"
Write-host "C: has plenty of space"
}
$DriveCheck = @()
#Windows Update Details
$failedupdates = Invoke-Command -Session $pssession -ScriptBlock {
$Session = New-Object -ComObject "Microsoft.Update.Session"
$Searcher = $Session.CreateUpdateSearcher()
$historyCount = $Searcher.GetTotalHistoryCount()
$Searcher.QueryHistory(0, $historyCount) | Select-Object @{Name="Computer"; Expression={$Computer}}, Date,
@{name="Operation"; expression={switch($_.operation){
1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}},
@{name="Status"; expression={switch($_.resultcode){
1 {"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"};
4 {"Failed"}; 5 {"Aborted"}
}}},Title| Where-Object {$_.Status -eq "Failed"}
}
$failedupdates |Export-Csv -NoType "E:\Windows Update Failures\UpdateAudit-$ServerName-Failed-WindowsUpdates.csv"
# Exit-PSSession
$ServerReport += $CurrentServer
Get-PSSession | Remove-PSSession
#Copy-Item -Path \\$ServerName\Users\abamaso-ccxadmin\Desktop\UpdateAudit-$ServerName-Failed-WindowsUpdates.csv -Destination 'C:\Users\abamaso-ccxadmin\Desktop\WIndows Update Failures'
}
#outSide PSSession if
else {
$CurrentServer | Add-Member -MemberType NoteProperty -Name "Status" -Value "Inaccessible"
Write-host "$ServerName Inaccessible"
$ServerReport += $CurrentServer
}
}
#outside for each
$ServerReport | Export-Csv "E:\Windows Update Failures\ServerReport.csv"

View File

@@ -0,0 +1,26 @@
$WSUSGroup = Read-Host "Enter Target Group Name"
$Computers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
foreach ($computer in $computers){
if(!(Test-Connection -Cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet))
{write-host "cannot reach $computer" -f red}
else {$Session = New-Object -ComObject "Microsoft.Update.Session"
$Searcher = $Session.CreateUpdateSearcher()
$historyCount = $Searcher.GetTotalHistoryCount()
$Searcher.QueryHistory(0, $historyCount) | Select-Object @{Name="Computer"; Expression={$Computer}}, Date,
@{name="Operation"; expression={switch($_.operation){
1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}},
@{name="Status"; expression={switch($_.resultcode){
1 {"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"};
4 {"Failed"}; 5 {"Aborted"}
}}},Title| Where {$_.Status -eq "In Progress"}|Write-Host}}

View File

@@ -0,0 +1,27 @@
PROD:
NCRA
$Host.UI.RawUI.WindowTitle = "NCRA - AD - Servers"
$Host.UI.RawUI.WindowTitle = "NCRA - Application - Prod"
$Host.UI.RawUI.WindowTitle = "NCRA - BizTalk - PROD"
$Host.UI.RawUI.WindowTitle = "NCRA - Edifecs - PROD"
$Host.UI.RawUI.WindowTitle = "NCRA - Exchange - PROD"
$Host.UI.RawUI.WindowTitle = "NCRA - File Servers - PROD"
$Host.UI.RawUI.WindowTitle = "NCRA - Mail Terminal Servers - PROD"
$Host.UI.RawUI.WindowTitle = "NCRA - Remote Desktop - PROD"
$Host.UI.RawUI.WindowTitle = "NCRA - SQL - PROD"
$Host.UI.RawUI.WindowTitle = "NCRA - Terminal Servers - PROD"
$Host.UI.RawUI.WindowTitle = "NCRA - Verint - PROD"
$Host.UI.RawUI.WindowTitle = "NCRA - Vistar Terminal Servers - PROD"
$Host.UI.RawUI.WindowTitle = "NCRA - Web - PROD"
OTHERS:
$Host.UI.RawUI.WindowTitle = "CTHA - Production Servers"
$Host.UI.RawUI.WindowTitle = "FLT2 - Application - PROD"
MANUAL:
$Host.UI.RawUI.WindowTitle = "CyberArc - PROD"
$Host.UI.RawUI.WindowTitle = "Exchange - PROD"
$Host.UI.RawUI.WindowTitle = "Infrastructure Weekend"
$Host.UI.RawUI.WindowTitle = "Last AD Controller"
$Host.UI.RawUI.WindowTitle = "Tidal - PROD"

View File

@@ -0,0 +1,27 @@
psrs001
psql007
psis002
pcpr001
psql015
psrs003
prsh182-failed connect
prsh028-failed connect
prsh175
pedi116
prsh029-failed connect
pvrt003
prsh014-failed connect
prsh018-failed connect
prsh002-failed connect
pedi114-failed connect
pedi111-failed connect
pedi115-failed connect
pspt001
pbiz122
pbiz124
pbiz125
pbiz126
pbiz123
pbiz121

View File

@@ -0,0 +1,28 @@
$servers = Import-Csv "E:\WSUS_Scripts\Patching-Day\December-2019\Tier0-December-Patching\ReRun\.csv" | select name
Get-Job | Remove-Job
$S2 = @()
$T = @()
$servers | % { $T += $_.Name.Split('#')[1] }
$P_Job_Failed_Servers = @()
Foreach ($S in $T) {
#$S = $T.name
$P_Job_Failed_Servers += Start-Job -ScriptBlock { Param($S) WindowsUpdate\Install-WindowsUpdate -ComputerName $S } -Name "$WSUSGroup-#$S#-Patching" -ArgumentList $S
}#endForeach
$P_Job_Failed_Servers | ft -AutoSize
<#
$Failed_J = Get-Job | ? { $_.State -eq "Failed" } | Select Name
$Failed_J | % { $S2 += $_.Name.Split('#')[1] }
#>

View File

@@ -0,0 +1,45 @@
Restart-Computer -ComputerName qsch013.ccx.carecentrix.com -Force
Write-Host "qsch013.ccx.carecentrix.com restart initiated"
Start-Sleep -Seconds 180
$ServerStatusCheck = Test-NetConnection -ComputerName qsch013.ccx.carecentrix.com
$ServerStatusOnline = $ServerStatusCheck.PingSucceeded
if ($ServerStatusOnline -eq $true) {
Write-Host "qsch013 is Online"
}
else {
Write-Host "qsch013 is not online"
}
Restart-Computer -ComputerName qsch014.ccx.carecentrix.com -Force
Write-Host "qsch014.ccx.carecentrix.com restart initiated"
Start-Sleep -Seconds 180
$ServerStatusCheck = Test-NetConnection -ComputerName qsch014.ccx.carecentrix.com
$ServerStatusOnline = $ServerStatusCheck.PingSucceeded
if ($ServerStatusOnline -eq $true) {
Write-Host "qsch014 is Online"
}
else {
Write-Host "qsch014 is not online"
}
Restart-Computer -ComputerName qsch011.ccx.carecentrix.com -Force
Write-Host "qsch011.ccx.carecentrix.com restart initiated"
Start-Sleep -Seconds 180
$ServerStatusCheck = Test-NetConnection -ComputerName qsch011.ccx.carecentrix.com
$ServerStatusOnline = $ServerStatusCheck.PingSucceeded
if ($ServerStatusOnline -eq $true) {
Write-Host "qsch011 is Online"
}
else {
Write-Host "qsch011 is not online"
}
Restart-Computer -ComputerName qsch012.ccx.carecentrix.com -Force
Write-Host "qsch012.ccx.carecentrix.com restart initiated"
Start-Sleep -Seconds 180
$ServerStatusCheck = Test-NetConnection -ComputerName qsch012.ccx.carecentrix.com
$ServerStatusOnline = $ServerStatusCheck.PingSucceeded
if ($ServerStatusOnline -eq $true) {
Write-Host "qsch012 is Online"
}
else {
Write-Host "qsch012 is not online"
}

View File

@@ -0,0 +1,8 @@
$ErrorActionPreference = "Ignore"
Restart-Computer -ComputerName psch013.ccx.carecentrix.com -Force
Start-Sleep -Seconds 600
Restart-Computer -ComputerName psch014.ccx.carecentrix.com -Force
Start-Sleep -Seconds 600
Restart-Computer -ComputerName psch011.ccx.carecentrix.com -Force
Start-Sleep -Seconds 600
Restart-Computer -ComputerName psch012.ccx.carecentrix.com -Force

View File

@@ -0,0 +1,120 @@
<#
.SYNOPSIS
Reset-WindowsUpdate.ps1 - Resets the Windows Update components
.DESCRIPTION
This script will reset all of the Windows Updates components to DEFAULT SETTINGS.
.OUTPUTS
Results are printed to the console. Future releases will support outputting to a log file.
.NOTES
Written by: Ryan Nemeth
Find me on:
* My Blog: http://www.geekyryan.com
* Twitter: https://twitter.com/geeky_ryan
* LinkedIn: https://www.linkedin.com/in/ryan-nemeth-b0b1504b/
* Github: https://github.com/rnemeth90
* TechNet: https://social.technet.microsoft.com/profile/ryan%20nemeth/
Change Log
V1.00, 05/21/2015 - Initial version
V1.10, 09/22/2016 - Fixed bug with call to sc.exe
V1.20, 11/13/2017 - Fixed environment variables
#>
$arch = Get-WMIObject -Class Win32_Processor -ComputerName LocalHost | Select-Object AddressWidth
Write-Host "1. Stopping Windows Update Services..."
Stop-Service -Name BITS
Stop-Service -Name wuauserv
Stop-Service -Name appidsvc
Stop-Service -Name cryptsvc
Write-Host "2. Remove QMGR Data file..."
Remove-Item "$env:allusersprofile\Application Data\Microsoft\Network\Downloader\qmgr*.dat" -ErrorAction SilentlyContinue
Write-Host "3. Renaming the Software Distribution and CatRoot Folder..."
Rename-Item $env:systemroot\SoftwareDistribution SoftwareDistribution.bak -ErrorAction SilentlyContinue
Rename-Item $env:systemroot\System32\Catroot2 catroot2.bak -ErrorAction SilentlyContinue
Write-Host "4. Removing old Windows Update log..."
Remove-Item $env:systemroot\WindowsUpdate.log -ErrorAction SilentlyContinue
Write-Host "5. Resetting the Windows Update Services to defualt settings..."
"sc.exe sdset bits D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)"
"sc.exe sdset wuauserv D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)"
Set-Location $env:systemroot\system32
Write-Host "6. Registering some DLLs..."
regsvr32.exe /s atl.dll
regsvr32.exe /s urlmon.dll
regsvr32.exe /s mshtml.dll
regsvr32.exe /s shdocvw.dll
regsvr32.exe /s browseui.dll
regsvr32.exe /s jscript.dll
regsvr32.exe /s vbscript.dll
regsvr32.exe /s scrrun.dll
regsvr32.exe /s msxml.dll
regsvr32.exe /s msxml3.dll
regsvr32.exe /s msxml6.dll
regsvr32.exe /s actxprxy.dll
regsvr32.exe /s softpub.dll
regsvr32.exe /s wintrust.dll
regsvr32.exe /s dssenh.dll
regsvr32.exe /s rsaenh.dll
regsvr32.exe /s gpkcsp.dll
regsvr32.exe /s sccbase.dll
regsvr32.exe /s slbcsp.dll
regsvr32.exe /s cryptdlg.dll
regsvr32.exe /s oleaut32.dll
regsvr32.exe /s ole32.dll
regsvr32.exe /s shell32.dll
regsvr32.exe /s initpki.dll
regsvr32.exe /s wuapi.dll
regsvr32.exe /s wuaueng.dll
regsvr32.exe /s wuaueng1.dll
regsvr32.exe /s wucltui.dll
regsvr32.exe /s wups.dll
regsvr32.exe /s wups2.dll
regsvr32.exe /s wuweb.dll
regsvr32.exe /s qmgr.dll
regsvr32.exe /s qmgrprxy.dll
regsvr32.exe /s wucltux.dll
regsvr32.exe /s muweb.dll
regsvr32.exe /s wuwebv.dll
Write-Host "7) Removing WSUS client settings..."
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v AccountDomainSid /f
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v PingID /f
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v SusClientId /f
Write-Host "8) Resetting the WinSock..."
netsh winsock reset
netsh winhttp reset proxy
Write-Host "9) Delete all BITS jobs..."
Get-BitsTransfer | Remove-BitsTransfer
Write-Host "10) Attempting to install the Windows Update Agent..."
if($arch -eq 64){
wusa Windows8-RT-KB2937636-x64 /quiet
}
else{
wusa Windows8-RT-KB2937636-x86 /quiet
}
Write-Host "11) Starting Windows Update Services..."
Start-Service -Name BITS
Start-Service -Name wuauserv
Start-Service -Name appidsvc
Start-Service -Name cryptsvc
Write-Host "12) Forcing discovery..."
wuauclt /resetauthorization /detectnow
Write-Host "Process complete. Please reboot your computer."

View File

@@ -0,0 +1,12 @@
[DateTime]$Check_Date = "10/1/2019"
$Event_ID = "7890","7891"
"w2012a","w2012b" | % {
$Comp_Name = $_
Write-Host "Checking Server: $_"
$Event_ID | % {
$E_ID = $_
Write-Host "Checking EventID: $_"
Get-EventLog -LogName Application -ComputerName $Comp_Name | ? { $_.EventID -eq $E_ID -and $_.TimeGenerated -like "*$Check_Date*" } | select MachineName,EventID,EntryType,Source,Message,TimeGenerated,TimeWritten
}#end%
}#end%

View File

@@ -0,0 +1,110 @@
<#
$ErrorActionPreference = "Ignore"
$WSUSGroup = Read-Host "Enter Target Group Name"
$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
Foreach ($server in $servers) {Install-WindowsUpdate -ComputerName $server -AsJob}
#Function Restart {# Force Reboot of Group (when auto failed) un-rem and run line below.
#Foreach ($server in $servers) {Restart-Computer -ComputerName $server -Force}}
#Write-Host "Type Restart and press enter to reboot the $WSUSGroup WSUS Computer Group"
Read-Host -Prompt "Press Enter to exit"
#>
#################################################################################################################################
#$ErrorActionPreference = "Ignore"
#$servers = "W2012A","W2012B","slfkjsdl"
#$WSUSGroup = "Test GGroupppppp"
#################################################################################################################################
If(Test-Path E:\WSUS_Scripts\Lock_Script.txt) {
Write-Host "The Script is locked for protection. If you are not running it by mistake - Delete the file (E:\WSUS_Scripts\Lock_Script.txt) and run the Script again" -ForegroundColor Yellow
Break
}
Else { New-Item -Path E:\WSUS_Scripts -Name Lock_Script.txt -ItemType File }
#################################################################################################################################
Get-Job | Remove-Job
$Location = Split-Path $MyInvocation.MyCommand.Path -Parent
############################################################
#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt
$Current_Month = (Get-Date -UFormat %B)
############################################################
$Dte = Get-Date -UFormat %m-%d-%Y
$Collect_Jobs = @()
$Patch_Job = @()
$Failed_Jobs = @()
$Receive_Jobs = @()
If(!(Test-Path E:\WSUS_Scripts\Patching-Day\$WSUSGroup-$Current_Month-Patching)) { New-Item -Path "E:\WSUS_Scripts\Patching-Day" -ItemType Directory -Name $WSUSGroup-$Current_Month-Patching }
$servers = ""
$WSUSGroup = Read-Host "Enter Target Group Name"
#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select -ExpandProperty Fulldomainname
$Group_Folder = "$WSUSGroup-$Current_Month-Patching"
#$Servers_Reboot_Only = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\CCXQ1-November-Prep-Files\Manual-$WSUSGroup-OperatingSystems-$Current_Month.csv
$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Target-Group-Computers-$Current_Month.csv | select -ExpandProperty FullDomainName
$servers = $servers | ? { $_ -notin $Servers_Reboot_Only.FullDomainName }
#$Failed_Ping_Test = gc $Location\Files\$WSUSGroup-Ping-Failed-$Current_Month.txt
#$servers = $servers | ? { $_ -notin $Failed_Ping_Test }
$servers | Out-File $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Today-$Dte.txt
$servers | Out-File E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Today-Backup-$Dte.txt
Foreach ($server in $servers) {
New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -ComputerName $server -verbose
New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -ComputerName $server -verbose
New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -ComputerName $server -verbose
Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Remote" -ComputerName $server -ErrorAction SilentlyContinue -verbose
$Patch_Job += Start-Job -ScriptBlock { Param($server) WindowsUpdate\Install-WindowsUpdate -ComputerName $server } -Name "$WSUSGroup-#$server#-Patching" -ArgumentList $server
Invoke-Command $server -ErrorAction SilentlyContinue {
New-EventLog -LogName Application -Source "Patching-Started" -ErrorAction SilentlyContinue -verbose
New-EventLog -LogName Application -Source "Patching-Finished" -ErrorAction SilentlyContinue -verbose
New-EventLog -LogName System -Source "Reboot-After-Patching" -ErrorAction SilentlyContinue -verbose
Write-EventLog -LogName Application -Source "Patching-Started" -EntryType Information -EventId 7890 -Message "Server Patching Started with Powershell - Invoke" -verbose
}#endInvoke
}#endForeach
#Get-Job
$Patch_Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte.csv -NoTypeInformation
$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Collect-Patching-Jobs-$Dte.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Collect-Patching-Jobs-Backup-$Dte.csv -NoTypeInformation
$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Jobs-ChildJobs-$Dte.csv -NoTypeInformation
$Patch_Job | Select @{n="Server";e={$_.Name.Split('-')[0]}},@{n="MainJobID";e={$_.ID}},@{n="MainJobName";e={$_.Name}},@{n="ChildJobID";e={$_.Childjobs.ID}},@{n="ChildJobState";e={$_.Childjobs.State}},PSBeginTime,PSEndTime,Command | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Jobs-ChildJobs-Backup-$Dte.csv -NoTypeInformation
<#
$Failed_Jobs += $Patch_Job | ? { $_.State -eq "Failed" }
$Failed_Jobs | ft -autosize
$Failed_Jobs | Export-Csv "E:\WSUS_Scripts\Patching-Day\NCRA - Quality Assurance Servers-November-Patching\failed-jobs.csv" -NoTypeInformation
#>
### Running Count
## ( $Patch_Job | ? { $_.State -eq "Running" } ).count
## ( $Patch_Job | ? { $_.State -eq "Completed" } ).count
## ( $Patch_Job | ? { $_.State -eq "Failed" } ).count

View File

@@ -0,0 +1,67 @@

$Location = Split-Path $MyInvocation.MyCommand.Path -Parent
#################################################################################################################################
$Dte = Get-Date -UFormat %m-%d-%Y
$Current_Month = (Get-Date -UFormat %B)
#$WSUSGroup = gc H:\Scripts\Patching\_Group-Config-File\Config-WSUS-Group.txt
#$Group_Folder = "$WSUSGroup-$Current_Month-Patching"
#$Group = "NCRA - Development Servers"
#################################################################################################################################
$servers = ""
$WSUSGroup = Read-Host "Enter Target Group Name"
#$servers = Get-WsusComputer -ComputerTargetGroups "$WSUSGroup" -IncludeSubgroups|select Fulldomainname -ExpandProperty Fulldomainname
$Group_Folder = "$WSUSGroup-$Current_Month-Patching"
#$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\December-2019\$Group_Folder\CCXQ1-November-Prep-Files\$WSUSGroup-Target-Group-Computers-$Current_Month.csv | select -ExpandProperty FullDomainName
$servers = Import-Csv E:\WSUS_Scripts\Patching-Day\December-2019\$WSUSGroup.csv | select -ExpandProperty FullDomainName
$servers | Out-File $Location\Patching-Day\$Group_Folder\$WSUSGroup-Servers-Rebooting-$Dte.txt -ErrorAction SilentlyContinue
$servers | Out-File E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Servers-Rebooting-Backup-$Dte.txt -ErrorAction SilentlyContinue
#$servers = $servers | ? { $_ -ne "qadf001.ccx.carecentrix.com"}
$Patch_Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue
$Patch_Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue
Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Get-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation -ErrorAction SilentlyContinue
Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Get-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation -ErrorAction SilentlyContinue
$Collect_Jobs = Get-Job | Export-Csv $Location\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Collect-Patching-Jobs-$Dte-Before-Reboot.csv -NoTypeInformation
$Collect_Jobs = Get-Job | Export-Csv E:\WSUS_Scripts\Patching-Day\$Group_Folder\$WSUSGroup-Patching-Collect-Patching-Jobs-$Dte-Before-Reboot-Backup.csv -NoTypeInformation
Foreach ($server in $servers) {
Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Remote" -ComputerName $server -ErrorAction SilentlyContinue
Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Remote" -ComputerName $server -ErrorAction SilentlyContinue
Invoke-Command $server -ErrorAction SilentlyContinue {
#New-EventLog -LogName Application -Source "Powershell-WSUS-Patching-Finished" -ErrorAction SilentlyContinue
#New-EventLog -LogName System -Source "Powershell-Reboot-After-Patching" -ErrorAction SilentlyContinue
Write-EventLog -LogName Application -Source "Patching-Finished" -EntryType Information -EventId 7891 -Message "Powershell-WSUS-Patching-Finished - Invoke" -ErrorAction SilentlyContinue
Write-EventLog -LogName System -Source "Reboot-After-Patching" -EntryType Information -EventId 7892 -Message "Server Rebooting After Patching - Invoke" -ErrorAction SilentlyContinue
}#endInvoke
Restart-Computer -ComputerName $server -Force -Verbose
}#endForeach
<#
$servers | % { $T = Test-Connection -ComputerName $_ -Count 1 -ErrorAction SilentlyContinue
If($T) { Write-Host "Server $_ -- Responding" -ForegroundColor Green } Else { Write-Host "Server $_ -- Not Responding" -ForegroundColor Red }
}
#>
# $Servers | % { Get-EventLog -LogName System -ComputerName $_.computer | ? { $_.EventID -eq '7893' } }
# $Servers | % { gwmi win32_operatingsystem -ComputerName $_ | select @{n="Server";e={$_.PSComputername}},@{n="LastBootup";e={$_.Converttodatetime($_.LastBootUpTime)}}}