Get Azure VM Boot Diagnostics and filter some string to print out to the console using powershell.
I have used the below script using parameters :
param(
[Parameter(Mandatory=$true)]
[string]$vm,
[Parameter(Mandatory=$true)]
[string]$resourcegroup,
[Parameter(Mandatory=$true)]
[string]$storageaccountname,
[Parameter(Mandatory=$true)]
[string]$localpath
)
$vm = Get-AzureRmVM -ResourceGroupName $resourcegroup -Name $vm
Set-AzureRmVMBootDiagnostics -VM $VM -Enable -ResourceGroupName $resourcegroup -StorageAccountName $storageaccountname
Set-AzureRmVMBootDiagnostics -VM $VM -Enable -ResourceGroupName $resourcegroup -StorageAccountName $storageaccountname |Update-AzurermVM
Get-AzureRmVMBootDiagnosticsData -ResourceGroupName $resourcegroup -Name $vm -Windows -LocalPath $localpath
Output is getting error :
cmdlet Task3.1.ps1 at command pipeline position 1
Supply values for the following parameters:
vm: azbootvm
resourcegroup: AzRg
storageaccountname: mystacc
localpath: c:\folder
Set-AzureRmVMBootDiagnostics : Cannot bind parameter 'VM'. Cannot convert the
"Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine" value of type "System.String" to type
"Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine".
At
- Set-AzureRmVMBootDiagnostics -VM $VM -Enable -ResourceGroupName $reso ...
- ~~~
- CategoryInfo : InvalidArgument: (:) [Set-AzureRmVMBootDiagnostics], ParameterBindingException
- FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.Compute.SetAzureVMBootDiagnostic
sCommand
Set-AzureRmVMBootDiagnostics : Cannot bind parameter 'VM'. Cannot convert the
"Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine" value of type "System.String" to type
"Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine".
At
- Set-AzureRmVMBootDiagnostics -VM $VM -Enable -ResourceGroupName $reso ...
- ~~~
- CategoryInfo : InvalidArgument: (:) [Set-AzureRmVMBootDiagnostics], ParameterBindingException
- FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.Compute.SetAzureVMBootDiagnostic
sCommand
Get-AzureRmVMBootDiagnosticsData : The Resource
'Microsoft.Compute/virtualMachines/Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine' under resource group
'AzRg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
ErrorCode: ResourceNotFound
ErrorMessage: The Resource
'Microsoft.Compute/virtualMachines/Microsoft.Azure.Commands.Compute.Models.PSVirtualMachine' under resource group
'AzRg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
ErrorTarget:
StatusCode: 404
ReasonPhrase: Not Found
OperationID : 02ec93c5-8e59-4cff-a551-0a20cebb80dc
At