$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
Related
Our sharepoint application database ip is now changed, (It is not under my control)
Since it is changed i cannot connect to my web site and cannot connect to central administration.
So how can i find the place where the database ip/name is stored so that i can change the db configration.
i have checked all the web.config files under iis->explore folder
i have changed the 'dsn' key under path
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Shared Tools\Web Server Extensions\14.0\Secure\ConfigDb
You could change the database instance of the application with the SharePoint Management Shell.
If you want to change all application at once you could run following powershell code:
# ForEach schleife
ForEach( $db in get-spdatabase) {
$db.ChangeDatabaseInstance("newDataBaseAddress")
$db.Update()
}
If you want to change only one application you can run following code:
$db = get-spdatabase -identity id
$db.ChangeDatabaseInstance("newDataBaseAddress")
$db.Update()
To get the ids of the applications simply run:
get-spdatabase
To change database server for Central Administration if WSS_Admin is depending on old database run following code:
$centralAdmin=Get-SPWebApplication -IncludeCentralAdministration | ? {$_.DisplayName -match ‘SharePoint Central Administration’}
$good=Get-SPWebApplication -identity placeHereTheIdOfAnApplicationThatHasTheCorrectDatabaseInstance
$centralAdmin.Parent.DefaultDatabaseInstance=$good.Parent.DefaultDatabaseInstance
$centralAdmin.Parent.Update()
$centralAdmin.Update()
I hope i could help.
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
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.
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()