There isn’t a command for “get noise profile”. This is a limitation of the Noise Reduction effect.
The command “Noise Reduction…:” does one of two things:
If the Noise Reduction effect does not have a noise profile, then the command “Noise Reduction…:” tells the Noise Reduction effect to use the current selection as a noise profile.
If the Noise Reduction effect does have a noise profile, then the command “Noise Reduction…:” tells the Noise Reduction effect to apply noise reduction to the selection.
It is usually simplest to manually create the noise profile before running the macro.
A few years ago, a new style of built-in effects was created, that standardized the API for built-in effects. Macros and Scripting commands use this new API. Unfortunately, the Noise Reduction effect has not been rewritten in the new style - it is the last remaining effect to use the old style. Because of this, it is not fully supported by scripting / macros.
The Noise Reduction effect is also a rather complicated effect, so rewriting it in the “new style” is not an easy or quick task.
If you need to process a batch of files, and you need to get a new noise profile for each file, then unfortunately that cannot be done with a Macro.
Something that I’ve done (successfully) is:
Create a short generic noise sample that is similar to the noise in all of the files (it only needs to be a short sample, say 2 seconds).
Save the noise sample as a WAV file, and name it “AAA.wav” so that it comes first in the list of files.
Close and restart Audacity (Noise reduction now has no noise profile)
Run the macro.
The first file processed is “AAA.wav” (because it is the first in alpha-numeric order), and when Noise Reduction runs, it gets the profile from the track “AAA.wav”. For all other files, the macro applies noise reduction with the noise profile obtained from AAA.wav.