Getting error while exporting azure db using powershell - powershell

Followed Export SQL database example using link :
https://learn.microsoft.com/en-us/azure/sql-database/sql-database-export-powershell#export-sql-database-example
Getting below error:
New-AzureRmSqlDatabaseExport : ResourceNotFound: The Resource 'Microsoft.Sql/servers/XXX.database.windows.net/databases/[DBNAME]' under resource group 'Default-SQL-SoutheastAsia' was
not found.
At [FilePath]\sample.ps1:24 char:18
+ $exportRequest = New-AzureRmSqlDatabaseExport –ResourceGroupName $ResourceGroupN ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureRmSqlDatabaseExport], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Sql.ImportExport.Cmdlet.NewAzureSqlDatabaseExport
Get-AzureRmSqlDatabaseImportExportStatus : Cannot bind argument to parameter 'OperationStatusLink' because it is null.
At [FilePath]\sample.ps1:30 char:63
+ Get-AzureRmSqlDatabaseImportExportStatus -OperationStatusLink $exportRequest.Ope ...
+ CategoryInfo : InvalidData: (:) [Get-AzureRmSqlDatabaseImportExportStatus], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.Azure.Commands.Sql.ImportExport.Cmdlet.GetAzureSqlDatabaseImportExportStatus
Any help?

I had this same issue today, actually. I think if you change your server name to not use the fully-qualified name, that might do it. So, just use "xxxxx."
At least that's what worked for me.

You need to verify that your Automation account has latest modules imported and are up to date (AzureRM.Automation – AzureRM.Profile – AzureRM.Sql) atleast to Version: 2.5.0. If modules show a different version, i.e. 1.0.3 then:
navigate to assets in the automation account, select modules and click on
Update Azure Modules
.
Wait for the modules to get updated it normally takes a few minutes

Related

How to load in Powershell a DLL that is missing a manifest

These lines:
"[Environment]::Is64BitProcess"
"[Reflection.Assembly]::LoadFile("C:\MvxAPI\MvxSockx64.dll")
"
gives these results:
True
Exception calling "LoadFile" with "1" argument(s): "The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018)"
At C:\GitRepo\PowerShellScripts\ApiDllTest.ps1:11 char:1
+ [Reflection.Assembly]::LoadFile("C:\MvxAPI\MvxSockx64.dll")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : BadImageFormatException
The DLL is supplied by the ERP manufacture (Infor M3) and I'm trying to use it to send transactions to the ERP from a PowerShell program I've created. Since I'm not a system admin but instead just a nerd that supports the ERP, I'm actually clueless as to what I'm doing related to the DLL. Google has gotten me this far but i can't get beyond this error. The same error returns when I attempt to use the non x64 version.
Thanks for your wisdom. All suggestions are appreciated.

Powershell fails to load DLL because manifest is missing

These statements:
[Environment]::Is64BitProcess
[Reflection.Assembly]::LoadFile("C:\MvxAPI\MvxSockx64.dll")
Generate:
True
Exception calling "LoadFile" with "1" argument(s): The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018)
At C:\GitRepo\PowerShellScripts\ApiDllTest.ps1:11 char:1
+ [Reflection.Assembly]::LoadFile("C:\MvxAPI\MvxSockx64.dll")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : BadImageFormatException
From a PowerShell program I've written, I am trying to send transactions to the ERP system (Infor's M3) via a DLL for APIs. The DLL is provided by the manufacture. Since I am not a system admin but just a nerd supporting the ERP system, I'm clueless as to what I'm doing and have gotten this far with Google but can't get any further. Your suggestions will be greatly appreciated.

"Method Not found" error when calling GetElementsbyClassName

I created a PowerShell automation script and I gave it to my friend when he run it, it said
Method invocation failed because [mshtml.HTMLBodyClass] does not contain a method
named 'getElementsByClassName'.
At C:\Users\עמית\Documents\asaf.ps1:22 char:3
+ $a=$docs.body.getElementsByClassName("FadeOut-Scroll")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
why is that happened?
We both have IE11, .net 4.5, Visual studio, but I have that function and he not.
And it looks like here in his computer the IE console have the function:
but PowerShell does not:
How to update PowerShell?
Found after alot of time:
the missing want microsoft core xml

