A parameter cannot be found that matches parameter name 'MaxSizeGB' - azure

New-AzureSqlDatabase command on execution suddently started failing with parameter not found message. MSDN link mentions the parameter as supported.
https://msdn.microsoft.com/en-us/library/dn546722.aspx
Command : New-AzureSqlDatabase
Input
PS C:\scripts>$database1 = New-AzureSqlDatabase -ServerName
"lpqd0zbrseg" -DatabaseName "Database1" -Edition "Business" -MaxSizeGB
50 -Collation "SQL_Latin1_General_CP1_CI_AS"
Output Error
New-AzureSqlDatabase : A parameter cannot be found that matches
parameter name 'MaxSizeGB'. At line:1 char:103
+ ... dition "Basic" -MaxSizeGB 1 -Collation "SQL_Latin1_General_CP1_CI_AS"
+ ~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-AzureSqlDatabase], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Azure.Commands.Sql.Database.Cmdlet.NewAzureSqlDatabas
What would be the reason that MaxSizeGB parameter got not found on execution. Thanks in advance
With Regards,
H Bala

Business and Wed editions are a deprecated service level. Now, the service levels are Free, Basic, Standard & Premium as the error shows.
About the parameter, are you using the Azure PowerShell module configured as "Resource Manager" or "Service Management"? The first one hasn't that value but the second one have it.
You can change it with "Switch-AzureMode". You can find the explanation in the second section of the page.
Source Code of Resource Manager command
Source Code of Service Management command

Related

I get this error when I run a .py file in vs code, it says something is not recognized , can anyone help me to fix that?

I get this error when I run a .py file in vs code:
n38-32" "c:/Users/hassan kh/Desktop/MY FOLDER/Python Projects/1_1.py"
& : The term 'C:/Users/hassan kh/AppData/Local/Programs/Python/Python38-32' 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:1 char:3
+ & "C:/Users/hassan kh/AppData/Local/Programs/Python/Python38-32" "c:/Users/hassa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:/Users/hassan...hon/Python38-32:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I deleted Python and vs code and installed it again but I get this error yet. if anyone knows or had this problem before, please let me know how can I fix it?
Isn't the path should be with backward slash \ in the path.

Set-AzureRmDataFactoryV2IntegrationRuntime : Method not found

