Skip to content

Instantly share code, notes, and snippets.

@patrickperrone
Last active November 2, 2017 11:00
Show Gist options
  • Select an option

  • Save patrickperrone/59b8745ee8b8ff9045b5 to your computer and use it in GitHub Desktop.

Select an option

Save patrickperrone/59b8745ee8b8ff9045b5 to your computer and use it in GitHub Desktop.

Revisions

  1. patrickperrone revised this gist May 19, 2017. 1 changed file with 11 additions and 6 deletions.
    17 changes: 11 additions & 6 deletions ChangeSearchProvider.ps1
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,9 @@
    Function Set-SCSearchProvider
    function Get-ConfigFileFilter([string]$providerName)
    {
    return "^.*\." + $providerName + "\.(.+\.)?config.*$"
    }

    function Set-SCSearchProvider
    {
    $rootPath = Read-Host "What is the path of your Sitecore instance's website folder?";
    $choice = Read-Host "(L)ucene or (S)olr?";
    @@ -34,9 +39,9 @@ Function Set-SCSearchProvider
    $deselectedProvider = "Lucene";
    }

    #enumerate all config files to be enabled
    $filter = "*." + $selectedProvider + ".*config*";
    $filesToEnable = Get-ChildItem -Recurse -File -Path $rootPath -Filter $filter;
    #enumerate all config files to be enabled
    $regexp = Get-ConfigFileFilter $selectedProvider
    $filesToEnable = Get-ChildItem -Recurse -File -Path $rootPath | Where-Object { $_.FullName -match $regexp }
    foreach ($file in $filesToEnable)
    {
    Write-Host $file.Name;
    @@ -49,8 +54,8 @@ Function Set-SCSearchProvider
    }

    #enumerate all config files to be disabled
    $filter = "*" + $deselectedProvider + "*.config*";
    $filesToDisable = Get-ChildItem -Recurse -File -Path $rootPath -Filter $filter;
    $regexp = Get-ConfigFileFilter $deselectedProvider
    $filesToDisable = Get-ChildItem -Recurse -File -Path $rootPath | Where-Object { $_.FullName -match $regexp }
    foreach ($file in $filesToDisable)
    {
    Write-Host $file.Name;
  2. patrickperrone revised this gist Mar 23, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion ChangeSearchProvider.ps1
    Original file line number Diff line number Diff line change
    @@ -35,7 +35,7 @@ Function Set-SCSearchProvider
    }

    #enumerate all config files to be enabled
    $filter = "*" + $selectedProvider + "*.config*";
    $filter = "*." + $selectedProvider + ".*config*";
    $filesToEnable = Get-ChildItem -Recurse -File -Path $rootPath -Filter $filter;
    foreach ($file in $filesToEnable)
    {
  3. patrickperrone revised this gist Jul 5, 2015. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions ChangeSearchProvider.ps1
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Function Change-SCSearchProvider
    Function Set-SCSearchProvider
    {
    $rootPath = Read-Host "What is the path of your Sitecore instance's website folder?";
    $choice = Read-Host "(L)ucene or (S)olr?";
    @@ -23,13 +23,13 @@ Function Change-SCSearchProvider
    {
    If (($choice -eq "L"))
    {
    Write-Host "Change to Lucene." -ForegroundColor Yellow;
    Write-Host "Set to Lucene." -ForegroundColor Yellow;
    $selectedProvider = "Lucene";
    $deselectedProvider = "Solr";
    }
    ElseIf (($choice -eq "S"))
    {
    Write-Host "Change to Solr." -ForegroundColor Yellow;
    Write-Host "Set to Solr." -ForegroundColor Yellow;
    $selectedProvider = "Solr";
    $deselectedProvider = "Lucene";
    }
    @@ -64,4 +64,4 @@ Function Change-SCSearchProvider
    }
    }

    Change-SCSearchProvider
    Set-SCSearchProvider
  4. patrickperrone revised this gist Mar 12, 2015. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions ChangeSearchProvider.ps1
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,3 @@
    Change-SCSearchProvider

    Function Change-SCSearchProvider
    {
    $rootPath = Read-Host "What is the path of your Sitecore instance's website folder?";
    @@ -38,7 +36,7 @@ Function Change-SCSearchProvider

    #enumerate all config files to be enabled
    $filter = "*" + $selectedProvider + "*.config*";
    $filesToEnable = Get-ChildItem Recurse -File -Path $rootPath -Filter $filter;
    $filesToEnable = Get-ChildItem -Recurse -File -Path $rootPath -Filter $filter;
    foreach ($file in $filesToEnable)
    {
    Write-Host $file.Name;
    @@ -52,7 +50,7 @@ Function Change-SCSearchProvider

    #enumerate all config files to be disabled
    $filter = "*" + $deselectedProvider + "*.config*";
    $filesToDisable = Get-ChildItem Recurse -File -Path $rootPath -Filter $filter;
    $filesToDisable = Get-ChildItem -Recurse -File -Path $rootPath -Filter $filter;
    foreach ($file in $filesToDisable)
    {
    Write-Host $file.Name;
    @@ -64,4 +62,6 @@ Function Change-SCSearchProvider
    }
    }
    }
    }
    }

    Change-SCSearchProvider
  5. patrickperrone created this gist Mar 8, 2015.
    67 changes: 67 additions & 0 deletions ChangeSearchProvider.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,67 @@
    Change-SCSearchProvider

    Function Change-SCSearchProvider
    {
    $rootPath = Read-Host "What is the path of your Sitecore instance's website folder?";
    $choice = Read-Host "(L)ucene or (S)olr?";


    $validInput = $true;
    #test that path is valid
    If (!(Test-Path -Path $rootPath))
    {
    Write-Host "The supplied path was invalid or inaccessible." -ForegroundColor Red;
    $validInput = $false;
    }
    #test that choice is valid
    ElseIf (($choice -ne "L") -and ($choice -ne "S"))
    {
    Write-Host "You must choose L or S." -ForegroundColor Red;
    $validInput = $false;
    }


    If ($validInput)
    {
    If (($choice -eq "L"))
    {
    Write-Host "Change to Lucene." -ForegroundColor Yellow;
    $selectedProvider = "Lucene";
    $deselectedProvider = "Solr";
    }
    ElseIf (($choice -eq "S"))
    {
    Write-Host "Change to Solr." -ForegroundColor Yellow;
    $selectedProvider = "Solr";
    $deselectedProvider = "Lucene";
    }

    #enumerate all config files to be enabled
    $filter = "*" + $selectedProvider + "*.config*";
    $filesToEnable = Get-ChildItem –Recurse -File -Path $rootPath -Filter $filter;
    foreach ($file in $filesToEnable)
    {
    Write-Host $file.Name;
    if (($file.Extension -ne ".config"))
    {
    $newFileName = [io.path]::GetFileNameWithoutExtension($file.FullName);
    $newFile = Rename-Item -Path $file.FullName -NewName $newFileName -PassThru;
    Write-Host "-> " $newFile.Name -ForegroundColor Green;
    }
    }

    #enumerate all config files to be disabled
    $filter = "*" + $deselectedProvider + "*.config*";
    $filesToDisable = Get-ChildItem –Recurse -File -Path $rootPath -Filter $filter;
    foreach ($file in $filesToDisable)
    {
    Write-Host $file.Name;
    if ($file.Extension -eq ".config")
    {
    $newFileName = $file.Name + ".disabled";
    $newFile = Rename-Item -Path $file.FullName -NewName $newFileName -PassThru;
    Write-Host "-> " $newFile.Name -ForegroundColor Green;
    }
    }
    }
    }