Skip to content

Commit

Permalink
Version 2.3.1.0
Browse files Browse the repository at this point in the history
View ReleaseNotes.txt to see all of the latest changes
  • Loading branch information
proxb committed Mar 27, 2016
1 parent 20c7249 commit 207d512
Show file tree
Hide file tree
Showing 38 changed files with 1,258 additions and 693 deletions.
Binary file modified PoshWSUS.psd1
Binary file not shown.
46 changes: 46 additions & 0 deletions ReleaseNotes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
PoshWSUS 2.3.1 Release Notes
Last Updated:


-------------
|MISC Updates|
-------------
* Updated Type and Format files
* Changed Global scope WSUS variable to Script
* Added Script scope _wsusconfig variable

-------------------
|Updated Functions|
-------------------
Get-PSWSUSUpdateApproval
Disconnect-PSWSUSServer
Connect-PSWSUSServer
Disconnect-PSWSUSServer
Get-PSWSUSConfigEnabledUpdateLanguages
Get-PSWSUSConfigSupportedUpdateLanguages
Get-PSWSUSConfigUpdateFiles
Get-PSWSUSConfigUpdateSource
Set-PSWSUSConfigEnabledUpdateLanguages
Set-PSWSUSConfigProxyServer
Set-PSWSUSConfigTargetingMode
Set-PSWSUSConfigUpdateFiles
Set-PSWSUSConfigUpdateSource
Get-PSWSUSClientGroupMembership
Get-PSWSUSCommand
Get-PSWSUSEvent
Get-PSWSUSSyncHistory
Resume-PSWSUSUpdateDownload
Remove-PSWSUSClientFromGroup
Remove-PSWSUSClient
Add-PSWSUSClientToGroup
Get-PSWSUSClientPerUpdate

---------------
|New Functions|
---------------

-------------------
|Removed Functions|
-------------------
Get-PSWSUSSyncEvent
Resume-PSWSUSDownload
2 changes: 1 addition & 1 deletion Scripts/Add-PSWSUSClientToGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function Add-PSWSUSClientToGroup {
#Verify Computer is in WSUS
If ($Computername -is [string]) {
Write-Verbose "Validating client in WSUS"
$client = Get-PSWSUSClient -computer $Computername
$client = Get-PSWSUSClient -computername $Computername
} ElseIf ($Computername -is [Microsoft.UpdateServices.Internal.BaseApi.ComputerTarget]) {
Write-Verbose "Collection of clients"
$Client = $Computername
Expand Down
174 changes: 88 additions & 86 deletions Scripts/Connect-PSWSUSServer.ps1
Original file line number Diff line number Diff line change
@@ -1,91 +1,93 @@
Function Connect-PSWSUSServer
{
Function Connect-PSWSUSServer {
<#
.SYNOPSIS
Make the initial connection to a WSUS Server.
.DESCRIPTION
Make the initial connection to a WSUS Server. Only one concurrent connection is allowed.
.PARAMETER WsusServer
Name of WSUS server to connect to. Defaults to local host.
.PARAMETER SecureConnection
Determines if a secure connection will be used to connect to the WSUS server. Defaults to un-secured.
.PARAMETER Port
Port number to connect to. Default is Port 8530 if not used. Typical ports are 80 (http), 443 (https), 8350 (http) and 8351 (https)
.NOTES
Name: Connect-PSWSUSServer
Author: Boe Prox
Editor: Friedrich Weinmann
DateCreated: 24SEPT2010
DateModified: 26MAR2015
.LINK
https://learn-powershell.net
.SYNOPSIS
Make the initial connection to a WSUS Server.
.DESCRIPTION
Make the initial connection to a WSUS Server. Only one concurrent connection is allowed.
.PARAMETER WsusServer
Name of WSUS server to connect to. If not value is given, an attempt to read the value from registry will occur.
.PARAMETER SecureConnection
Determines if a secure connection will be used to connect to the WSUS server. If not used, then a non-secure
connection will be used.
.PARAMETER Port
Port number to connect to. Default is Port "80" if not used. Accepted values are "80","443","8350" and "8351"
.NOTES
Name: Connect-PSWSUSServer
Author: Boe Prox
Version History:
1.2 | 17 Feb 2015
-Renamed to Connect-PSWSUSServer
-Allow read of registry for WUServer and Port
1.0 | 24 Sept 2010
-Initial Version
.LINK
https://learn-powershell.net
.EXAMPLE
Connect-PSWSUSServer "server1"
.EXAMPLE
Connect-PSWSUSServer -PSWSUSserver "server1"
Description
-----------
This command will establish the connection to the WSUS using an unsecure connection on port 8530.
.EXAMPLE
Connect-PSWSUSServer "server1" $true 443
Description
-----------
This command will make the connection to the WSUS using an unsecure port (Default:80).
.EXAMPLE
Connect-PSWSUSServer -WSUSserver "server1" -SecureConnection
Description
-----------
This command will establish a secure connection to the WSUS server on port 443.
.EXAMPLE
Connect-PSWSUSServer "server1" -port 8530
Description
-----------
This command will make a secure connection (Default: 443) to a WSUS server.
.EXAMPLE
Connect-PSWSUSServer -WSUSserver "server1" -port 8530
Description
-----------
This command will make the connection to the WSUS using a defined port 8530.
#>
[cmdletbinding(ConfirmImpact = 'low')]
Param (
[Parameter(Position = 0, ValueFromPipeline = $True)]
[Alias('WSUS', 'WSUSServer', 'Server', 'Name', 'Computer')]
[string]
$ComputerName = $env:COMPUTERNAME,

[Parameter(Position = 1)]
[Alias('SSL')]
[bool]
$SecureConnection = $false,

[Parameter(Position = 2)]
[int]
$Port = $DefaultWsusPort
)
Begin
{
Write-Debug "[Start] Connecting to WSUS"
}
Process
{
if ($PSCmdlet.ShouldProcess($ComputerName, "Establishing Connection to WSUS $ComputerName using Port $Port ($(if ($SecureConnection) { "SSL" } else { "no SSL" }))"))
{
# Make connection to WSUS server
Try
{
$Global:wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($ComputerName, $SecureConnection, $Port)
Write-Output $Wsus
}
Catch
{
Write-Warning "Unable to connect to $($ComputerName)!`n$($error[0])"
}
}
}
End
{
Write-Debug "[End] Connecting to WSUS"
}
}
Description
-----------
This command will make the connection to the WSUS using a defined port 8530.
#>
[cmdletbinding()]
Param(
[Parameter(ValueFromPipeline = $True)]
[Alias('Computername')]
[string]$WsusServer,

[Parameter()]
[switch]$SecureConnection,

[Parameter()]
[ValidateSet("80","443","8530","8531" )]
[int]$Port = 80
)
Begin {
$ErrorActionPreference = 'Stop'
If ($PSBoundParameters['SecureConnection']) {
$Secure = $True
} Else {
$Secure = $False
}
}
Process {
If (-NOT $PSBoundParameters.ContainsKey('WSUSServer')) {
#Attempt to pull WSUS server name from registry key to use
If ((Get-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate -Name WUServer).WUServer -match '(?<Protocol>^http(s)?)(?:://)(?<Computername>(?:(?:\w+(?:\.)?)+))(?::)?(?<Port>.*)') {
$WsusServer = $Matches.Computername
$Port = $Matches.Port
}
}
#Make connection to WSUS server
Try {
Write-Verbose "Connecting to $($WsusServer) <$($Port)>"
$Script:Wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer($wsusserver,$Secure,$port)
$Script:_wsusconfig = $Wsus.GetConfiguration()
Write-Output $Wsus
} Catch {
Write-Warning "Unable to connect to $($wsusserver)!`n$($error[0])"
} Finally {
$ErrorActionPreference = 'Continue'
}
}
}
3 changes: 2 additions & 1 deletion Scripts/Disconnect-PSWSUSServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function Disconnect-PSWSUSServer {
Param ()
Process {
#Disconnect WSUS session by removing the variable
Remove-Variable -Name wsus -Force -Scope Global
Remove-Variable -Name wsus -Force -Scope Script
Remove-Variable -Name _wsusconfig -Force -Scope Script
}
}
61 changes: 20 additions & 41 deletions Scripts/Get-PSWSUSClientGroupMembership.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,60 +28,39 @@ function Get-PSWSUSClientGroupMembership {
This command will retrieve the group membership/s of 'server1'.
.EXAMPLE
Get-PSWSUSClient -computer "server1" | Get-PSWSUSClientGroupMembership
Get-PSWSUSClient -computername "server1" | Get-PSWSUSClientGroupMembership
Description
-----------
This command will retrieve the group membership/s of 'server1'.
.EXAMPLE
Get-PSWSUSClient -computer "servers" | Get-PSWSUSClientGroupMembership
Get-PSWSUSClient -computername "servers" | Get-PSWSUSClientGroupMembership
Description
-----------
This command will retrieve the group membership/s of each server.
#>
[cmdletbinding(
DefaultParameterSetName = 'collection'
)]
Param(
[Parameter(
Mandatory = $True,
Position = 0,
ParameterSetName = 'string',
ValueFromPipeline = $True)]
[string]$Computer,
[Parameter(
Mandatory = $True,
Position = 0,
ParameterSetName = 'collection',
ValueFromPipeline = $True)]
[system.object]
[ValidateNotNullOrEmpty()]
$InputObject
)
Process {
Switch ($pscmdlet.ParameterSetName) {
"string" {
Write-Verbose "String parameter"
#Retrieve computer in WSUS
Try {
Write-Verbose "Searching for computer"
$client = Get-PSWSUSClient -Computer $Computer
} Catch {
Write-Error "Unable to retrieve $($computer) from database."
}
}
"Collection" {
Write-Verbose "Collection parameter"
$client = $inputobject
[cmdletbinding()]
Param(
[Parameter(Mandatory = $True,ValueFromPipeline = $True)]
[Alias('CN')]
[ValidateNotNullOrEmpty()]
$Computername
)
Process {
ForEach ($Computer in $Computername) {
If (($Computer -is [Microsoft.UpdateServices.Internal.BaseApi.ComputerTarget])) {
$Client = $Computer
} Else {
$Client = Get-PSWSUSClient -Computername $Computer
}
#List group membership of client
$client | ForEach {
$Data = $_.GetComputerTargetGroups()
$data | Add-Member -MemberType NoteProperty -Name FullDomainName -Value $_.fulldomainname -PassThru
}
}
#List group membership of client
$client | ForEach {
$Data = $_.GetComputerTargetGroups()
$data | Add-Member -MemberType NoteProperty -Name FullDomainName -Value $_.fulldomainname -PassThru
}
}
}
2 changes: 1 addition & 1 deletion Scripts/Get-PSWSUSCommand.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ function Get-PSWSUSCommand {
Param ()

#List all WSUS functions available
Get-Command -Module PSWSUS
Get-Command -Module PoshWSUS
}
12 changes: 4 additions & 8 deletions Scripts/Get-PSWSUSConfigEnabledUpdateLanguages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ function Get-PSWSUSConfigEnabledUpdateLanguages {
Name: Get-PSWSUSConfigEnabledUpdateLanguages
Author: Dubinsky Evgeny
DateCreated: 1DEC2013
Modified: 06 Feb 2014 -- Boe Prox
-Removed instances where set actions are occuring
.LINK
http://blog.itstuff.in.ua/?p=62#Get-PSWSUSConfigEnabledUpdateLanguages
Expand All @@ -29,13 +31,7 @@ function Get-PSWSUSConfigEnabledUpdateLanguages {

Begin
{
if($wsus)
{
$config = $wsus.GetConfiguration()
$config.ServerId = [System.Guid]::NewGuid()
$config.Save()
}#endif
else
if( -NOT $wsus)
{
Write-Warning "Use Connect-PSWSUSServer for establish connection with your Windows Update Server"
Break
Expand All @@ -44,7 +40,7 @@ function Get-PSWSUSConfigEnabledUpdateLanguages {
Process
{
Write-Verbose "Getting WSUS Enabled Update Languages."
$config.GetEnabledUpdateLanguages()
$_wsusconfig.GetEnabledUpdateLanguages()
}
End{}
}
8 changes: 2 additions & 6 deletions Scripts/Get-PSWSUSConfigProxyServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function Get-PSWSUSConfigProxyServer {
Name: Get-PSWSUSConfigProxyServer
Author: Dubinsky Evgeny
DateCreated: 1DEC2013
Modified: 06 Feb 2014 -- Boe Prox
-Removed instances where set actions are occuring
.LINK
http://blog.itstuff.in.ua/?p=62#Get-PSWSUSConfigProxyServer
Expand All @@ -28,12 +30,6 @@ function Get-PSWSUSConfigProxyServer {
Begin
{
if($wsus)
{
$config = $wsus.GetConfiguration()
$config.ServerId = [System.Guid]::NewGuid()
$config.Save()
}#endif
else
{
Write-Warning "Use Connect-PSWSUSServer for establish connection with your Windows Update Server"
Break
Expand Down
Loading

0 comments on commit 207d512

Please sign in to comment.