When I am trying "Set-AzureRmDataFactoryV2IntegrationRuntime" command constantly getting below error.
Set-AzureRmDataFactoryV2IntegrationRuntime : Method not found:
'Newtonsoft.Json.Serialization.IAttributeProvider
Newtonsoft.Json.Serialization.JsonProperty.get_AttributeProvider()'.
At C:\Users\ravi\source\repos\test.ps1:12 char:5
+ Set-AzureRmDataFactoryV2IntegrationRuntime `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzureRmData...egrationRuntime], MissingMethodException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.DataFactoryV2.SetAzureDataFactoryIntegrationRuntimeCommand
When I ran "Get-Module" command I see below list of modules
ModuleType Version Name
ExportedCommands
---------- ------- ---- ----------------
Script 0.5.10 AzureRM.DataFactoryV2
{Get-AzureRmDataFactoryV2, Get-AzureRmDataFactoryV2ActivityRun,
Get-AzureRmDat...
Script 5.6.0 AzureRM.profile
{Add-AzureRmEnvironment, Clear-AzureRmContext, Clear-AzureRmDefault,
Connect-A...
Manifest 3.1.0.0 Microsoft.PowerShell.Management
{Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest 3.0.0.0 Microsoft.PowerShell.Security
{ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl,
Get-AuthenticodeSi...
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member,
Add-Type, Clear-Variable, Compare-Object...}
Manifest 3.0.0.0 Microsoft.WSMan.Management
{Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan,
Enable-WSManCredSSP...}
Script 0.2.0 PowerShellEditorServices.Commands
{ConvertFrom-ScriptExtent, ConvertTo-ScriptExtent, Find-Ast,
Get-Token...}
Script 0.2.0 PowerShellEditorServices.VSCode
{Close-VSCodeHtmlContentView, New-VSCodeHtmlContentView,
Set-VSCodeHtmlContent...
I have installed Azure PowerShell MSI link given on below page.
Page URL: https://learn.microsoft.com/en-us/powershell/azure/other-install?view=azurermps-6.9.0
MSI URL: https://github.com/Azure/azure-powershell/releases/download/v6.9.0-September2018/azure-powershell.6.9.0.msi
Update:
When I was trying to create IS manually I see that its created but with "Unavailable" status
Updated on 10/10 for Joy Wang
I test the Set-AzureRmDataFactoryV2IntegrationRuntime on my side, it works fine. I recommend you to remove the modules and install again, refer to this link.
My specific command:
Set-AzureRmDataFactoryV2IntegrationRuntime -ResourceGroupName 'joywebapp' -DataFactoryName 'joyfactoryv2' -Name 'integrationRuntime35' -Type "SelfHosted" -Description 'New description111'
My module :
When I was trying to create IS manually I see that its created but with "Unavailable" status
To fix this issue of Self-Hosted type runtime, you could install the Microsoft Integration Runtime Configuration Manager, in the runtime -> Edit -> Click here to launch the express setup for this computer, refer to the screenshot.
After installing it, you will see them like the screenshot.
Check in the portal:

Use custom, composite resource with Azure DSC extension

I have a VM template that deploys a DSC extension. It's been working fine but my configuration is growing so I've refactored it to use a composite resource and republished it to blob storage with Publish-AzureRmVMDscConfiguration.
I verified that the .ps1.zip file in blob storage contains my custom module and that the module is listed under dscmetadata.json. However, when I deploy, the DSC extension fails. The logs under C:\WindowsAzure\Logs\Plugins\Microsoft.Powershell.DSC\2.17.0.0 reveal the reason:
C:\Packages\Plugins\Microsoft.Powershell.DSC\2.17.0.0\bin..\DSCWork\AppServerDev.ps1.0\AppserverDev.ps1
PSDesiredStateConfiguration\node : The module 'xCustomResource' could
not be loaded. For more information, run 'Import-Module
xCustomResource'.
At C:\Packages\Plugins\Microsoft.Powershell.DSC\2.17.0.0\DSCWork\AppServerDev.ps1.0\AppserverDev.ps1:9 char:3
node "localhost"
~~~~
CategoryInfo : ObjectNotFound: (xCustomResource\xCustomResource:String)
[PSDesiredStateConfiguration\node], ParentContainsErrorRecordException
FullyQualifiedErrorId : CouldNotAutoLoadModule,PSDesiredStateConfiguration\node
Here are the relevant bits of my configuration file:
configuration AppServerDev
{
param($environment)
Import-DscResource -ModuleName 'PSDesiredStateConfiguration'
Import-DscResource -ModuleName 'SaaSModule'
node "localhost"
{
LocalConfigurationManager
{
RebootNodeIfNeeded = $true
ConfigurationMode = "ApplyAndAutoCorrect"
ConfigurationModeFrequencyMins = 1440
}
xDCTPlatformVM VM {
OctopusParametersFile = $environment
ChocolateyPackages = #(
'googlechrome',
'notepadplusplus',
'7zip',
'microsoftwse',
'octopusdeploy.tentacle',
'sqlserver-cmdlineutils'
)
}
}
}
Running Get-Module -ListAvailable reveals that DankModule is found and I can, from powershell, run Import-Module DankModule and it works as expected. I assume the confusion is coming from it trying to import xCustomResource rather than DankModule but my .ps1 file under C:\Packages\Plugins\Microsoft.Powershell.DSC\2.17.0.0\DSCWork says
Import-Module "DankModule"
and not
Import-Module "xCustomType"
Why is it trying to import xCustomType rather than DankModule? How do I make it find DankModule which is available and contains xCustomType?
UPDATE: Get-Module -ListAvailable shows DankModule is installed but Get-DSCResource -Module DankModule doesn't return anything.
I'm not sure but I think this is a rookie mistake on my part because I have no experience building powershell modules. I was using this page as well as this one to construct my module and I'd gotten a valid module file by using New-ModuleManifest, I had the correct file structure mentioned in both of them e.g.
C:\Program Files\WindowsPowerShell\Modules\
DankModule
DankModule.psd1
DankModule.psm1
DSCResources
xCustomResource
xCustomResource.psd1
RootModule = ‘xCustomResource.schema.psm1'
xCustomResource.schema.psm1
Configuration, no Node block
but I didn't realize I had some tweaking left. I needed to correct the RootModule property in DankModule.psd1 to look like this:
RootModule = 'C:\Program Files\WindowsPowerShell\Modules\DankModule\DankModule.psm1'
And also needed to add to my blank DankModule.psm1 a line referencing my xCustomResource.schema.psm1 equivalent:
. .\DSCResources\xCustomResource\xCustomResource.schema.psm1
That is the only line in my module-level .psm1 file and everything is now working. I also, at one point, removed all the \0s from both my .psd1 files but now I'm not sure if that was strictly necessary.

Powershell and System.Security.Cryptography.X509Certificates.X509Certificate2

i'm getting this error when i run the system.security namespace. This is what i am running after
$cert=New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("C:\mycert.cer")
New-Object: Cannot find type [System.Security.Cryptography.X509Certificates.X509Certificate2("C:\mycert.cer")]: make sure the assembly containing this type is loaded.
At line:1 char:19
+ $cert = New-Object <<<<
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand**
What am i doing wrong?
Try running this to see if you have the System.dll loaded (should be by default):
[AppDomain]::CurrentDomain.GetAssemblies() |
Where {$_.Location -match '\\System\\'}
If it is loaded then this command should show the X509Certificate2 type:
[AppDomain]::CurrentDomain.GetAssemblies() |
Where {$_.Location -match '\\System\\'} |
%{$_.GetExportedTypes()} | Where {$_.Name -match 'X509Cert'}
If the System.dll isn't loaded (which would be odd) try loading it:
Add-Type -AssemblyName System
See: http://technet.microsoft.com/en-us/library/hh849914.aspx
FYI ... I got error:
Unable to find type [System.Security.Cryptography.x509Certificates.X509Certificate2UI]
when using:
$certSelect = [System.Security.Cryptography.x509Certificates.X509Certificate2UI]::SelectFromCollection($certCollection, $title, $msg, 0)
However, I had no error creating the collection earlier on in my script:
$certCollection = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection
To make the error go away I had to include the following at some point earlier on:
Add-Type -AssemblyName System.Security
I've solved my problem. It's easily:
cd\
$cert=New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("C:\mycert.cer")
cd\ is necessary
I ran into this in the ISE (but seems to apply to the normal command window too) and it seems that using autocomplete will automatically Add-Type for whatever you're looking for. If you start a new instance and run:
[AppDomain]::CurrentDomain.GetAssemblies() | grep Security
it will not return System.Security, but if you then type this and let intellisense do its thing:
[System.
You can then run this again:
[AppDomain]::CurrentDomain.GetAssemblies() | grep Security
And it will then return System.Security. So this is why you can write a script that works fine, and then revisit it later and it's broken. Using intellisense doesn't fix your script though, instead you have to add this line:
Add-Type System.Security
Or whatever library is not getting auto-added (it seems to need the dll filename, e.g. C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Security.dll).
I'm pretty sure IseSteroids (a paid ISE add-in) can detect this, maybe others as well.

I want to add web part in web part zone using powershell script

I want to add web part in the web part zone programmatically only using power shell script
I am getting this exception using power shell scripting
Exception code
$webPart = $webpartmanager.ImportWebPart($xmlReader, $errorMsg) -as [Microsoft.SharePoint.WebPartPages.WebPart]
Argument: '2' should be a System.Management.Automation.PSReference. Use [ref].
+ $webPart = $webpartmanager.ImportWebPart <<<< ($xmlReader, $errorMsg) -as [Microsoft.SharePoint.WebPartPages.WebPart]
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : NonRefArgumentToRefParameterMsg
Have you tried what the error message suggests (note the addition of [ref] before $errorMsg)?
$webPart = $webpartmanager.ImportWebPart($xmlReader, [ref]$errorMsg)
-as [Microsoft.SharePoint.WebPartPages.WebPart]

Resources