PowerShell + WebAdministration - How to get website from webapplication?

后端 未结 3 638
滥情空心
滥情空心 2021-01-17 16:39

I\'m writing a PowerShell script to perform certain administrative functions in IIS 7.5.

import-module WebAdministration

In some cases I kn

3条回答
  •  时光取名叫无心
    2021-01-17 17:17

    I haven't dug into why, but if you use an asterisk or question mark anywhere in the string it works like a wildcard and returns as such.

    I.E.

    get-website -name '*myapp'
    
       Name      ID   State    Physical Path        Bindings
       ----      --   -----    -------------        --------
    
       myapp     12   Started  C:\inetpub\wwwroot   http:*:80:
      amyapp     13   Stopped  C:\anetpub\          http:*:81:
     aamyapp     14   Stopped  C:\another\place     http:172.198.1.2:80:host.header.com
    

    or

    get-website -name '?myapp'
    
    Name   ID State   Physical Path Bindings
    ----   -- -----   ------------- --------
    amyapp 13 Stopped C:\anetpub    http:*:81:
    

提交回复
热议问题