Solved

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

Posted on 2016-07-29
7
64 Views
Last Modified: 2016-08-02
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
0
Comment
Question by:sqlagent007
  • 4
  • 2
7 Comments
 
LVL 38

Expert Comment

by:Adam Brown
ID: 41735201
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

0
 
LVL 12

Accepted Solution

by:
Dustin Saunders earned 500 total points
ID: 41735210
Give this a go.  Specify the credentials you want to use at the top and the website name, and fire away.

Import-Module -Name "web*"

$taregtUser="donstupid@wizdev.local"
$taregtPWD="2stupid4u"
$siteName='"Default Web Site"'
$pathToSite='system.applicationhost/sites/site[@name='+$siteName+']'
$pathToValues=$pathtosite+'/application[@path="/"]/virtualdirectory[@path="/"]'

Get-WebConfiguration $pathToSite | select *
set-WebConfigurationproperty $pathToValues -name username -value $taregtUser
set-WebConfigurationproperty $pathToValues -name password -value $taregtPWD

Open in new window

0
 
LVL 1

Author Comment

by:sqlagent007
ID: 41735225
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
0
Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

 
LVL 1

Author Comment

by:sqlagent007
ID: 41735243
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
0
 
LVL 1

Author Comment

by:sqlagent007
ID: 41735246
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

0
 
LVL 12

Expert Comment

by:Dustin Saunders
ID: 41739730
Are you running Powershell as admin?
0
 
LVL 1

Author Closing Comment

by:sqlagent007
ID: 41739794
Thanks, I needed to close the PS terminal and re-open it. Then I was able to bring in the WebAdministration module.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now