DOS shell one liner for enumerating IIS 7 and up sites


I was looking for a way to quickly compare IIS sites across my servers. I turned to my old friend DOS shell scripts and wrote a quick one liner

FOR /F "tokens=2 delims= " %i IN ('"%windir%\system32\inetsrv\appcmd.exe list site"') DO FOR %A IN (%windir%\system32\inetsrv\appcmd) DO %A list site %i /config >> sites-%computername%.txt

The script defines the field(s) I want which is the 2nd field, enumerates the sites on the IIS server and then enumerates the sites’ configurations and bindings and outputs the results to a file.  The script appends to the file so either make sure to rename an existing one or delete it to avoid confusion.  I may update the script to do that itself but for the meantime…