Azure Automation Account PowerShell string manipulation

MO-64 396 Reputation points
2023-07-25T09:12:26.6233333+00:00

I haven't been able to find any information on how to manipulate this string or even read the value of "Name" below:

*$blobs = Get-AzStorageBlob -Container $stContainer -Context $azCtx.Context | sort @{expression="LastModified";Descending=$true} | Select-Object -Property Name

$LatestBlobFile = $blobs[0]*

I now have the file name but it's in this format, as a string:

@{Name=TestFile-1.txt}

My question is, how do you get just "TestFile-1.txt" out of this?

Thank you very much for your help.

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,308 questions
0 comments No comments
{count} votes

Accepted answer
  1. Saurabh Sharma 23,826 Reputation points Microsoft Employee
    2023-07-26T22:58:42.4966667+00:00

    @MO-64

    Thanks for using Microsoft Q&A!!

    Based on the above response from you I believe you are unblocked manipulating the string. If yes, please 'Accept the answer' for the above reply. This will help other community members facing similar query to refer to this solution.

    Please let me know if that's not the case and we will look into your issue.

    Thanks,

    Saurabh

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. MO-64 396 Reputation points
    2023-07-25T09:19:48.0066667+00:00

    You simply do it this way:

    $LatestBlobFile = $blobs[0].Name

    The value of $LatestBlobFile will be TestFile-1.txt

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.