SitecorePowerShell / Console

Sitecore PowerShell Extensions
https://doc.sitecorepowershell.com/
Other
114 stars 70 forks source link

Hi I am not able to rebuild the link db in sitecore using spe 4.3 #893

Closed RajasekharVM closed 7 years ago

RajasekharVM commented 7 years ago

When i use commnads ( [Sitecore.Globals]::LinkDatabase.Rebuild($database))to rebuild, i am getting as "Unable to find type [Sitecore.Globals]."

Can you please guide me how to proceed

AdamNaj commented 7 years ago

Based on your example - I've just tried this in SPE ISE and it worked fine for me.

$database = Get-Database -Name "master"
[Sitecore.Globals]::LinkDatabase.Rebuild($database)

Can you tell more about how/where are you running it?

RajasekharVM commented 7 years ago

Hi Adam, We are trying by using Powershell ISE by importing SPE module. We are getting issue. Or rebuild functionality will work only on SPE ISE ?

RajasekharVM commented 7 years ago

i tried with SPE 4.5

RajasekharVM commented 7 years ago

suggest me how to install latest SPE on my local server.

RajasekharVM commented 7 years ago

We are facing some issue while rebuild the link databes, by using the blow code. https://michaellwest.blogspot.in/2015/05/sitecore-powershell-extensions-system-maintenance.html

While using the below code we are getting the error. And we are running the code by using Powershell ISE(Down loaded SPE 4.5 from market place and placed the spe modules and appconfig, bin and respective folders)

Error :

Unable to find type [Sitecore.Globals].

AdamNaj commented 7 years ago

This code will only work when executed in the context of a Sitecore process. You are getting the error because you are running in within the PowerShell ISE indeed. To execute it from PowerShell ISE but having your script body still run on the Sitecore server you need to wrap it with SPE remoting. With the following assumptions:

The following script executed in PowerShell ISE will work:

Import-Module -Name SPE
$session = New-ScriptSession -Username admin -Password b -ConnectionUri http://sitecoreinstance
$jobId = Invoke-RemoteScript -Session $session -ScriptBlock {
        Get-Database "master" | 
            ForEach-Object { 
                [Sitecore.Globals]::LinkDatabase.Rebuild($_)
            }
} -AsJob
Wait-RemoteScriptSession -Session $session -Id $jobId -Delay 5 -Verbose
Stop-ScriptSession -Session $session
RajasekharVM commented 7 years ago

Hi Adam, I am using above script which have mentioned. But while running the script i am getting the below message(it is not giving any error) and rebuild is not happening.. Can you please guide us to resolve the issue.

Messages VERBOSE: Checking the Runspace for the variable id. VERBOSE: Polling job 4d3b0808-534d-479e-a625-4b0712f80d4d. Status : Busy

AdamNaj commented 7 years ago

That means the operation is in progress and after a few messages like this, when the rebuild is finished it should give you the completion message.

RajasekharVM commented 7 years ago

After few messages it is saying that pulling job is available and finished pulling job.

Please find the below full messages while running the script:

VERBOSE: Checking the Runspace for the variable id. VERBOSE: Polling job 4d3b0808-534d-479e-a625-4b0712f80d4d. Status : Busy. VERBOSE: Checking the Runspace for the variable id. VERBOSE: Polling job 4d3b0808-534d-479e-a625-4b0712f80d4d. Status : Busy. VERBOSE: Checking the Runspace for the variable id. VERBOSE: Polling job 4d3b0808-534d-479e-a625-4b0712f80d4d. Status : Busy. VERBOSE: Checking the Runspace for the variable id. VERBOSE: Polling job 4d3b0808-534d-479e-a625-4b0712f80d4d. Status : Busy. VERBOSE: Checking the Runspace for the variable id. VERBOSE: Polling job 4d3b0808-534d-479e-a625-4b0712f80d4d. Status : Busy. VERBOSE: Checking the Runspace for the variable id. VERBOSE: Polling job 4d3b0808-534d-479e-a625-4b0712f80d4d. Status : Available. VERBOSE: Finished polling job 4d3b0808-534d-479e-a625-4b0712f80d4d. VERBOSE: Checking the Runspace for the variable id.

RajasekharVM commented 7 years ago

and script execution is stopped after getting the messages.

RajasekharVM commented 7 years ago

after the script execution when i checked the logs, it is showing as unitprocessed is blank.

AdamNaj commented 7 years ago

As far as I can see, from what you gave me, the processing has performed and the rebuilding should be successful.