我正在尝试将以下脚本作为运行手册运行,以将所有设置从一个 webapp 复制到另一个 webapp,但出现以下错误。
try
{
$acct = Get-AzureRmSubscription
}
catch
{
Login-AzureRmAccount
}
$fromResourceGroup = 'resourceG1'
$fromSite = 'website1'
$toResourceGroup = 'resourceG2'
$toSite = 'website2'
$props = (Invoke-AzureRmResourceAction -ResourceGroupName $fromResourceGroup -ResourceType Microsoft.Web/sites/Config -Name $fromSite/appsettings -Action list -ApiVersion 2015-08-01 -Force).Properties
$hash = @{}
$props | Get-Member -MemberType NoteProperty | % { $hash[$_.Name] = $props.($_.Name) }
Set-AzureRMWebApp -ResourceGroupName $toResourceGroup
-Name $toSite -AppSettings $hash
例外:
Get-Member : You must specify an object for the Get-Member cmdlet.
At line:18 char:10
+ $props | Get-Member -MemberType NoteProperty | % { $hash[$_.Name] = $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-Member], InvalidOperationException
+ FullyQualifiedErrorId : NoObjectInGetMember,Microsoft.PowerShell.Commands.GetMemberCommand
Set-AzureRMWebApp : The term 'Set-AzureRMWebApp' 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:20 char:1
+ Set-AzureRMWebApp -ResourceGroupName $toResourceGroup
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-AzureRMWebApp:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
-Name : The term '-Name' 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:21 char:9
+ -Name $toSite -AppSettings $hash
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (-Name:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException