IIS WebAdministration - set physical path credentials locked

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Daniel Krebs Daniel Krebs 2 years, 1 month ago.

  • Author
    Posts
  • #20144
    Profile photo of Scott Vierregger
    Scott Vierregger
    Participant

    I am getting an error when I try to clear or set the IIS physical path credentials in Powershell 3 using the WebAdministration module. I want to be able to make the changes at the application level so I don't interfere with other applications or sites on the server. Specifying a PSPath and location doesn't seem to do anything.

    I assume I have to unlock the section, but the closest section I can find is Sites, and that is too coarse. I would appreciate the assistance if anybody knows exactly what to do in Powershell to manage the IIS physical path credentials (and all application-related settings) at the application level? I was looking for a command to create a location tag for my application, and then be able to specify that location tag for all my subsequent setting changes – but no joy.

    Cheers

  • #20147
    Profile photo of Daniel Krebs
    Daniel Krebs
    Participant

    Hi Scott,

    I haven't found a way to apply the physical path credentials using the Set-WebConfiguration cmdlets but below works for me.

    Import-Module WebAdministration
    
    $SitePath = 'IIS:\Sites\Test'
    
    Set-ItemProperty -Path $SitePath -Name userName -Value 'DOMAIN\TestUser'
    Set-ItemProperty -Path $SitePath -Name password -Value 'Pa55word'
    

    Best,
    Daniel

  • #20149
    Profile photo of Daniel Krebs
    Daniel Krebs
    Participant

    I take back that I haven't found a way to use Set-WebConfiguration 🙂

    Set-WebConfiguration -Filter "/system.applicationHost/sites/site[@name='Test']/application[@path='/']/virtualDirectory[@path='/']" -Value @{userName='DOMAIN\TestUser'; password='Pa55word'}
    

    Please let me know if above works for you.

    Thanks
    Daniel

You must be logged in to reply to this topic.