Enable-WSManCredSSP -Role client -DelegateComputer “FQDN-SERVER”
Enter-PSSession -Computer FQDN-SERVER -Authentication CredSSP -Credential DOMINIO\USUARIO
Add-PSSnapin Microsoft.SharePoint.Powershell
jueves, 29 de octubre de 2015
InstallSolution.ps1 - Este Script implementa todos los WSP que se encuentren dentro de la misma carpeta
function WaitForJobToFinish([string]$Identity)
{
$job = Get-SPTimerJob | ?{ $_.Name -like "*solution-deployment*$Identity*" }
$maxwait = 30
$currentwait = 0
if (!$job)
{
Write-Host -f Red '[ERROR] Timer job not found'
}
else
{
$jobName = $job.Name
Write-Host -NoNewLine "[WAIT] Waiting to finish job $jobName"
while (($currentwait -lt $maxwait))
{
Write-Host -f Green -NoNewLine .
$currentwait = $currentwait + 1
Start-Sleep -Seconds 2
if (!(Get-SPTimerJob $jobName)){
break;
}
}
Write-Host -f Green "...Done!"
}
}
function RetractSolution([string]$Identity)
{
Write-Host "[RETRACT] Uninstalling $Identity"
Write-Host -NoNewLine "[RETRACT] Does $Identity contain any web application-specific resources to deploy?"
$solution = Get-SPSolution | where { $_.Name -match $Identity }
if($solution.ContainsWebApplicationResource)
{
Write-Host -f Yellow "...Yes!"
Write-Host -NoNewLine "[RETRACT] Uninstalling $Identity from all web applications"
Uninstall-SPSolution -identity $Identity -allwebapplications -Confirm:$false
Write-Host -f Green "...Done!"
}
else
{
Write-Host -f Yellow "...No!"
Uninstall-SPSolution -identity $Identity -Confirm:$false
Write-Host -f Green "...Done!"
}
WaitForJobToFinish
Write-Host -NoNewLine '[UNINSTALL] Removing solution:' $SolutionName
Remove-SPSolution -Identity $Identity -Confirm:$false
Write-Host -f Green "...Done!"
}
function DeploySolution([string]$Path, [string]$Identity)
{
Write-Host -NoNewLine "[DEPLOY] Adding solution:" $Identity
Add-SPSolution $Path
Write-Host -f Green "...Done!"
Write-Host -NoNewLine "[DEPLOY] Does $Identity contain any web application-specific resources to deploy?"
$solution = Get-SPSolution | where { $_.Name -match $Identity }
if($solution.ContainsWebApplicationResource)
{
Write-Host -f Yellow "...Yes!"
Write-Host -NoNewLine "[DEPLOY] Installing $Identity for all web applications"
Install-SPSolution -Identity $Identity -AllWebApplications -GACDeployment
}
else
{
Write-Host -f Yellow "...No!"
Write-Host -NoNewLine "[DEPLOY] Globally deploying $Identity"
Install-SPSolution -Identity $Identity -GACDeployment
}
Write-Host -f Green "...Done!"
WaitForJobToFinish
}
$snapin = Get-PSSnapin | Where-Object { $_.Name -eq "Microsoft.SharePoint.Powershell" }
if ($snapin -eq $null) {
Write-Host "[INIT] Loading SharePoint Powershell Snapin"
Add-PSSnapin "Microsoft.SharePoint.Powershell"
}
Write-Host "[INIT] Locating WSP files to be deployed"
$wsps = Get-ChildItem . *.wsp | where-object { !($_.psiscontainer) }
foreach ($wsp in $wsps)
{
$identity = $wsp.Name
$path = $wsp.FullName
Write-Host "[INFO] ----------------------------------------"
Write-Host "[INFO] Installing $Identity"
Write-Host -NoNewLine "[INFO] Determining if $Identity is already installed"
$isInstalled = Get-SPSolution | where { $_.Name -eq $identity }
if ($isInstalled)
{
Write-Host -ForegroundColor Yellow "...Yes!"
(RetractSolution $identity)
(DeploySolution $path $identity)
}
else
{
Write-Host -ForegroundColor Yellow "...No!"
(DeploySolution $path $identity)
}
Write-Host -NoNewline "[INFO] Installation and deployment of $Identity"
Write-Host -ForegroundColor Green "...Done!"
}
{
$job = Get-SPTimerJob | ?{ $_.Name -like "*solution-deployment*$Identity*" }
$maxwait = 30
$currentwait = 0
if (!$job)
{
Write-Host -f Red '[ERROR] Timer job not found'
}
else
{
$jobName = $job.Name
Write-Host -NoNewLine "[WAIT] Waiting to finish job $jobName"
while (($currentwait -lt $maxwait))
{
Write-Host -f Green -NoNewLine .
$currentwait = $currentwait + 1
Start-Sleep -Seconds 2
if (!(Get-SPTimerJob $jobName)){
break;
}
}
Write-Host -f Green "...Done!"
}
}
function RetractSolution([string]$Identity)
{
Write-Host "[RETRACT] Uninstalling $Identity"
Write-Host -NoNewLine "[RETRACT] Does $Identity contain any web application-specific resources to deploy?"
$solution = Get-SPSolution | where { $_.Name -match $Identity }
if($solution.ContainsWebApplicationResource)
{
Write-Host -f Yellow "...Yes!"
Write-Host -NoNewLine "[RETRACT] Uninstalling $Identity from all web applications"
Uninstall-SPSolution -identity $Identity -allwebapplications -Confirm:$false
Write-Host -f Green "...Done!"
}
else
{
Write-Host -f Yellow "...No!"
Uninstall-SPSolution -identity $Identity -Confirm:$false
Write-Host -f Green "...Done!"
}
WaitForJobToFinish
Write-Host -NoNewLine '[UNINSTALL] Removing solution:' $SolutionName
Remove-SPSolution -Identity $Identity -Confirm:$false
Write-Host -f Green "...Done!"
}
function DeploySolution([string]$Path, [string]$Identity)
{
Write-Host -NoNewLine "[DEPLOY] Adding solution:" $Identity
Add-SPSolution $Path
Write-Host -f Green "...Done!"
Write-Host -NoNewLine "[DEPLOY] Does $Identity contain any web application-specific resources to deploy?"
$solution = Get-SPSolution | where { $_.Name -match $Identity }
if($solution.ContainsWebApplicationResource)
{
Write-Host -f Yellow "...Yes!"
Write-Host -NoNewLine "[DEPLOY] Installing $Identity for all web applications"
Install-SPSolution -Identity $Identity -AllWebApplications -GACDeployment
}
else
{
Write-Host -f Yellow "...No!"
Write-Host -NoNewLine "[DEPLOY] Globally deploying $Identity"
Install-SPSolution -Identity $Identity -GACDeployment
}
Write-Host -f Green "...Done!"
WaitForJobToFinish
}
$snapin = Get-PSSnapin | Where-Object { $_.Name -eq "Microsoft.SharePoint.Powershell" }
if ($snapin -eq $null) {
Write-Host "[INIT] Loading SharePoint Powershell Snapin"
Add-PSSnapin "Microsoft.SharePoint.Powershell"
}
Write-Host "[INIT] Locating WSP files to be deployed"
$wsps = Get-ChildItem . *.wsp | where-object { !($_.psiscontainer) }
foreach ($wsp in $wsps)
{
$identity = $wsp.Name
$path = $wsp.FullName
Write-Host "[INFO] ----------------------------------------"
Write-Host "[INFO] Installing $Identity"
Write-Host -NoNewLine "[INFO] Determining if $Identity is already installed"
$isInstalled = Get-SPSolution | where { $_.Name -eq $identity }
if ($isInstalled)
{
Write-Host -ForegroundColor Yellow "...Yes!"
(RetractSolution $identity)
(DeploySolution $path $identity)
}
else
{
Write-Host -ForegroundColor Yellow "...No!"
(DeploySolution $path $identity)
}
Write-Host -NoNewline "[INFO] Installation and deployment of $Identity"
Write-Host -ForegroundColor Green "...Done!"
}
miércoles, 28 de octubre de 2015
Backup All Site Collections in SharePoint
http://nubo.eu/sharepoint/it-pro/plamber/using-powershell-to-backup-all-site-collections-in-sharepoint/
A Quick Guide to Getting, Setting and Copying User Profile Properties using PowerShell
http://matthewyarlett.blogspot.com.ar/2013/10/a-quick-guide-to-getting-and-setting_30.html
viernes, 23 de octubre de 2015
How to enable Remote PowerShell for SharePoint 2013 for Non-Administrators
On the SharePoint Servers:
- In Server Manager, add the user(s) to the following Groups:
- Remote Desktop Users
- WinRMRemoteWMIUsers__
- WSS_ADMIN_WPG
- Run the SharePoint Management Shell as Administrator
- Type Enable-PSRemoting -Force
- Type Enable-WSManCredSSP –Role Server
- Type winrm set winrm/config/winrs '@{MaxShellsPerUser="25"}'
- Type winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="600"}'
- Type Get-SPShellAdmin
- This should only return all the users who have the SharePoint_Shell_Access role
- Type Add-SPShellAdmin -UserName Domain\Username -Database (Get-SPContentDatabase -Identity “ContentDatabaseName”)
- Replace Domain\Username with the user needing access
- Replace ContentDatabaseName with one of the Content Databases
- You will need to run this command for all content databases for the user(s) who need access
- NOTE-> To grant access to all content databases use the following command:Get-SPDatabase | Add-SPShellAdmin DOMAIN\UserName
- Type Get-SPShellAdmin
- The user you added should now be listed
- Type Set-PSSessionConfiguration -Name Microsoft.PowerShell32 –ShowSecurityDescriptorUI
- This will open up a dialog box. Add the user(s) with Read and Execute permissions then click OK
- Run the command again to ensure the permissions were applied correctly
On the Client Machine:
- Open Windows PowerShell as Administrator
- Type Enable-WSManCredSSP -Role client -DelegateComputer “SharePointServerName”
- Replace SharePointServerName with the FQDN of the SharePoint server
- Type $cred=get-Credential
- Type $s=new-PSsession “SharePointServerName” -authentication credssp -credential $cred
- Replace SharePointServerName with the FQDN of the SharePoint server
- NOTE: If this fails with an "access denied" error, re-run Step 10 on the server to enable configuration of the x64 PowerShell by running Set-PSSessionConfiguration -Name Microsoft.PowerShell32 –ShowSecurityDescriptorUI
- Type Invoke-Command -Session $s -ScriptBlock {Add-PSSnapin Microsoft.SharePoint.PowerShell;}
- Type Invoke-Command -Session $s -ScriptBlock {get-SPContentDatabase}
- This will return all the content databases in your SharePoint farm and ensure you have access
- Type Invoke-Command -Session $s -ScriptBlock {get-spserviceinstance}
- This will return the SharePoint service instances and ensure you have access
- Type Enter-PSSession -session $s
You will now see the servers name in [ ] PS: c:\users\someuser\documents
Example: [sp2013-app.fabrikaminc.local]: PS C:\Users\egutierrez\Documents>
At this point, the user can implement PowerShell scripts on the SharePoint server.
Note: Special thanks to Mark Kordelski & Samer Judeh for the assistance with this!
jueves, 8 de octubre de 2015
Listar todas las Features activas de un Site Collection - SharePoint
$allSiteFeatures = Get-SPFeature | Where-Object { $_.Scope -eq "Site" }
$activeFeatures = Get-SPFeature -Site "http://sitecollectionUrl"
$allSiteFeatures | ForEach-Object {
$active = $false
foreach($feature in $activeFeatures)
{
if($feature.Id.ToString() -eq $_.Id.ToString())
{
$active = $true
}
}
if(!$active)
{
$_ | DisplayName,ID
}
}
$activeFeatures = Get-SPFeature -Site "http://sitecollectionUrl"
$allSiteFeatures | ForEach-Object {
$active = $false
foreach($feature in $activeFeatures)
{
if($feature.Id.ToString() -eq $_.Id.ToString())
{
$active = $true
}
}
if(!$active)
{
$_ | DisplayName,ID
}
}
Suscribirse a:
Entradas (Atom)