powershell 来自http://social.technet.microsoft.com/Forums/en-US/9cc5b5c6-e728-4f48-af6c-00cf8be3d4ba/p

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 来自http://social.technet.microsoft.com/Forums/en-US/9cc5b5c6-e728-4f48-af6c-00cf8be3d4ba/p相关的知识,希望对你有一定的参考价值。

cd /c %~dp0
powershell -noexit -file "installwsp.ps1" "%CD%"
pause
Add-PsSnapin Microsoft.SharePoint.PowerShell
 
#Do not modify anything in the script from here onwards
 function Get-ScriptDirectory
 {
  $Invocation = (Get-Variable MyInvocation -Scope 1).Value
  Split-Path $Invocation.MyCommand.Path
 }
 
function Deploy-Solution{
 param(
 [string]$physicalPath,
 [string]$name)
 
$SolutionName = $name
 $SolutionPath = Join-Path ($physicalPath) $SolutionName
 echo "Extracting information from $physicalPath"
 
#Admin service
 $AdminServiceName = "SPAdminV4"
 $IsAdminServiceWasRunning = $true;
 
if ($(Get-Service $AdminServiceName).Status -eq "Stopped")
 {
     $IsAdminServiceWasRunning = $false;
     Start-Service $AdminServiceName
    Write-Host 'SERVICE WAS STOPPED, SO IT IS NOW STARTED'
 }
 
#Uninstall
 Write-Host 'UNINSTALLING SOLUTION ...'
 
$Solution = Get-SPSolution | ? {($_.Name -eq $SolutionName) -and ($_.Deployed -eq $true)}
 
if ($Solution -ne $null)
 {
     if($Solution.ContainsWebApplicationResource)
     {
         Uninstall-SPSolution $SolutionName -AllWebApplications -Confirm:$false
     }
     else
     {
         Uninstall-SPSolution $SolutionName -Confirm:$false
     }
 }
 
while ($Solution.JobExists)
 {
     Start-Sleep 2
 }
 
Write-Host 'SOLUTION HAS BEEN UNINSTALLED SUCCESSFULLY.'
 
Write-Host 'REMOVING SOLUTION ...'
 
if ($(Get-SPSolution | ? {$_.Name -eq $SolutionName}).Deployed -eq $false)
 {
     Remove-SPSolution $SolutionName -Confirm:$false
 
Write-Host 'SOLUTION HAS BEEN REMOVED SUCCESSFULLY.'
 }
 
Write-Host 'ADDING SOLUTION ...'
 
Add-SPSolution $SolutionPath  | Out-Null
 
Write-Host 'SOLUTION HAS BEEN ADDED SUCCESSFULLY.'
 
Write-Host 'DEPLOYING SOLUTION ...'
 
$Solution = Get-SPSolution | ? {($_.Name -eq $SolutionName) -and ($_.Deployed -eq $false)}
 
#use '-force' paramater to install all commands in this if statement
 
if(($Solution -ne $null) -and ($Solution.ContainsWebApplicationResource))
 {
 Install-SPSolution $SolutionName –AllwebApplications -GACDeployment -Force -Confirm:$false
 }
 else
 {
 Install-SPSolution $SolutionName -GACDeployment -Force -Confirm:$false
 }
 
while ($Solution.Deployed -eq $false)
 {
     Start-Sleep 2
 }
 
Write-Host 'SOLUTION HAS BEEN DEPLOYED SUCCESSFULLY.'
 
if (-not $IsAdminServiceWasRunning)
 {
     Stop-Service $AdminServiceName
 }
 }
 
#Get Current Physical Path
 $currentPhysicalPath = Get-ScriptDirectory
 
#Iterate through all .wsp files in the current Physical Path to deploy solution
 get-childitem $currentPhysicalPath -include *.wsp -recurse | foreach ($_) {Deploy-Solution $currentPhysicalPath $_.name}
 
#Remove SharePoint Snapin
 Remove-PsSnapin Microsoft.SharePoint.PowerShell
 
Echo Finish

以上是关于powershell 来自http://social.technet.microsoft.com/Forums/en-US/9cc5b5c6-e728-4f48-af6c-00cf8be3d4ba/p的主要内容,如果未能解决你的问题,请参考以下文章

powershell 添加和删​​除Windows存储来自Powershell / CMD的应用程序

powershell 从文件加载Powershell函数。来自http://stackoverflow.com/a/6016630/1678525

powershell 从文件加载Powershell函数。来自http://stackoverflow.com/a/6016630/1678525

powershell 来自https://stackoverflow.com/questions/1663748/powershell-analog-to-quote-words

使用来自 Textfile 的文件创建 7-Zip 存档 - Powershell

管道文件到 uglifyjs - 来自 Powershell