Powershell Error when run on a different machine

I wrote a script to take an AD user, disable the user, remove the user from group memberships and move the user to an OU. I originally wrote this on our Windows 2008 R2 DC (I know, bad idea) and I wanted to run the script locally on my Win 7 SP1 machine. It has the AD role installed as stated in this article (http://blogs.msdn.com/b/rkramesh/archive/2012/01/17/how-to-add-active-directory-module-in-powershell-in-windows-7.aspx)
I ran on both the DC and my Win7 machine $PSVersionTable and they are exactly the same. I can run ADSIEDIT.msc on the Win 7 machine. The error is occurring when doing an AD user lookup. See error output below:
Here is my script: https://github.com/nocode99/powershell/blob/master/UserDisableGroupRemoval.ps1
Property 'filter' cannot be found on this object; make sure it exists and is settable.
At C:\Admin\test.ps1:23 char:12
+ $ADsearch. <<<< filter = "(&(objectClass=user)(sAMAccountName=$user))"
+ CategoryInfo : InvalidOperation: (filter:String) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
You cannot call a method on a null-valued expression.
At C:\Admin\test.ps1:24 char:32
+ $ADfind = $ADsearch.findOne <<<< ()
+ CategoryInfo : InvalidOperation: (findOne:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Any ideas? The ActiveDirectory module imports with no issues and I want my users to run this locally on their machine rather than the DC.
Looks like I needed to include a filter before the lookup and added:
$adsearch = [adsisearcher]""
though I'm not sure why this works without the filter on AD server itself.

Entitiy Framework migration with EF in multiple projects

Currently I trying to separate my data model into a different project in the same solution, with code first. If I only have one project with EF( 6.1.3 ) installed, migration ( Enable-Migration, Add-Migration ) work as intended.
But as I add an other project and install EF packet, if i try Enable-Migration, I've got this error:
Join-Path : Cannot bind argument to parameter 'Path' because it is null.
At C:\projects\IMS 2\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:713 char:27
+ $toolsPath = Join-Path <<<< $installPath tools
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
Join-Path : Cannot bind argument to parameter 'Path' because it is null.
At C:\projects\IMS 2\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:780 char:73
+ $utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-Path <<<< $ToolsPath EntityFramework.PowerShell.Utility.dll))
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
You cannot call a method on a null-valued expression.
At C:\projects\IMS 2\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:781 char:50
+ $dispatcher = $utilityAssembly.CreateInstance <<<< (
+ CategoryInfo : InvalidOperation: (CreateInstance:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Join-Path : Cannot bind argument to parameter 'Path' because it is null.
At C:\projects\IMS 2\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:810 char:19
+ (Join-Path <<<< $runner.ToolsPath EntityFramework.PowerShell.dll),
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
EF seems to work fine in both of the projects. Reinstalling EF to either or both of the projects did not solve it. Any solution in mind?
EDIT: I started a new solution with 3 projects, 1. for the basecontext( public class BaseContext<TContext> : DbContext where TContext : DbContext ... ), 2. for base classes, and 3. for creating a context based on base context and the classes. If i put ef in only one then migrtation works, or at least tells me thet it can't find a context, but if i install it into more then one, then it's producing the error again.
I found the same problem today and I had to uninstall the EF and install again.
PM> Uninstall-Package EntityFramework -Force
PM> Install-Package EntityFramework -Pre
Ok, solved it, the problem was not EF, or VS2015, but my Windows 7, since it come with PowerShell 2, but EF or VS required PowerShell 3 to work properly. After updating to it the errors was gone.
Then i run ito this bug: https://connect.microsoft.com/VisualStudio/feedback/details/1302181/add-migration-bug what is currently under review.
It seems like that it's caused by some configuration bug in the VS2015 RC release. Rolled back to VS13 with powershell 2, reinstalled the related nuget packages, and it's working fine now.