Skip to content. | Skip to navigation

Personal tools


You are here: Home / weblog / Powershell profile for Tridion development

Powershell profile for Tridion development

Posted by Dominic Cronin at Mar 15, 2009 09:50 PM |

My powershell profile for Tridion and general .Net development

I have recently stopped using a local vmware image on my laptop for development work, and instead I now use an image hosted on a proper vmware server at the office. I pretty soon discovered that I needed the vcvars script from my other powershell profile. As it took me ten minutes to load up the old image and copy the profile, I figured I'd post it here for future reference. The good bits nicked from elsewhere are credited inline.

Edit: The aliases for the compound templating uploader didn't really work, so now I have a function for this.


function prompt { "PS " + (get-location).Path + "`n> " }
& {
  $prp=new-object System.Security.Principal.WindowsPrincipal($wid)
    if ($IsAdmin)
  $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()
  $p = New-Object System.Security.Principal.WindowsPrincipal($id)
  if ($p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))
   $Host.UI.RawUI.WindowTitle = "Administrator: " + $Host.UI.RawUI.WindowTitle
  function VsVars32($version = "8.0")
      $key = "HKLM:SOFTWARE\Microsoft\VisualStudio\" + $version
      $VsKey = get-ItemProperty $key
      $VsInstallPath = [System.IO.Path]::GetDirectoryName($VsKey.InstallDir)
      $VsToolsDir = [System.IO.Path]::GetDirectoryName($VsInstallPath)
      $VsToolsDir = [System.IO.Path]::Combine($VsToolsDir, "Tools")
      $BatchFile = [System.IO.Path]::Combine($VsToolsDir, "vsvars32.bat")
      Get-Batchfile $BatchFile
      [System.Console]::Title = "Visual Studio " + $version + " Windows Powershell"
  function Get-Batchfile ($file) {
      $cmd = "`"$file`" & set"
      cmd /c $cmd | Foreach-Object {
          $p, $v = $_.split('=')
          Set-Item -path env:$p -value $v
  set-alias -name rat -value RestartAllTridion
  function RestartAllTridion
  "### Restart All Tridion ###"
  "Stopping All Tridion services"
  service TC*, Tri* | stop-service -force
  "Doing an IISRESET"
  "Starting all Tridion services"
  service TC*, Tri* | start-service
  "### Done ###"
  set-alias -name kt -value killTridion
  function KillTridion
  "Shutting down Tridion COM+ Application
  $COMAdminCatalog = new-object -com COMAdmin.COMAdminCatalog
  $COMAdminCatalog.ShutdownApplication("Tridion Content Manager")
  set-alias -name upta -value uploadTridionAssembly
  function uploadTridionAssembly {
    & 'C:\Program Files\Tridion\bin\client\TcmUploadAssembly.exe' /verbose config.xml $args[0]