Last active
December 22, 2016 14:26
-
-
Save Kieranties/9545049 to your computer and use it in GitHub Desktop.
Revisions
-
Kieranties revised this gist
Mar 14, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Example of running Invoke-FillDB.ps1 # Additional files to download $downloads= @( "http://www.gutenberg.org/files/42698/42698-0.txt", "http://www.gutenberg.org/cache/epub/42705/pg42705.txt", @@ -12,7 +12,7 @@ $downloads= @( # Custom template $template = "{1C7E374B-44FC-4E33-8F8B-857D1A32CDC3}" # Additional fields on a custom template to populate $fields= @( "{DB074AA7-DF72-46C5-8269-E4A06FC8EC74}", "{6AB6FC48-D23C-465D-8D11-6BECB76C64CC}", -
Kieranties revised this gist
Mar 14, 2014 . 1 changed file with 9 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ # Example of running Invoke-FillDB.ps1 # Additonal files to download $downloads= @( "http://www.gutenberg.org/files/42698/42698-0.txt", @@ -8,8 +8,11 @@ $downloads= @( "http://www.gutenberg.org/files/42700/42700-0.txt", "http://www.gutenberg.org/files/42706/42706-0.txt" ) # Custom template $template = "{1C7E374B-44FC-4E33-8F8B-857D1A32CDC3}" # Additonal fields on a custom template to populate $fields= @( "{DB074AA7-DF72-46C5-8269-E4A06FC8EC74}", "{6AB6FC48-D23C-465D-8D11-6BECB76C64CC}", @@ -18,17 +21,17 @@ $fields= @( "{A4562857-67CC-48D3-9424-A0BF37C7F429}", "{EA0C14FF-2868-4F9A-8FCF-236B0DBCF86B}" ) $site = "http://sitecore.testsite" $username = "sitecore\username" $password = "password" # Invoke-FillDB performing all basic steps $response = .\Invoke-FillDB.ps1 $site $username $password -clearCache -runSqlScript ` -createWordsDir -wordsDir "words" -downloadFiles $downloads -templateFields $fields ` -templateGuid $template -prefix "Standard" ` -wordsPerField 100 -itemCount 100 -indexName "sitecore_master_index" # See the response $response.messages $response.success -
Kieranties revised this gist
Mar 14, 2014 . 1 changed file with 6 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,8 +19,12 @@ $fields= @( "{EA0C14FF-2868-4F9A-8FCF-236B0DBCF86B}" ) $site = "http://sitecore.testsite" $username = "sitecore\username" $password = "password" # Invoke-FillDB performing all basic steps $response = .\Invoke-FillDB.ps1 $site $username $password -clearCache -runSqlScript ` -createWordsDir -wordsDir "words" -downloadFiles $downloads -templateFields $fields ` -templateGuid "{1C7E374B-44FC-4E33-8F8B-857D1A32CDC3}" -prefix "Standard" ` -wordsPerField 100 -itemCount 100 -indexName "sitecore_master_index" @@ -30,7 +34,7 @@ $response.messages $response.success # Invoke-FillDB only creating items $response = .\Invoke-FillDB.ps1 $site $username $password -itemCount 100 -clearcache # See the response $response.messages -
Kieranties revised this gist
Mar 14, 2014 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -77,8 +77,8 @@ $body = @{ wordsPerField = $wordsPerField runIndex = $runIndex -or (-not [string]::IsNullOrEmpty($indexName)) -or ($indexRoots.Length -gt 0) indexName = $indexName indexRoots = $indexRoots -join "," json = $true } $session = Get-SitecoreSession -
Kieranties revised this gist
Mar 14, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -76,7 +76,7 @@ $body = @{ namePrefix = $prefix wordsPerField = $wordsPerField runIndex = $runIndex -or (-not [string]::IsNullOrEmpty($indexName)) -or ($indexRoots.Length -gt 0) indexName = $indexName indexRoots = $indexRoots -join "," json = $true } -
Kieranties created this gist
Mar 14, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ # Example of running Invoke-FillDB.ps1 # Additonal files to download $downloads= @( "http://www.gutenberg.org/files/42698/42698-0.txt", "http://www.gutenberg.org/cache/epub/42705/pg42705.txt", "http://www.gutenberg.org/cache/epub/42710/pg42710.txt", "http://www.gutenberg.org/files/42700/42700-0.txt", "http://www.gutenberg.org/files/42706/42706-0.txt" ) # Additonal fields on my custom template to populate $fields= @( "{DB074AA7-DF72-46C5-8269-E4A06FC8EC74}", "{6AB6FC48-D23C-465D-8D11-6BECB76C64CC}", "{D5E42CBE-3D6A-470F-A7B6-AC4EC7CF72D3}", "{3293A6C1-3E6F-45F3-9170-6D2D133C4304}", "{A4562857-67CC-48D3-9424-A0BF37C7F429}", "{EA0C14FF-2868-4F9A-8FCF-236B0DBCF86B}" ) # Invoke-FillDB performing all basic steps $response = .\Invoke-FillDB.ps1 "http://siteocre.testsite" "sitecore\username" "password" -clearCache -runSqlScript ` -createWordsDir -wordsDir "words" -downloadFiles $downloads -templateFields $fields ` -templateGuid "{1C7E374B-44FC-4E33-8F8B-857D1A32CDC3}" -prefix "Standard" ` -wordsPerField 100 -itemCount 100 -indexName "sitecore_master_index" # See the response $response.messages $response.success # Invoke-FillDB only creating items $response = .\Invoke-FillDB.ps1 "http://siteocre.testsite" "sitecore\username" "password" -itemCount 100 -clearcache # See the response $response.messages $response.success This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,86 @@ <# .SYNOPSIS Run FillDB.aspx on a Sitecore instance .DESCRIPTION Processes the FillDB.aspx admin page to create new items in Sitecore #> param( # The full url of the site to run FillDB on $site, # The user to login as - must have access to FillDb page $username, # The password of the user $password, # The database to run content into. Defaults to "master" $database = "master", # The directory to create/store/read txt files. Defaults to "/data/words" $wordsDir = "/data/words", # Set if the preparation sql script should be ran. [switch]$runSqlScript, # The sql preparation script. Defaults to "/sitecore/admin/SqlScripts/ItemGenerator.sql" $sqlScript = "/sitecore/admin/SqlScripts/ItemGenerator.sql", # Set if the words directory should be initialized [switch]$createWordsDir, # Set if the cache should be cleared [switch]$clearCache, # A collection of files to download [string[]]$downloadFiles, # The number of items to generate [int]$itemCount = 0, # The guid to create items under. Defaults to "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}" (Home) $parentGuid = "{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}", # The template guid to create items based on. Defaults to "{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}" (Sample Item) $templateGuid = "{76036F5E-CBCE-46D1-AF0A-4143F9B557AA}", # The fields of the template to populate. Defaults to "{A60ACD61-A6DB-4182-8329-C957982CEC74}","{75577384-3C97-45DA-A847-81B00500E250})" (Title and Text of Sample Item) [string[]]$templateFields = @("{A60ACD61-A6DB-4182-8329-C957982CEC74}","{75577384-3C97-45DA-A847-81B00500E250}"), # The prefix to add to the name of created items. Defaults to "Auto" $prefix = "Auto", # The maxium number of words to set in a field. Defaults to 25 [int]$wordsPerField = 25, # Set if the indexes should be rebuilt. [switch]$runIndex, # The index to rebuild after items are inserted. [string]$indexName, # The item ids to index from. [String[]]$indexRoots ) Function Get-SitecoreSession{ # Login - to create web session with authorisation cookies $loginPage = "$site/sitecore/admin/login.aspx" $login = Invoke-WebRequest $loginPage -SessionVariable webSession $form = $login.forms[0] $form.fields["LoginTextBox"] = $username $form.fields["PasswordTextBox"] = $password Invoke-WebRequest -Uri $loginPage -WebSession $webSession -Method POST -Body $form | Out-Null $webSession } # Parameters to post to fill db page $body = @{ database = $database wordsDir = $wordsDir runsql = $runSqlScript sqlScript = $sqlScript runWordsDir = $createWordsDir runDownloadFiles = $downloadFiles.Count -gt 0 downloadFiles = $downloadFiles -join "," runCacheClear = $clearCache runGenerate = $itemCount -gt 0 itemCount = $itemCount parentGuid = $parentGuid templateGuid = $templateGuid templateFields = $templateFields -join "," namePrefix = $prefix wordsPerField = $wordsPerField runIndex = $runIndex -or (-not [string]::IsNullOrEmpty($indexName)) -or ($indexRoots.Length -gt 0) indexName = $indexName indexRoots = $indexRoots -join "," json = $true } $session = Get-SitecoreSession $fillPage = "$site/sitecore/admin/filldb.aspx" Invoke-RestMethod -Uri $fillPage -WebSession $session -Method POST -Body $body