Posts

Showing posts from March, 2024

SOLVED: Get the "connect as" credentials for an IIS web application using the "WebAdministration" PowerShell cmdlets Get-WebApplication

Image
When using the WebAdministration PowerShell cmdlets Get-WebVirtualDirectory the username, password and other virtual directory information as expected. However when using the Get-WebApplication cmdlet these properties aren't available even though a web application is a virtual directory. If you look at the applicationHost.config file you'll see that the application in fact has a virtual directory (with path "/") associated with it.  This virtual directory has the additional information required. <application path="/TestApp" applicationPool="TestSite">    <virtualDirectory path="/" physicalPath="C:\TestApp" userName="administrator" password="[enc:AesProvider:B2sdfsd1213E98dV53cb5NfdZndNWvCUf/AekXE=:enc]" /> </application> To access this information get the "/" virtual directory from the collection property. $app = Get-WebApplication "TestApp" ; $app . Collection [ 0