New-WSUSLocalPackage ?

Feb 14, 2012 at 8:48 PM

Hi Boe,

First, THANK YOU for this module which I envision making my life a LOT easier. I just downloaded the version 2.0.3, and on the home page you have the New-WSUSLocalPackage command listed, but I'm unable to find it in the scripts directory or in Powershell. Is that coming up in the next version, or am I looking in the wrong place? My hope was that that would allow me to publish a local update.

Thank you, and keep up the good work!

ralibrando

Coordinator
Feb 14, 2012 at 11:35 PM

Hi ralibrando,

Thank you for the kind words.

Unfortunately, New-WSUSLocalPackage is not quite ready for prime time yet. I am still working out some kinks in the code to make it work properly. But rest assured, it will be out hopefully in the next couple of releases. I did update the home page so that the command doesn't show up anymore.

 

Boe

Feb 17, 2012 at 5:17 PM

Thanks for the quick reply and the hope I'll cling to as I create local packages without powershell. :)

I'll keep an eye out for it and I really do appreciate you putting all this effort in to make it easier for everyone else.

 

ralibrando

Feb 23, 2012 at 12:59 AM

I was able to import the module all right, but it cannot connect to my WSUS server.  I tried it on one machine that does have the WSUS Admin installed, and then on the WSUS server itself.  In both cases I get:

 

WARNING: Unable to connect to comwsus!

 

John Thayer Jensen

Coordinator
Feb 26, 2012 at 7:13 PM

Can you tell me the exact command line you use to connect to the WSUS server?

Feb 26, 2012 at 7:25 PM

I imported the module, then tried various ways to connect.  Typical:

Connect-WSUSServer -WsusServer myservers.fqdn

Messed around with other stuff and looked at the commands and a bit of the help stuff.

Our WSUS server is running in 2008R2.  The version of WSUS is:

Update Services

Microsoft Corporation

Version: 3.2.7600.226

Our AD is 2008 R2 native mode.

Thanks if you can help!  I would so much love to automate my WSUS stuff!!

jj

Coordinator
Feb 26, 2012 at 7:33 PM

Are you running the command from an elevated prompt (runas administrator)? What port is the WSUS server listening on? Try running the following lines and see if it works:

