How can I use a variable to implement reserved namespaces?

5 views
Skip to first unread message

rkr...@tucowsinc.com

unread,
Oct 21, 2019, 9:36:31 AM10/21/19
to Carbon
Hi,

Normally, NETSH is used to create reserved namespaces, see below

$endpoints = @(
"http://service.domain.com:8088/configurations/",
"http://service.domain.com:8088/configurations/start/",
"http://service.domain.com:8088/configurations/stop/",
"http://service.domain.com:8088/configurations/refresh/",
"http://service.domain.com:8088/certificates/",
"http://service.domain.com:8088/healthcheck/",
"http://service.domain.com:8088/scan/"
)

ForEach($endpoint in $endpoints){
    
If(!($endpoint)){
        
netsh http add urlacl url=$endpoint user=<username> listen=yes
    
}
    
Else{
        
netsh http show urlacl url=$endpoint
    
}
}

But now, I would like to run this in PowerShell. But I got stuck using your module.

  1. I need to run the commands to create various URLs
  2. I would like to check first if they exists and if not, create these
  3. I am looking for a way to use a variable, which contains all URLs
$endpoints = @(
"http://service.domain.com:8088/configurations/",
"http://service.domain.com:8088/configurations/start/",
"http://service.domain.com:8088/configurations/stop/",
"http://service.domain.com:8088/configurations/refresh/",
"http://service.domain.com:8088/certificates/",
"http://service.domain.com:8088/healthcheck/",
"http://service.domain.com:8088/scan/"
)

ForEach($endpoint in $endpoints){
   
If(!($endpoint)){
       
Grant-HttpUrlAclPermission -Url $endpoint -Principal 'DOMAIN\user' -Permission [Carbon.Security.HttpUrlAccessRights]::Listen
   
}
   
Else{
       
Get-HttpUrlAcl -Url $endpoint
   
}
}




Can you point me in the right direction?

With kind regards
Reply all
Reply to author
Forward
0 new messages