Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Commit

Permalink
Merge pull request proxb#29 from Windos/master
Browse files Browse the repository at this point in the history
Adding and/or adjusting warning to run Connect-PSWSUSServer
  • Loading branch information
proxb authored Oct 21, 2016
2 parents d687417 + bef6204 commit 0b9196a
Show file tree
Hide file tree
Showing 80 changed files with 643 additions and 266 deletions.
36 changes: 22 additions & 14 deletions Scripts/Add-PSWSUSClientToGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,29 @@ function Add-PSWSUSClientToGroup {
$Client = $Computername
}
If ($client) {
#Get group object
Write-Verbose "Retrieving group"
$targetgroup = $wsus.getcomputertargetgroups() | Where {
$_.Name -eq $group
}
If (-Not $targetgroup) {
Write-Error "Group $group does not exist in WSUS!"
Break
}
ForEach ($C in $Client) {
#Add client to group
Write-Verbose ("Adding {0} to {1}" -f $c.fulldomainname,$Group)
If ($pscmdlet.ShouldProcess($($c.fulldomainname))) {
$targetgroup.AddComputerTarget($c)
if($wsus)
{
#Get group object
Write-Verbose "Retrieving group"
$targetgroup = $wsus.getcomputertargetgroups() | Where {
$_.Name -eq $group
}
If (-Not $targetgroup) {
Write-Error "Group $group does not exist in WSUS!"
Break
}
ForEach ($C in $Client) {
#Add client to group
Write-Verbose ("Adding {0} to {1}" -f $c.fulldomainname,$Group)
If ($pscmdlet.ShouldProcess($($c.fulldomainname))) {
$targetgroup.AddComputerTarget($c)
}
}
}#endif
else
{
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
} Else {
Write-Warning ("{0}: Unable to locate!`n{1}" -f $Computername,$_.Exception.Message)
Expand Down
8 changes: 8 additions & 0 deletions Scripts/Connect-PSWSUSDatabaseServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ Function Connect-PSWSUSDatabaseServer {
ValueFromPipeline = $False)]
[switch]$Passthru
)

Begin {
if(-not $wsus)
{
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Process {
#Create database connection
Write-Verbose "Creating the database connection to the database hosting WSUS"
Expand Down
8 changes: 8 additions & 0 deletions Scripts/Export-PSWSUSMetaData.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ function Export-PSWSUSMetaData {
[Parameter(Mandatory=$True,Position = 1,ValueFromPipeline = $True)]
[string]$LogName
)

Begin {
if(-not $wsus)
{
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Process {
If ($pscmdlet.ShouldProcess($FileName,"Export MetaData")) {
Try {
Expand Down
8 changes: 8 additions & 0 deletions Scripts/Get-PSWSUSCategory.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ function Get-PSWSUSCategory {
ValueFromPipeline = $True)]
[string]$Title
)

Begin {
if(-not $wsus)
{
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Process {
If ($PSBoundParameters['Id']) {
$Wsus.GetUpdateCategory($Id)
Expand Down
8 changes: 8 additions & 0 deletions Scripts/Get-PSWSUSChildServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ function Get-PSWSUSChildServer {
#>
[cmdletbinding()]
Param ()

Begin {
if(-not $wsus)
{
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Process {
#Gather all child servers in WSUS
$wsus.GetChildServers()
Expand Down
8 changes: 8 additions & 0 deletions Scripts/Get-PSWSUSClassification.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ Function Get-PSWSUSClassification {
#>
[cmdletbinding()]
Param()

Begin {
if(-not $wsus)
{
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Process {
$wsus.GetUpdateClassifications()
}
Expand Down
72 changes: 40 additions & 32 deletions Scripts/Get-PSWSUSClient.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,39 +103,47 @@ function Get-PSWSUSClient {
[switch]$IncludeDownstreamComputerTargets
)
Begin {
$ErrorActionPreference = 'Stop'
If ($PSCmdlet.ParameterSetName -eq 'ComputerScope') {
$ComputerScope = New-Object Microsoft.UpdateServices.Administration.ComputerTargetScope
If ($PSBoundParameters['IncludedInstallationState']) {
$ComputerScope.IncludedInstallationStates = $IncludedInstallationState
}
If ($PSBoundParameters['ExcludedInstallState']) {
$ComputerScope.ExcludedInstallationStates = $ExcludedInstallState
}
If ($PSBoundParameters['FromLastStatusTime']) {
$ComputerScope.FromLastReportedStatusTime = $FromLastStatusTime
}
If ($PSBoundParameters['ToLastStatusTime']) {
$ComputerScope.ToLastReportedStatusTime = $ToLastStatusTime
}
If ($PSBoundParameters['FromLastSyncTime']) {
$ComputerScope.FromLastSyncTime = $FromLastSyncTime
}
If ($PSBoundParameters['ToLastSyncTime']) {
$ComputerScope.ToLastSyncTime = $ToLastSyncTime
}
If ($PSBoundParameters['IncludeSubGroups']) {
$ComputerScope.IncludeSubgroups = $IncludeSubGroups
}
If ($PSBoundParameters['OSFamily']) {
$ComputerScope.OSFamily = $OSFamily
}
If ($PSBoundParameters['IncludeDownstreamComputerTargets']) {
$ComputerScope.IncludeDownstreamComputerTargets = $IncludeDownstreamComputerTargets
}
If ($PSBoundParameters['ComputerTargetGroups']) {
[void]$ComputerScope.ComputerTargetGroups.AddRange($ComputerTargetGroups)
if($wsus)
{
$ErrorActionPreference = 'Stop'
If ($PSCmdlet.ParameterSetName -eq 'ComputerScope') {
$ComputerScope = New-Object Microsoft.UpdateServices.Administration.ComputerTargetScope
If ($PSBoundParameters['IncludedInstallationState']) {
$ComputerScope.IncludedInstallationStates = $IncludedInstallationState
}
If ($PSBoundParameters['ExcludedInstallState']) {
$ComputerScope.ExcludedInstallationStates = $ExcludedInstallState
}
If ($PSBoundParameters['FromLastStatusTime']) {
$ComputerScope.FromLastReportedStatusTime = $FromLastStatusTime
}
If ($PSBoundParameters['ToLastStatusTime']) {
$ComputerScope.ToLastReportedStatusTime = $ToLastStatusTime
}
If ($PSBoundParameters['FromLastSyncTime']) {
$ComputerScope.FromLastSyncTime = $FromLastSyncTime
}
If ($PSBoundParameters['ToLastSyncTime']) {
$ComputerScope.ToLastSyncTime = $ToLastSyncTime
}
If ($PSBoundParameters['IncludeSubGroups']) {
$ComputerScope.IncludeSubgroups = $IncludeSubGroups
}
If ($PSBoundParameters['OSFamily']) {
$ComputerScope.OSFamily = $OSFamily
}
If ($PSBoundParameters['IncludeDownstreamComputerTargets']) {
$ComputerScope.IncludeDownstreamComputerTargets = $IncludeDownstreamComputerTargets
}
If ($PSBoundParameters['ComputerTargetGroups']) {
[void]$ComputerScope.ComputerTargetGroups.AddRange($ComputerTargetGroups)
}
}
}#endif
else
{
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Process {
Expand Down
8 changes: 8 additions & 0 deletions Scripts/Get-PSWSUSClientsInGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ function Get-PSWSUSClientsInGroup {
Position = 1)]
[string]$Id
)

Begin {
if(-not $wsus)
{
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Process {
If ($PSBoundParameters['id']) {
($wsus.GetComputerTargetGroups() | Where {
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Get-PSWSUSConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function Get-PSWSUSConfig {
if($wsus){}#endif
else
{
Write-Warning "Use Connect-PSWSUSServer for establish connection with your Windows Update Server"
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Get-PSWSUSConfigEnabledUpdateLanguages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function Get-PSWSUSConfigEnabledUpdateLanguages {
{
if( -NOT $wsus)
{
Write-Warning "Use Connect-PSWSUSServer for establish connection with your Windows Update Server"
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Get-PSWSUSConfigProxyServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ function Get-PSWSUSConfigProxyServer {

Begin
{
if($wsus)
if(-not $wsus)
{
Write-Warning "Use Connect-PSWSUSServer for establish connection with your Windows Update Server"
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Get-PSWSUSConfigSupportedUpdateLanguages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ function Get-PSWSUSConfigSupportedUpdateLanguages {
Param
(
)
if($wsus)
if(-not $wsus)
{
Write-Warning "Use Connect-PSWSUSServer for establish connection with your Windows Update Server"
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
Write-Verbose "Getting WSUS Supported Update Languages"
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Get-PSWSUSConfigSyncSchedule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function Get-PSWSUSConfigSyncSchedule {

if(-NOT $wsus)
{
Write-Warning "Use Connect-PSWSUSServer for establish connection with your Windows Update Server"
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
Write-Verbose "Getting WSUS update source configuration"
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Get-PSWSUSConfigSyncUpdateCategories.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function Get-PSWSUSConfigSyncUpdateCategories {
Param ()
if (-NOT $wsus)
{
Write-Warning "Use Connect-PSWSUSServer for establish connection with your Windows Update Server"
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
$wsus.GetSubscription().GetUpdateCategories()
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Get-PSWSUSConfigSyncUpdateClassifications.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ function Get-PSWSUSConfigSyncUpdateClassifications {
Param()


if ($wsus)
if (-not $wsus)
{
Write-Warning "Use Connect-PSWSUSServer for establish connection with your Windows Update Server"
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
$wsus.GetSubscription().GetUpdateClassifications()
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Get-PSWSUSConfigUpdateFiles.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Get-PSWSUSConfigUpdateFiles {
}#endif
else
{
Write-Warning "Use Connect-PSWSUSServer for establish connection with your Windows Update Server"
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Get-PSWSUSConfigUpdateSource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ function Get-PSWSUSConfigUpdateSource {
[CmdletBinding()]
Param()

if($wsus)
if(-not $wsus)
{
Write-Warning "Use Connect-PSWSUSServer for establish connection with your Windows Update Server"
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}

Expand Down
2 changes: 1 addition & 1 deletion Scripts/Get-PSWSUSConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function Get-PSWSUSConfiguration {
if($wsus){}#endif
else
{
Write-Warning "Use Connect-PoshWSUSServer for establish connection with your Windows Update Server"
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Expand Down
8 changes: 8 additions & 0 deletions Scripts/Get-PSWSUSContentDownloadProgress.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ function Get-PSWSUSContentDownloadProgress {
#>
[cmdletbinding()]
Param ()

Begin {
if(-not $wsus)
{
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Process {
#Gather all child servers in WSUS
$wsus.GetContentDownloadProgress()
Expand Down
8 changes: 8 additions & 0 deletions Scripts/Get-PSWSUSCurrentUserRole.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ function Get-PSWSUSCurrentUserRole {
#>
[cmdletbinding()]
Param ()

Begin {
if(-not $wsus)
{
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Process {
#Return the current user role
$wsus.GetCurrentUserRole()
Expand Down
8 changes: 8 additions & 0 deletions Scripts/Get-PSWSUSDatabaseConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ function Get-PSWSUSDatabaseConfig {
#>
[cmdletbinding()]
Param ()

Begin {
if(-not $wsus)
{
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Process {
$wsus.GetDatabaseConfiguration()
}
Expand Down
8 changes: 8 additions & 0 deletions Scripts/Get-PSWSUSDownstreamServer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ function Get-PSWSUSDownstreamServer {
#>
[cmdletbinding()]
Param ()

Begin {
if(-not $wsus)
{
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Process {
#Gather all child servers in WSUS
$wsus.GetDownstreamServers()
Expand Down
10 changes: 9 additions & 1 deletion Scripts/Get-PSWSUSEmailConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@ function Get-PSWSUSEmailConfig {
[switch]$SendTestEmail
)
Begin {
$email = $wsus.GetEmailNotificationConfiguration()
if($wsus)
{
$email = $wsus.GetEmailNotificationConfiguration()
}#endif
else
{
Write-Warning "Use Connect-PSWSUSServer to establish connection with your Windows Update Server"
Break
}
}
Process {
If ($PSBoundParameters['SendTestEmail']) {
Expand Down
Loading

0 comments on commit 0b9196a

Please sign in to comment.