Share via


Find IIS URLs

Question

Tuesday, September 13, 2016 9:26 PM

I'm trying to find a way via PowerShell/Registry/etc... find all IIS website URL's on a given IIS7/8 server. I have searched the net and forums high and low without success to this point.

Task I'm trying to accomplish is on each IIS webserver, for each site, run the Invoke-Webrequest -uri and search the RawContent for keywords.  Easy to do when you have the URL.  I would also be open to any sugestions at this point.

import-module webadministration

$sites = Get-ChildItem -path IIS:\Sites

foreach ($site in $sites){

$url = ####Can't seem to get###

$temp = Invoke-WebRequest -Uri $url
$cons = ($temp.RawContent).Contains("keyword1")
$dev = ($temp.RawContent).Contains("keyword2")

}

if ($cons -eq $true -or $dev -eq $true){
 write-output "Found"
}

All replies (5)

Friday, September 16, 2016 6:45 PM ✅Answered

You have an issue with your website or your account.

\(ツ)_/


Tuesday, September 13, 2016 10:02 PM

The URL is not available in that location.

Get-WebBinding

\(ツ)_/


Wednesday, September 14, 2016 3:51 AM | 1 vote

Hi,

You could also use these cmdlet: Get-WebURL 'IIS:\Sites\Default Web Site'

More cmdlets about IIS, please refer to link below:

https://technet.microsoft.com/en-us/library/ee790599.aspx

Best regards,

Andy_Pan

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
If you have feedback for TechNet Subscriber Support, contact [email protected].


Friday, September 16, 2016 6:41 PM

When I run the command Get-WebURL 'IIS:\Sites\Default Web Site' I get the following results:

Status

TrustFailure

Doesn't return what I would hope to be the full URL.


Tuesday, September 20, 2016 5:48 AM

Hi,

Was your issue resolved?

If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

If no, please reply and tell us the current situation in order to provide further help.

Best Regards,

Andy_Pan

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
If you have feedback for TechNet Subscriber Support, contact [email protected].