Created
August 24, 2017 23:58
-
-
Save stanislavhordiyenko/abf85cb74dcd2f764c9314cd22d77f70 to your computer and use it in GitHub Desktop.
Test-VirtualDirectory function will help you to find out whether virtual directory exists in IIS from powershell script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module WebAdministration | |
function Test-VirtualDirectory | |
{ | |
param( | |
[string]$WebsiteName, | |
[string]$VirtualDirectoryPath | |
) | |
if (-not (Test-Path "IIS:\Sites\$WebsiteName")) { | |
throw "$WebsiteName website could not be found in IIS" | |
} | |
return (Get-ChildItem "IIS:\Sites\$WebsiteName" | Where { $_.Schema.Name -eq 'VirtualDirectory' -and $_.Name -eq $VirtualDirectoryPath } | Measure).Count -eq 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment