Saturday 23 March 2013

PowerShell script - CRM version number and rollup updates


################
#     This script queries the local server registry to obtain the CRM version number and installs rollup updates depending on the returned version number
#  
#     Jonathan read and Jason Hough
#
#     14.02.13
#################

###Logging###


$scriptname = $MyInvocation.MyCommand.Name
$scriptpath = $MyInvocation.MyCommand.Path

$transcriptFile = "C:\Users\mgr1137107\Documents\Powershell_$scriptname.log"

Start-Transcript $transcriptFile -append -force

Write-Output "Starting Script: $scriptpath"


###Variables###

$path ="Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM"
$name = "CRM_Server_Version"


###Trapping###


$p=Get-ItemProperty $path
if(!$p){


    'CRM is not deployed on this server'


}else{


    ' CRM is deployed on this server - the script will now continue'


}

###Functions###

FUNCTION DEPLOYMENT1

#Deploys rollup 6 then rollup 11

{ write-host "Deploying rollups 6 and 11"      }

FUNCTION DEPLOYMENT2

#Deploys rollup 11

{   write-host "Deploying rollup 11"     }


###VersionNumber###



    $key = Get-Item -LiteralPath $path -ErrorAction SilentlyContinue
    if ($key) {
        $key.GetValue($name, $null)
    }


# $VN = $key.GetValue($name, $null)
Write-host "The version number is "$key.GetValue($name, $null)

###CORE LOGIC###

if (

($Version -eq "5.0.9688.1045") -or ($Version -eq "5.0.9688.1157") -or ($Version -eq "5.0.9688.1244") -or ($Version -eq "5.0.9688.1450") -or ($Version -eq

"5.0.9688.1533")

 )

{DEPLOYMENT1}

else


{DEPLOYMENT2}


stop-transcript




No comments:

Post a Comment

SharePoint Information Architecture Diagram

Here is the template I use for Information Architecture designs. It's built using Mindjet and I flesh the nodes out with the low level d...