Parse script #Requires with Get-Help -Name '<path_to_file>'?
#25466
o-l-a-v
started this conversation in
Enhancements
Replies: 1 comment
-
|
I just found: [System.Management.Automation.Language.Parser]::ParseFile($ScriptFilePath, [ref]$null, [ref]$null).ScriptRequirementsthanks to: Neat. :) With the example in the original post: PS > [System.Management.Automation.Language.Parser]::ParseFile($ScriptFilePath, [ref]$null, [ref]$null).ScriptRequirements | ConvertTo-Json
{
"RequiredApplicationId": null,
"RequiredPSVersion": {
"Major": 7,
"Minor": 4,
"Build": -1,
"Revision": -1,
"MajorRevision": -1,
"MinorRevision": -1
},
"RequiredPSEditions": [],
"RequiredModules": [
{
"Name": "Az.Accounts",
"Guid": null,
"Version": null,
"MaximumVersion": null,
"RequiredVersion": null
},
{
"Name": "Az.Resources",
"Guid": null,
"Version": null,
"MaximumVersion": null,
"RequiredVersion": null
}
],
"RequiredAssemblies": [],
"IsElevationRequired": false
}
PS >But would still be useful if |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm looking into doing less clickops with Azure Automation Account + PowerShell.
Ideally I'd like to parse metadata from a
runbook.ps1, like.SYNOPSIScan become runbook description.I'd also like to be able to easily parse / get out
#Requiresinformation, like-Version 7.4and-Modules Az.Accounts, Az.Resources, and that way dynamically create runtime environment in Automation Account, and add required modules to it.Seems
Get-Helpdoes not get out this information. Are there any other native cmdlets that can do this?Sample
file.ps1, have to add a blank line between#Requiresand comment based help / CBH due to:gives with v7.5.1:
Beta Was this translation helpful? Give feedback.
All reactions