Link to home
Start Free TrialLog in
Avatar of sqlagent007
sqlagent007Flag for United States of America

asked on

Powershell - windows 2008 r2 - how to change IIS [application user (pass-through authentication)

I need to create a powershell script that changes the IIS setting: "authentication" > "connect as" > "specific user" > "set" > to domain\service_account.

See attached for location
How-can-I-change-the-IIS-7-w-powersh.pdf
Avatar of Adam Brown
Adam Brown
Flag of United States of America image

Open Powershell on the IIS server, Run the following:
add-pssnapin WebAdministration

Open in new window


Then run this:
set-webconfigurationproperty "system.applicationHost/sites/site[@name='Default Web Site']/application[@path='/']/virtualDirectory[@path='/']" -name username -value ''user@domain.com"
set-webconfigurationproperty "system.applicationHost/sites/site[@name='Default Web Site']/application @path='/']/virtualDirectory[@path='/']" -name password -value 'password'

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dustin Saunders
Dustin Saunders
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sqlagent007

ASKER

what do I do when I get an error: " The Windows PowerShell snap-in 'WebAdministration' is not installed on this machine."
pssnapin-webAdministration-error.tiff
For both solutions, I am getting this error:
The term 'Get-WebConfiguration' is not recognized as the name of a cmdlet, function, script file, or operable program.

Open in new window


The term 'Get-WebConfiguration' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:21
+ Get-WebConfiguration <<<<
    + CategoryInfo          : ObjectNotFound: (Get-WebConfiguration:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
To me it looks like the "WebAdministration" module is installed...When I run Get-Module -ListAvailable

PS C:\Windows\system32> Get-Module -ListAvailable

ModuleType Name                      ExportedCommands
---------- ----                      ----------------
Manifest   ActiveDirectory           {}
Manifest   ADRMS                     {}
Manifest   AppLocker                 {}
Manifest   BestPractices             {}
Manifest   BitsTransfer              {}
Manifest   PSDiagnostics             {}
Manifest   ServerManager             {}
Manifest   TroubleshootingPack       {}
Manifest   WebAdministration         {}

Open in new window

Are you running Powershell as admin?
Thanks, I needed to close the PS terminal and re-open it. Then I was able to bring in the WebAdministration module.