Thursday, November 19, 2015

SharePoint 2013: Install Solutions with PowerShell Remoting

Remoting Configurations

1. Check remoting service is running by executing get-service winrm
2. Enable the remoting by executing Enable-PSRemoting –force
3. Run the command on the server Enable-WSManCredSSP -Role Server
4. Run the following command on the client
set-item wsman:localhost\client\trustedhosts -value *

Enable-WSManCredSSP -Role Client –DelegateComputer *

 

$remoteMachine = "de-c-qs-ws.domain.de"
$userName = "domain\user";
$password = "Password";
$filePath = "C:\solutions\solution.wsp"


$pass =  $password | ConvertTo-SecureString -AsPlainText -Force>
$credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $userName, $pass
$session = New-PSSession $remoteMachine -Authentication Credssp -Credential $credentials

Write-Host "Loaded PowerShell Assembly" -f Green;
Invoke-Command -Session $session -ScriptBlock { Add-PSSnapin Microsoft.SharePoint.PowerShell; }

Invoke-Command -Session $session -ScriptBlock { Install-SPSolution -Identity $args[0] -GACDeployment } -ArgumentList $newSolution.SolutionId                                              
$newSolution = Invoke-Command -Session $session -ScriptBlock { Add-SPSolution -LiteralPath $args[0] } -ArgumentList $filePath
Write-Host "Added Solution: " $filePath -f Green;#>
                      
Remove-PSSession -Session $session
#Write-Host "Installed Solution: " $filePath -f Green;

No comments:

Post a Comment