Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect handling server names from registry #12

Open
MVKozlov opened this issue Apr 4, 2016 · 3 comments
Open

Incorrect handling server names from registry #12

MVKozlov opened this issue Apr 4, 2016 · 3 comments
Assignees
Labels

Comments

@MVKozlov
Copy link

MVKozlov commented Apr 4, 2016

  • Currently, server names with '-' not supported
  • Absent port from registry not supported (no default to 80)
  • Canonical url (ended with '/') not supported

My suggestions:
If ((Get-ItemProperty -Path HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate -Name WUServer).WUServer -match '(?<Protocol>^http(s)?)(?:://)(?<Computername>(?:(?:[\w-]+(?:\.)?)+))(?::)?(?<Port>\d*)/?') { $WsusServer = $Matches.Computername; if ($Matches.Port) { $Port = $Matches.Port } }
Slightly corrected regex and test for empty port.
btw, isn't a time to correct default port to 8530 ?

sorry for formatting. cant get it as need

@proxb
Copy link
Owner

proxb commented Apr 4, 2016

I'm assuming that this all refers to Connect-PSWSUSServer...correct? At this point in time, you are correct that we can move the default port to 8530 and good catch on server names with a '-' in them. Good things to look at improving on with the next release.

@proxb proxb added the bug label Apr 4, 2016
@proxb proxb self-assigned this Apr 4, 2016
@MVKozlov
Copy link
Author

MVKozlov commented Apr 5, 2016

Definitely, I'm talking about Connect-PSWSUSServer :)

btw, take into account that if default server port will be changed to 8530, than my code above need addition
if ($Matches.Port) { $Port = $Matches.Port } else { $Port = 80 } #because default url without port equal to port=80

@TaylorWhitt
Copy link

TaylorWhitt commented Sep 4, 2016

I'm still learning how Git-Hub works and how to contribute.... but there was a bug where the registry name was an alias that gave a fit when I tried connecting to it. I got around this by doing a DNS lookup. It would resolve and output the FQDN. Perhaps if your regex included everything between the first "//" and the last ":" and did a look up, it wouldn't matter? Still learning regex too, so not sure how that would work. Also not sure if all entries have a port...

What I use:
$WsusServer = [System.Net.DNS]::GetHostEntry("$WsusServer").hostname

The gethostentry has an address list as well which you could cycle through to get around any name or alias. Could try/cycle the port too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants