Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

Monday, 26 March 2012

Automated SSL Certificate Import (Certutil)

Just a quick script drop.  You can use this script to import SSL certificates.  It will import all the the PFX files in the directory to your COMPUTER\Personal\ Store.  Which is the required store for your SSL Certificates.  It does not import intermediate or CA certificates.  I might add that functionality one day.  Any questions post a comment below:


  1. Create a Directory called "SSL" (or something like that)
  2. Drop all your PFX files into the SSL folder
  3. Create a Batch File "InstallCert.bat" 
  4. Run a command prompt as administrator
  5. Change Directory to your batch file and run it
Batch File Contents


set CURDIR=%CD%
for /f "usebackq delims=|" %%f in (`dir /b "%CURDIR%" ^| findstr /i pfx`) do certutil.exe -f -p <PFX File Password> -importpfx "%CURDIR%\%%f"
pause

Thursday, 9 February 2012

Update-SPSolution Automated Install

Just a quick script drop, I am going to polish this up a bit over the coming weeks.  This script will Update all of the WSP’s in the install folder. It will not add new solutions only update old ones.  How it works:
  1. Create the following folder structure (where OutofBand is the name of your release):


  2. Drop your wsps you want to release in the install folder
  3. Drop your current production wsps in the rollback folder (if you do not have them check this out)
  4. Create setup.ps1 in the OutofBand folder with the following code
  5. Do not run this from PowerShell ISE, the Get-Location will fail.  This will cause an IISReset

  6. #Release Script for SharePoint 2010 wsps (assumes wsps have already been released)
    asnp Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue

    [string]$strDeploymentFiles = Get-Location -PSProvider FileSystem;
    [bool]$Rollback = $false;

    if ($Rollback)
    {$strDeploymentFiles += "\rollback\";}
    else
    {$strDeploymentFiles += "\install\";}

    $strd = dir -Recurse $strDeploymentFiles *.wsp;
    foreach($wsp in $strd)
    {
        [string]$strWSPName = $wsp  
        Update-SPSolution -Identity $strWSPName -LiteralPath "$strDeploymentFiles$wsp" -Force -GAC
    }


  7. To deploy your solution files simply run setup.ps1 from SharePoint 2010 Management Shell
  8. If you need to roll back update the $Rollback variable to $true






Wednesday, 14 December 2011

PowerShell - Where is the IntelliSense??

Don't you wish PowerShell had IntelliSense?  If you need to find out what properties or methods an Object has you can create pass the object into the Get-Member cmdlet. and it will output the details

If you need to find out how to work with a string object load a variable with a string.
$test = "Test"
$test | Get-Member

You will get the following output


Name
MemberType
Definition
Clone
Method
System.Object Clone()
CompareTo       
Method               
int CompareTo(System.Object value), i...

Contains        
Method               
bool Contains(string value)

CopyTo          
Method               
System.Void CopyTo(int sourceIndex, c...

EndsWith        
Method               
bool EndsWith(string value), bool End...


This will of course work with SharePoint objects.

Happy Scripting!!