My IIS looks like this:
Sites ->
Default Web Site ->
MyWebApp
Then the question is: How do I enable Forms Authentication on MyWebApp? I mange to change or edit Anonymous Access, Basic, and Windows Auth. However, Forms Auth is not that easy. How do I do this in Powershell?
I'm able to read the setting this way:
(Get-WebConfiguration system.web/authentication 'IIS:\sites\Default Web Site\MyWebApp').Mode
I'm having trouble or no luck with Set-Webconfiguration, or Set-Webconfigurationproperty. I find these cmdlets hard to figure out.
Change happens in web.config, at least the web.config updates when I hit Enable or Disable on Forms Authentication at the IIS manager. Any clues and tips are highly appreciated.
Or with a one liner:
Set-WebConfiguration system.web/authentication 'IIS:\sites\Default Web Site' -value #{mode='Forms'}
You pipe the authentication configuration settings to Set-Webconfiguration giving the appropriate filter after you modify your properties:
$config = (Get-WebConfiguration system.web/authentication 'IIS:\sites\Default Web Site')
$config.mode = "Forms"
$config | Set-WebConfiguration system.web/authentication
Note: Backup your config before trying this.
Related
$webapp.Parent.ApplyWebConfigModifications() updates all the webapplications in the farm.
For e.g. i have 2 web applications in my sharepoint farm.
webapp1
webapp2
I have web.config updates in webapp1 and below is the code using powershell
$webapp = [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($url)
$change = new-object "Microsoft.SharePoint.Administration.SPWebConfigModification"
$webapp.WebConfigModifications.Add($change)
$webapp.Update()
$webapp.Parent.ApplyWebConfigModifications()
this code works for webapp1 and webapp2 but when i run it for webapp2 i see an update in webapp1 config file also. Am i missing anything here ????
When you use SPWebConfigModication, the change is saved in the SharePoint configuration databases and populated out to all web.config files in the farm. Please see the following articles:
http://msdn.microsoft.com/en-us/library/office/bb861909(v=office.14).aspx
http://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.administration.spwebservice.applywebconfigmodifications(v=office.14).aspx
I can't describe this problem but it happened after I restore a site collection from our development machine to the production server. I see the same error page also when I try to access the site collection.
I tried to set customErrors to Off on all web.config files on the server but no luck.
I deleted the Site collection and the web application of that site but nothing changed. other site collections are working just fine.
Please help.
This is what I see when trying to create a new Web Application.
Maybe One reason is There is already a web application with the same name or same port in Central Application ,
Confirm that that is not the case?
You can try to follow steps given below:
Go to Central Admin->System Settings->Mange Service on server
Check status of following service:
Microsoft SharePoint Foundation Web Application
If it is stuck at stopping state, follow the steps given below:
Open command Prompt
Navigate to 14 Hive/Bin path
Enter following command
stsadm -o provisionservice -action stop -servicetype spwebservice
perform IISRESET with "Noforce" attribute
Execute following command
stsadm -o provisionservice -action start -servicetype spwebservice
Perform IISRESEt with "Noforce" attribute
Hope this helps
can some one help me out on how to Delete SharePoint 2007 /2010 Recyclebin using powershell and webservices.
I don't know if this is what you want, but you can empty web's recycle bin using this two lines in powershell:
$w = get-spweb http://localhost
$w.RecycleBin.DeleteAll()
But I never combined powershell and web services, so this maybe not what you asked for.
I am working on an automated set up of a web server using PowerShell and I need to create a virtual directory which I am able to do using the following code
New-Item 'IIS:\Sites\Default Web Site\folder' -type VirtualDirectory -physicalPath $folder
I also need to set this virtual directory so that it will allow clients to upload files, which can be done manually by opening the BITS Uploads feature and checking the "Allow clients to upload files" check box.
Is there a way to set this using PowerShell?
Thanks in advance
The following example shows how to use PowerShell to enable an IIS virtual directory for BITS uploads. It use System.DirectoryServices to setup virtual directory, it deals with IIS 6 classes, and it also works on IIS 7 if the IIS 6 Management Compatibility feature is installed (see Creating Sites and Virtual Directories Using System.DirectoryServices).
$root = new-object system.directoryservices.directoryentry("IIS://127.0.0.1/W3SVC/1/Root/folder")
$root.EnableBITSUploads()
#$root.BITSUploadEnabled = $true
#$root.setinfo()
I am a developer and I have arrived at a solution to a webservice authentication problem that involved ensuring Kerberos was maintained because of multiple network hops. In short:
A separate application pool for the virtual directory hosting the webservice was established
The Identity of this application pool is set to a configurable account (DOMAINname\username which will remain constant but the strong password is somehow changed every 90 days I think); at a given point in time, the password is known or obtainable somehow by our system admin).
Is there a script language that could be used to setup a new application pool for this application and then set the identity as described (rather than manual data entry into property pages in IIS)?
I think our system admin knows a little about Powershell but can someone help me offer him something to use (he will need to repeat this on 2 more servers as the app is rolled out). Thanks.
You can use such PowerShell script:
Import-Module WebAdministration
$appPool = New-WebAppPool -Name "MyAppPool"
$appPool.processModel.userName = "domain\username"
$appPool.processModel.password = "ReallyStrongPassword"
$appPool.processModel.identityType = "SpecificUser"
$appPool | Set-Item