I just published my latest version of the PoshWSUS module to CodePlex which has some updated code on a few functions and some other bug fixes. Also, there are 8 new commands that are available with this latest version of the module. The majority of these commands deal with creating and working with the Approval Rules in WSUS that can be set to automatically approve specific types of patches for specific groups. The other functions deal with connecting to the database server that the WSUS database is hosted on and looking at the update classifications in WSUS.
New Commands
- New-WSUSInstallApprovalRule
- Used to create a new WSUS Install Approval Rule
- Set-WSUSInstallApprovalRule
- Configures an existing Approval Rule. Also allows you to Disable/Enable a rule.
- Get-WSUSInstallApprovalRules
- Lists all Approval Rules on WSUS
- Remove-WSUSInstallApprovalRule
- Removes a specified Approval Rule
- Start-WSUSInstallApprovalRule
- Runs a specified Approval Rule
- Connect-WSUSDatabaseServer
- Connects to and lists configuration of SQL Database server used by WSUS
- Test-WSUSDatabaseServerConnection
- Presents a True/False along with error when attempting to test connection to Database server from system this command is being ran from.
- Get-WSUSUpdateClassifications
- Lists all Update classifications on WSUS server
Examples
Get-WSUSUpdateClassifications
This command was one I thought I already included in V1.0, but as I was working on the Approval commands, it became apparent that this was not the case. This command is pretty straight forward and gives you all of the update classifications on the WSUS server.
Get-WSUSUpdateClassifications
Test-WSUSDatabaseServerConnection
Test-WSUSDatabaseServerConnection
Connect-WSUSDatabaseServer
This command, while using the –Passthru switch, will show you the database server and how it is connecting. A global variable is also created with the name $wsusdb.
Connect-WSUSDatabaseServer -Passthru
Viewing the $wsusdb using Get-Member will list out everything that can be done with that database using various methods. This is a little more beyond what I am going to show you here. But you can feel free to play with it and see what you get. If I have more time, I will attempt to dive deeper into it.
New-WSUSInstallApprovalRule
This command allows you to create a Install Approval Rule in WSUS that will automate the approval process for you by approving specific patches that meet the criteria that you determine and will only apply to whichever groups you pick. This does require some extra steps in getting the group/s, classification/s and categories prior to creating the new rule.
$cat = Get-WSUSUpdateCategories | ? {$_.Title -eq "Windows Server 2008"}
$group = Get-WSUSGroups | ? {$_.Name -eq "Test"}
$class = Get-WSUSUpdateClassifications | ? {$_.Title -eq "Updates"}
New-WSUSInstallApprovalRule -Name "Rule1" -Category $cat -Classification $class -Group $group -Enable
Get-WSUSInstallApprovalRules
This command will list all of the Approval Rules on the WSUS server.
Get-WSUSInstallApprovalRules
Set-WSUSInstallApprovalRule
Much like the New-WSUSInstallApprovalRule, this one may require some prep work prior to actually running the command. If you are just going to enable/disable the rule, then it is as simple as running the command with the –Enable or –Disable switch.
Set-WSUSInstallApprovalRule -Name 'Rule1' -Enable
Get-WSUSInstallApprovalRule | ? {$_.Name -eq "Rule1"} | Set-WSUSInstallApprovalRule -Disable
Besides that, as long as you supply a new group, or new classifications and categories, you can also edit what groups a rule could apply to as well as the classifications and update categories to change on the rule.
$cat = Get-WSUSUpdateCategories | ? {$_.Title -eq "Windows Server 2003"}
$group = Get-WSUSGroups | ? {$_.Name -eq "Test"}
$class = Get-WSUSUpdateClassifications | ? {$_.Title -eq "Updates"}
Set-WSUSInstallApprovalRule -Name "Rule1" -Category $cat -Classification $class -Group $group
Start-WSUSInstallApprovalRule
This command will start the approval rule process and automatically approve updates based on the requirements of a specified Approval Rule. Just make sure the rule is enabled prior to running this command.
Start-WSUSInstallApprovalRule
Remove-WSUSInstallApprovalRule
As this command states, this will remove a Approval Rule from WSUS.
Remove-WSUSInstallApprovalRule -Name 'Rule1'
Code
The downloads for this updated Module are available from the following locations:
Please use either the comments here, codeplex or the script repository to report any bugs that are found. Also, any features or things of that nature that you would like to see added can be posted in those areas as well.
