Solved

Windows Server 2008 R2 - powershell: term 'Get-WebConfiguration' is not recognized as the name of a cmdlet, function, script file, or operable program

Posted on 2016-07-29
3
311 Views
Last Modified: 2016-08-01
I am trying to automate some IIS tasks, and the commands I need to use are not working:

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

Open in new window


However when I run the Get-Module -ListAvailable, the WebAdministration show up
PS C:\Program Files\IIS> 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


Even the basic command:
Get-WebConfiguration

Open in new window

returns an error:
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

Open in new window


Please help me figure out what I need to do to get this working. I am using powershell as the local administrator.
0
Comment
Question by:sqlagent007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 80

Accepted Solution

by:
David Johnson, CD, MVP earned 450 total points
ID: 41735402
# first you have to import the module
import-module  WebAdministration    
# then you can use the cmdlets in the module.
Get-WebConfiguration $pathToSite | select *
set-WebConfigurationproperty $pathToValues -name username -value $taregtUser
set-WebConfigurationproperty $pathToValues -name password -value $taregtPWD

Open in new window

newer versions of powershell will load the module automatically, older versions you must explicitly  load the module
0
 
LVL 69

Assisted Solution

by:Qlemo
Qlemo earned 50 total points
ID: 41735725
To be precise, this has changed with PowerShell 3. You can go up to PS 5 (the current one) on W2008r2, and I recommend to do so (see https://www.microsoft.com/en-us/download/details.aspx?id=50395 for download).
1
 
LVL 1

Author Closing Comment

by:sqlagent007
ID: 41737476
Thanks Experts!!
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

A safe way to clean winsxs folder from your windows server 2008 R2 editions
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
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…

749 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