[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer('myservers.fqdn',$False)
$wsus

Feb 26, 2012 at 7:53 PM

"Are you running the command from an elevated prompt (runas administrator)?"

   yes.

"What port is the WSUS server listening on?"

   80

Try running the following lines and see if it works:

[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer('myservers.fqdn',$False)
$wsus

   Replaced with the address - works fine.  $wsus now contains:

   WebServiceUrl                    : http://wsus.com.auckland.ac.nz:80/ApiRemoting30/WebService.asmx
   BypassApiRemoting                : False
   IsServerLocal                    : False
   Name                             : wsus.com.auckland.ac.nz
   Version                          : 3.2.7600.226
   IsConnectionSecureForApiRemoting : False
   PortNumber                       : 80
   PreferredCulture                 : en
   ServerName                       : wsus.com.auckland.ac.nz
   ServerProtocolVersion            : 1.8

Again, many thanks for looking into this.

jj

Coordinator
Feb 26, 2012 at 8:13 PM

Interesting, this is pretty much what the Connect-WSUSServer does.  Run this after you import the module to overwrite the existing Connect-WSUSServer function and try a connection again and let me know what the error is.

Function Connect-WSUSServer {
    <# 
    .SYNOPSIS 
        Retrieves the last check-in times of clients on WSUS.
       
    .DESCRIPTION
        Retrieves the last check-in times of clients on WSUS. You will need to run this on a machine that
        has the WSUS Administrator console installed. Only one connection currently allowed.
       
    .PARAMETER WsusServer
        Name of WSUS server to query against.   
             
    .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: Get-LastCheckIn
        Author: Boe Prox
        DateCreated: 24SEPT2010
              
    .LINK 
        https://learn-powershell.net
    .EXAMPLE
    Connect-WSUSServer -wsusserver "server1"

    Description
    -----------
    This command will make the connection to the WSUS using an unsecure port (Default:80).
    .EXAMPLE
    Connect-WSUSServer -wsusserver "server1"  -SecureConnection

    Description
    -----------
    This command will make a secure connection (Default: 443) to a WSUS server.  
    .EXAMPLE
    Connect-WSUSServer -wsusserver "server1" -port 8560

    Description
    -----------
    This command will make the connection to the WSUS using a defined port 8560. 
          
    #>
    [cmdletbinding(
        DefaultParameterSetName = 'wsus',
        ConfirmImpact = 'low'
    )]
        Param(
            [Parameter(
                Mandatory = $True,
                Position = 0,
                ParameterSetName = '',
                ValueFromPipeline = $True)]
                [string]$WsusServer,                    
            [Parameter(
                Mandatory = $False,
                Position = 1,
                ParameterSetName = '',
                ValueFromPipeline = $False)]
                [switch]$SecureConnection,  
            [Parameter(
                Mandatory = $False,
                Position = 2,
                ParameterSetName = 'port',
                ValueFromPipeline = $False)]
                [ValidateSet("80","443","8530","8531" )]
                [int]$port                               
                )  
    Begin {                        
        $ErrorActionPreference = 'stop'
        If ($PSBoundParameters['SecureConnection']) {
            Write-Verbose ("Using a secure connection")
            $Secure = $True
        } Else {
            $Secure = $False
        }
    }
    Process {
        #Make connection to WSUS server 
        Try {
            Switch ($pscmdlet.ParameterSetName) {
                "wsus" {
                    $Global:wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($wsusserver,$Secure)
                }
                "port" {
                    Write-Verbose ("Connecting via port {0}" -f $Port)
                    $Global:wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($wsusserver,$Secure,$port)             
                }              
            }
            Write-Output $Wsus 
        } Catch {
            Write-Warning ("{0}: {1}" -f $Wsusserver,$_.Exception.Message)
        } Finally {
            $ErrorActionPreference = 'continue'
        }
    }         
}

Feb 26, 2012 at 8:15 PM
Edited Feb 26, 2012 at 8:16 PM

It now connects just fine!

 

 

jj

 

John Thayer Jensen,

System Administrator, Digital Services,

The University of Auckland Business School

 

Room 260-4136, 12 Grafton Road

 

DDI: +64 9 923-7543

mobile: +64 21 85-1904

quickdial: 60001

FAX: +64 9 373-7696

 

http://inquietumcor.blogspot.com

 

 

 

 

From: boeprox [email removed]
Sent: Monday, 27 February 2012 9:14 a.m.
To: John Thayer Jensen
Subject: Re: New-WSUSLocalPackage ? [poshwsus:313963]

 

From: boeprox

Interesting, this is pretty much what the Connect-WSUSServer does. Run this after you import the module to overwrite the existing Connect-WSUSServer function and try a connection again and let me know what the error is.

 

Feb 26, 2012 at 8:50 PM

Oops!  Just thought I had better try it with a fresh instance of Powershell - one in which I had not loaded the wsus administration assembly.  Now, with the original version of connect-wsusserver, I get:

WARNING: Unable to connect to comwsus.com.auckland.ac.nz!

And with the new one you sent, I get:

WARNING: comwsus.com.auckland.ac.nz: Unable to find type
[Microsoft.UpdateServices.Administration.AdminProxy]: make sure that the assembly containing
this type is loaded.

So it looks like somehow that assembly has to be loaded??

 

jj

Coordinator
Feb 27, 2012 at 1:22 AM

How are you importing the module? Are you saving the module to %userprofile%\documents\WindowsPowerShell\Modules or equivalent location based on your OS?

If your not saving it there and just saving it to someplace like your desktop, make sure you import the *.psd1 file and not the *.psm1, otherwise all of the assemblies and type data information will not be loaded.

Feb 27, 2012 at 1:25 AM

Bingo!  I'm very sorry to have wasted your time.  I thought that the .psm1 file was the one to import and that it would take care of the .psd1 file.  It connects fine now.  Thank you so much for being patient! :-)

 

jj

Coordinator
Feb 27, 2012 at 1:29 AM

No time wasted at all. A lot of times PowerShell modules just use the .psm1 file, but I wanted to make use of the manifest file instead (.psd1) as it gives the module a more professional look, in my opinion.  Glad it is working for you now :)

Feb 27, 2012 at 1:30 AM

Thanks - what I had thought was that the Manifest file got loaded BY the module file - instead of the other way around.

Works a treat now!

jj