Solved

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

Posted on 2016-07-29
7
87 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 39

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
A brief introduction to what I consider to be the best editor for PowerShell.
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
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…

820 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