0

So, I have been unsuccessfully trying to restore a PowerApp environment for a Dynamics 365 instance, using Microsoft.PowerApps.Administration.PowerShell. The example according to MS docs for the command Syntax and example

shows that you need to create a pscustomobject first and then run the cmdlet. While trying to create a pscustomobject, Powershell throws this error

d4aaa888-a96z-54dg-9999-6942069b6qe9 :The term 'd4aaa888-a96z-54dg-9999-6942069b6qe9' is not recognized as 
the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again. 
At line:2 char:31
+         SourceEnvironmentId = c3aae985-d87c-49cb-8212-8624159a6ed8
+                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (    d4aaa888-a96z-54dg-9999-6942069b6qe9:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

The backup cmdlet seems to work but, with restore I am running into all kinds of issues. Plus just trying to create the RestorePointDateTime throws a

You cannot call a method on a null-valued expression error

Aditya Das
  • 1
  • 1
  • 2
  • 1
    Change `SourceEnvironmentId = c3aae985-d87c-49cb-8212-8624159a6ed8` to `SourceEnvironmentId = "c3aae985-d87c-49cb-8212-8624159a6ed8"` – Mathias R. Jessen Jun 07 '21 at 22:30
  • 1
    Apparently wrapping the SourceEnvironmentID in "" seems to have solved the issue. The example on the docs seems to be weird. – Aditya Das Jun 07 '21 at 22:33
  • In short: In PowerShell, assigning _strings_ to variables or properties (including as part of custom-object and hashtable literals) always requires _quoting_ - see [this answer](https://stackoverflow.com/a/67729013/45375). – mklement0 Jun 07 '21 at 23:15
  • As for the linked documentation page: I encourage you to provide feedback there. – mklement0 Jun 07 '21 at 23:16

0 Answers0