WSD Printers IP Address

Read Time:2 Minute, 8 Second

WSD is an awesome service for printers. It goes out and finds a printer on the network and adds it accordingly. It does all the IP address stuff for you. Which is awesome. It even tells you that it was set up as a wsd by naming the port wsd and some code. Super friendly. However… What happens when DHCP changes that IP address because someone forgot to do a reservation? How do you get that IP address? Believe it or not, that IP address is stored in the registry for the most part. Its located under the Hardware Local Machine > System > Current Control Set > Enum > SWD > DAFWSDProvider. Each entry has a friendly name and location information. The location information has the IP address like a web page. Powershell can give you this information pretty quickly with a single line as well. Let’s take a look.

Get-ChildItem HKLM:\SYSTEM\CurrentControlSet\Enum\SWD\DAFWSDProvider | foreach-object { $_ | Get-ItemProperty | Select-Object FriendlyName, LocationInformation }

Get-childitem is normally used in directories. The registry is a type of directory with files inside of it. So we use the get-childitem and treat the registry as a file path. We navigate to the DAFWSDProvider. Then we look at each file or in this case item property with Get-ItemProperty. We are looking for that FriendlyName and the LocationInformation. The location information will look like https://192.168.2.62/something because it is treating the IP address as a webpage. Still unsure why. The above command will list all of the printers like this. If it has an IP address, it will appear there.

Now we can wrap this up in a nice little function for remote computers.

The Script

function Get-SHDWDSPrinters {
    [cmdletbinding()]
    param (
        [string[]]$ComputerName = $Env:COMPUTERNAME
    )
    foreach ($Computer in $ComputerName) {
        Invoke-Command -ComputerName $Computer -ScriptBlock {
            Get-ChildItem HKLM:\SYSTEM\CurrentControlSet\Enum\SWD\DAFWSDProvider | foreach-object { $_ | Get-ItemProperty | Select-Object FriendlyName, LocationInformation }
        }
    }
}

You Might Also Like

Leave a Reply

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.