Application Migration Service - Powershell Module - Returns only 50 records

0

I am trying to fetch the Source Servers with the powershell cmdlet get-mgnsourceserver, it is only fetching 50 records not more than that. Not sure if there is any limitation as such with the MGN Powershell module, Please let me know if there is any alternative to get all the source server list from the Application Migration Service (MGN).

1개 답변
0
수락된 답변

What is your use case. Could you please brief on the same. I am guessing that the powershell output is enabling pagination which is causing you to see only 50 records. Please check if you are getting a nexttoken in your reponse. Output Pagination with AWS Tools for PowerShell

I havent tested this code, let me know if this works:

# Get the account ID
$account_id = Get-Account

# Get the first page of results
$results = Get-MgnSourceServer -AccountId $account_id -MaxResults 100

# Loop through the results
while ($results.Count -gt 0) {

    # Get the current page of results
    foreach ($source_server in $results) {
        Write-Host $source_server
    }

    # Get the next page of results
    $results = Get-MgnSourceServer -AccountId $account_id -MaxResults 100 -NextToken $results.NextToken
}

You may try out some of the below steps if it works for you:

  1. In case of powershell, total number of items to return in the command's output could be controlled by using the parameter -MaxResult <Int32>
  2. If your command result returns more than the value defined for MaxResults, then you would need to use the parameter -NextToken to fetch the next set of records.
  3. You may also try the AWS CLI describe-source-servers with options like --no-paginate or --max-items
  4. You may try the AWS API documentation for DescribeSourceServers with request body maxResults or nextToken Let me know if this helps you.
AWS
Vijesh
답변함 9달 전
profile pictureAWS
전문가
검토됨 9달 전
  • Hi Vijesh, thanks for the suggestion. I have tried the -NextToken option, however it didn't work, it keep on fetch the same 50 records every time. Since there is no fix found for the Powershell module, I am going to continue with the AWS CLI, which is fetching all the source Servers. Thanks for suggesting the AWS CLI.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