Skip to content

Instantly share code, notes, and snippets.

@sannae
Created November 24, 2022 09:09
Show Gist options
  • Save sannae/fd9a42c91f6aa075f6242880cfbe0808 to your computer and use it in GitHub Desktop.
Save sannae/fd9a42c91f6aa075f6242880cfbe0808 to your computer and use it in GitHub Desktop.
Gets all the services and web application whose physical path resides in a specific root folder
$RootFolder = "ROOT_FOLDER_NAME"
# Services whose path contains $RootFolder
Get-CimInstance -ClassName Win32_service | Where-Object {$_.PathName -like "*$RootFolder*"} | Format-Table
# Web application whose physical path contains $RootFolder
$(Get-IISServerManager).Sites["Default Web Site"].Applications | Where-Object {$_.VirtualDirectories.PhysicalPath -like "*$RootFolder*"} | Format-Table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment