- Open the PowerShell management shell with administrative rights.
- Run the below command in powershell
- Get-SPServiceApplicationPool | select Id, Name
Samir's Blog
Thursday, 2 June 2016
SharePoint 2103: Powershell command to get IIS application pool name from GUID
Monday, 28 March 2016
SharePoint2013: PowerShell Script to find data based on column value in list/Library
cls
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
$weburl = "http://YourSite"
$listname = "Your SharePoint List/Library"
$Column = "List/Library Column"
$web = get-spweb $weburl
$list = $web.lists[$listname]
$listItems = $list.Items| where {$_['Your List/Library Column Name'] -eq 'Your List/Library Column value'}
$listItems | ForEach-Object {
Write-Host $_.name
}
cls
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}
$weburl = "http://YourSite"
$listname = "Your SharePoint List/Library"
$Column = "List/Library Column"
$web = get-spweb $weburl
$list = $web.lists[$listname]
$listItems = $list.Items| where {$_['Your List/Library Column Name'] -eq 'Your List/Library Column value'}
$listItems | ForEach-Object {
Write-Host $_.name
}
Thursday, 28 January 2016
Do NOT do this on a production server directly. Try to run in Development environment.
Run Powershell : Run the command Get-SPUsageDefinition
It will shows all the things that are retained, and for how long.
Change retention days 3 from 14 by using following PowerShell command:
The next time the Usage Log File timer jobs run it’ll clean out everything more than 3 days old. If we want to manually trigger those jobs we can use this PowerShell:
It will take some time to clear the Audit data table.
Another way:
Below is the script to delete records for particular site:
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$site = Get-SPSite -Identity "Your Site"
$date = Get-Date
$date = $date.AddDays(-3)
#Delete Audit logs
$site.Audit.DeleteEntries($date)
|
Sunday, 24 January 2016
SharePoint 2013 Powershell script to update document library column (choice field category) when any folder created in Document Library
Scenario : My client wants to update a document library column(selected as choice category) whenever a folder is added in document library he wants that folder name should be added in category menu also.
Below is the tested SharePoint 2013 script
--------------------------------------------------------------------------------------------------------
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$web=Get-spweb "Your site collection"
$list=$web.Lists.TryGetList("Your document library")
$i=0
$RootFolder=$web.GetFolder("Your document library")
foreach($folder in $RootFolder.SubFolders)
{
$ChoiceField = $list.Fields.GetField("Your column where category filed needs to be added") #Get the field
if($folder.Name -ne "Forms")
{
$fname= $folder.Name
if($ChoiceField.Choices.Contains($fname))
{
#write-host $ChoiceField.Choices.Item($i)
}
else
{
$ChoiceField.Choices.Add($fname)
}
}
$i=$i+1
$ChoiceField.update()
}
----------------------------------------------------------------------------------------------------------------------
Scenario : My client wants to update a document library column(selected as choice category) whenever a folder is added in document library he wants that folder name should be added in category menu also.
Below is the tested SharePoint 2013 script
--------------------------------------------------------------------------------------------------------
Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$web=Get-spweb "Your site collection"
$list=$web.Lists.TryGetList("Your document library")
$i=0
$RootFolder=$web.GetFolder("Your document library")
foreach($folder in $RootFolder.SubFolders)
{
$ChoiceField = $list.Fields.GetField("Your column where category filed needs to be added") #Get the field
if($folder.Name -ne "Forms")
{
$fname= $folder.Name
if($ChoiceField.Choices.Contains($fname))
{
#write-host $ChoiceField.Choices.Item($i)
}
else
{
$ChoiceField.Choices.Add($fname)
}
}
$i=$i+1
$ChoiceField.update()
}
----------------------------------------------------------------------------------------------------------------------
SharePoint 2013 PowerShell script to create sub folder in Document Library.
Note : Tested in SharePoint 2013
Script will get the date from server and create the sub folder in library named as server date.
Below is the script:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Get the Web
$web=Get-spweb "Your Site Collection"
#Get the List/Library
$list=$web.Lists.TryGetList("Your Document Library Name")
$RootFolder=$web.GetFolder("Your Root Folder name")
$foldername = Get-Date -Format "yyyy-MM-dd"
foreach( $folder in $RootFolder.SubFolders )
{
if($folder.name -ne "Forms")
{
$Subfolder = $list.ParentWeb.GetFolder($folder.URL + "/" + "$foldername");
#write-host $Subfolder
if ($Subfolder.Exists -eq $false)
{
#Create a Sub-Folder Inside "Sales Documents"
$Subfolder = $list.AddItem($folder.URL, [Microsoft.SharePoint.SPFileSystemObjectType]::Folder, "$foldername")
$Subfolder.Update();
Write-host "Sub-Folder created successfully"
}
else
{
write-host "Sub-Folder already exists"
}
}
}
Note : Tested in SharePoint 2013
Script will get the date from server and create the sub folder in library named as server date.
Below is the script:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Get the Web
$web=Get-spweb "Your Site Collection"
#Get the List/Library
$list=$web.Lists.TryGetList("Your Document Library Name")
$RootFolder=$web.GetFolder("Your Root Folder name")
$foldername = Get-Date -Format "yyyy-MM-dd"
foreach( $folder in $RootFolder.SubFolders )
{
if($folder.name -ne "Forms")
{
$Subfolder = $list.ParentWeb.GetFolder($folder.URL + "/" + "$foldername");
#write-host $Subfolder
if ($Subfolder.Exists -eq $false)
{
#Create a Sub-Folder Inside "Sales Documents"
$Subfolder = $list.AddItem($folder.URL, [Microsoft.SharePoint.SPFileSystemObjectType]::Folder, "$foldername")
$Subfolder.Update();
Write-host "Sub-Folder created successfully"
}
else
{
write-host "Sub-Folder already exists"
}
}
}
Thursday, 23 April 2015
Export to excel large file failed in SSRS 2012 SharePoint 2013 integrated mode
we need to perform below changes in SharePoint Environment.
Server : SharePoint WFE server.
Step 1. Open the web.config file(\inetpub\wwwroot\wss\VirtualDirectories\Virtual Directory Name)
Step 2: Backup of Web.config Web application of affected site.
Step 3: Search below tag in web.config
<httpRuntime maxRequestLength="51200" requestValidationMode="2.0" />
and comment the tag like for e.g
<!-<httpRuntime maxRequestLength="51200" requestValidationMode="2.0" />->
and add below code in web.config
<httpRuntime maxRequestLength="100000" executionTimeout="9000" />
save the file and close.
Server : SharePoint Application server
Step 1. Open the web.config file(\inetpub\wwwroot\wss\VirtualDirectories\Virtual Directory Name)
Step 2: Backup of Web.config Web application of affected site.
Step 3: Search below tag in web.config
<httpRuntime maxRequestLength="51200" />
and comment the tag like for e.g
<!-<httpRuntime maxRequestLength="51200" />->
and add below code in web.config
<httpRuntime executionTimeout="9000" maxRequestLength="409600" />
save the file and close.
Repeat the steps for all the WFE and App servers.
Refresh the site and try to export.!!!
we need to perform below changes in SharePoint Environment.
Server : SharePoint WFE server.
Step 1. Open the web.config file(\inetpub\wwwroot\wss\VirtualDirectories\Virtual Directory Name)
Step 2: Backup of Web.config Web application of affected site.
Step 3: Search below tag in web.config
<httpRuntime maxRequestLength="51200" requestValidationMode="2.0" />
and comment the tag like for e.g
<!-<httpRuntime maxRequestLength="51200" requestValidationMode="2.0" />->
and add below code in web.config
<httpRuntime maxRequestLength="100000" executionTimeout="9000" />
save the file and close.
Server : SharePoint Application server
Step 1. Open the web.config file(\inetpub\wwwroot\wss\VirtualDirectories\Virtual Directory Name)
Step 2: Backup of Web.config Web application of affected site.
Step 3: Search below tag in web.config
<httpRuntime maxRequestLength="51200" />
and comment the tag like for e.g
<!-<httpRuntime maxRequestLength="51200" />->
and add below code in web.config
<httpRuntime executionTimeout="9000" maxRequestLength="409600" />
save the file and close.
Repeat the steps for all the WFE and App servers.
Refresh the site and try to export.!!!
Monday, 13 April 2015
SharePoint 2013 IIS Application Pool detailed Information using Powershell.
Steps:
Get-SPServiceApplication | Select Name, @{Name="SPAppPoolName"; Expression={$_.ApplicationPool.Name}}, @{Name="IISAppPoolName"; Expression={$_.ApplicationPool.Id}}, @{Name="ProcessAccountName"; Expression={$_.ApplicationPool.ProcessAccountName}}
Steps:
- Run Powershell as an administrator.
- Copy the below powershell command and execute.
Get-SPServiceApplication | Select Name, @{Name="SPAppPoolName"; Expression={$_.ApplicationPool.Name}}, @{Name="IISAppPoolName"; Expression={$_.ApplicationPool.Id}}, @{Name="ProcessAccountName"; Expression={$_.ApplicationPool.ProcessAccountName}}
Subscribe to:
Posts (Atom)