London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

Powershell?

Vote:
 

Hi,

I'm trying to run Powershell commands for EPiServer, to upgrade the DDS. When issuing Get-EPiVersion I get the following error:

PS D:\> Get-EPiVersion -MapPath "D:\Websites\Site"
Get-EPiVersion : Object reference not set to an instance of an object.
At line:1 char:15
+ Get-EPiVersion <<<< -MapPath "D:\Websites\Site"
+ CategoryInfo : NotSpecified: (:) [Get-EPiVersion], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,EPiServer.Install.Common.Cmdlets.GetVersionCmdlet

I'm running Powershell versions 2 and 3 (on two different computers), and EPiServer 6.1.379.502.

#66537
Mar 04, 2013 14:11
Vote:
 

Could it be that you have not loaded the snapin containing the cmdlet? If so try this:

# Load the EPiServer Common snapin if required
$snapIn = Get-PSSnapin -Name EPiServer.Install.Common.1 -ErrorAction SilentlyContinue
if ($snapIn -eq $null)
{
Add-PSSnapin EPiServer.Install.Common.1
}

 

#66542
Mar 04, 2013 15:54
Vote:
 

Unfortunately not. :)

Here is the output of a new Powershell session:

PS D:\> Add-PSSnapin EPiServer.Install.Common.1
PS D:\> Add-PSSnapin EPiServer.Install.CMS.6.1.379.0
PS D:\> Get-EPiVersion -MapPath "D:\Websites\Site"
Get-EPiVersion : Object reference not set to an instance of an object.
At line:1 char:15
+ Get-EPiVersion <<<< -MapPath "D:\Websites\Site"
+ CategoryInfo : NotSpecified: (:) [Get-EPiVersion], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,EPiServer.Install.Common.Cmdlets.GetVersionCmdlet

I get the same results both on my local development machine, and the production servers on EverWeb.

#66543
Mar 04, 2013 16:05
Vote:
 

Ok, I just looked at the sourcecode for the cmdLet and it expects the foldername to be in "version" format, so you should be able to call it something like:

Get-EPiVersion -MapPath "C:\Program Files (x86)\EPiServer\CMS\6.1.379.0"

#66544
Mar 04, 2013 16:13
Vote:
 

Doh! I din't even consider using that directory as the directory for the commandlet... Thank you!!

Now, the question is - where can I find the Upgrade-EPiRemapDDSTypes commandlet?

#66545
Mar 04, 2013 17:02
Vote:
 

That should be in the EPiServer.Framework snapin

 

$snapIn = Get-PSSnapin -Name EPiServer.Framework.Install.6.2.267.1 -ErrorAction SilentlyContinue
if ($snapIn -eq $null)
{
Add-PSSnapin EPiServer.Framework.Install.6.2.267.1
}

 

#66548
Mar 04, 2013 17:27
Vote:
 

Hmm... Which DLL do I need to run InstallUtil on to be able to add that snap-in?

#66550
Mar 04, 2013 17:38
Vote:
 

That would be the not so famous EPiServer.Framework.Install.dll

#66560
Mar 05, 2013 9:08
Vote:
 

That was my guess, but I can't find that file on my system. It IS, however, installed in the GAC, but Powershell doesn't seem to find it.

I tried downloading the installation for EPiServer CMS 6 R2 and extracted the contents of EPiServer.Framework.msi, and there I found EPiServer.Framework.Install, which I renamed to EPiServer.Framework.Install.dll. However, when trying to install this dll, InstallUtil says it doesn't have any public installers.

Perhaps a better solution for me would be to take code for EPiServer.Framework.Install.Upgrade.RemapDDSType and add that to my project and run it from there instead? For unknown reasons, I need to remap EPiServer.Core,.PageObject in the DDS.

#66561
Mar 05, 2013 9:27
Vote:
 

Patrick,

Where you able to work around this? 

#71550
May 22, 2013 13:38
Vote:
 

Being as I were unable to remap with PowerShell, I added a call to the method below in my Global.asax.cs Application_Start(). This only does the remapping thought - not any property-renaming:

        private void ReMapType(string _type)
        {
            Type type = TypeResolver.GetType(_type);
            if (type != null)
            {
                string storeNameForType = DynamicDataStoreFactory.Instance.GetStoreNameForType(type);
                if (!string.IsNullOrEmpty(storeNameForType))
                {
                    StoreDefinition definition = StoreDefinition.Get(storeNameForType);
                    if (definition != null)
                    {
                        definition.Remap(type);
                        definition.CommitChanges();
                    }
                }
            }
        }

    

You have to reference EPiServer.Data.dll as well.

#71556
May 22, 2013 14:24
Vote:
 

That's kind of what I did as well, but I put it in an IInitializableModule.

I also added this:

foreach (var storeDefinition in StoreDefinition.GetAll())
{
	foreach (var propertyMap in storeDefinition.AllMappings)
	{
		storeDefinition.Remap(propertyMap.PropertyType);
	}

	storeDefinition.CommitChanges();
}

    

#71577
Edited, May 22, 2013 18:13
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.