Get Source Code for referenced functions in Azure Runbook
I'm new to powershell and Azure automation. Currently I've an Azure Automation Account and it has few Runbook jobs. I'm trying to add new logic to an existing Azure Runbook job by updating its powershell script. I see there are some functions but unfortunately we didn't maintain the source code :(. As the runbook is currently running without any issues, i want to know how to get the source code of the referenced functions.
I searched in the modules, modules gallery, python 2 packages, etc in the Automation Account used by this runbook as well as under Assets, cmdlets, and runbooks nodes (that you see in the Edit mode of the script in Portal) but couldn't find where these functions are referenced. I see one module which I suspect to have something related but not sure.
As an FYI, the functions are named like this:
GetClassicConnection,
GetRunAsConnection,
Set-Subscription $subcriptName
So here are my questions:
Is there are way to get the source code of all the referenced functions within this runbook powershell script? Something like disassembling a .NET dll using disassembler tools.
How to see the source code of an existing module in Automation Account that has its Status as "Available" under Modules section.
azure powershell azure-automation runbook
add a comment |
I'm new to powershell and Azure automation. Currently I've an Azure Automation Account and it has few Runbook jobs. I'm trying to add new logic to an existing Azure Runbook job by updating its powershell script. I see there are some functions but unfortunately we didn't maintain the source code :(. As the runbook is currently running without any issues, i want to know how to get the source code of the referenced functions.
I searched in the modules, modules gallery, python 2 packages, etc in the Automation Account used by this runbook as well as under Assets, cmdlets, and runbooks nodes (that you see in the Edit mode of the script in Portal) but couldn't find where these functions are referenced. I see one module which I suspect to have something related but not sure.
As an FYI, the functions are named like this:
GetClassicConnection,
GetRunAsConnection,
Set-Subscription $subcriptName
So here are my questions:
Is there are way to get the source code of all the referenced functions within this runbook powershell script? Something like disassembling a .NET dll using disassembler tools.
How to see the source code of an existing module in Automation Account that has its Status as "Available" under Modules section.
azure powershell azure-automation runbook
I can't speak to Azure Automation, but in general terms you can use(Get-Command $commandName).Definition
to get the source code of (body) of a function, and for compiled cmdlets it will display the syntax diagrams (parameters and their types). A locally installed module can be inspected via its installation directory atSplit-Path (Get-Module -ListAvailable $moduleName).Path
– mklement0
Nov 13 '18 at 14:17
add a comment |
I'm new to powershell and Azure automation. Currently I've an Azure Automation Account and it has few Runbook jobs. I'm trying to add new logic to an existing Azure Runbook job by updating its powershell script. I see there are some functions but unfortunately we didn't maintain the source code :(. As the runbook is currently running without any issues, i want to know how to get the source code of the referenced functions.
I searched in the modules, modules gallery, python 2 packages, etc in the Automation Account used by this runbook as well as under Assets, cmdlets, and runbooks nodes (that you see in the Edit mode of the script in Portal) but couldn't find where these functions are referenced. I see one module which I suspect to have something related but not sure.
As an FYI, the functions are named like this:
GetClassicConnection,
GetRunAsConnection,
Set-Subscription $subcriptName
So here are my questions:
Is there are way to get the source code of all the referenced functions within this runbook powershell script? Something like disassembling a .NET dll using disassembler tools.
How to see the source code of an existing module in Automation Account that has its Status as "Available" under Modules section.
azure powershell azure-automation runbook
I'm new to powershell and Azure automation. Currently I've an Azure Automation Account and it has few Runbook jobs. I'm trying to add new logic to an existing Azure Runbook job by updating its powershell script. I see there are some functions but unfortunately we didn't maintain the source code :(. As the runbook is currently running without any issues, i want to know how to get the source code of the referenced functions.
I searched in the modules, modules gallery, python 2 packages, etc in the Automation Account used by this runbook as well as under Assets, cmdlets, and runbooks nodes (that you see in the Edit mode of the script in Portal) but couldn't find where these functions are referenced. I see one module which I suspect to have something related but not sure.
As an FYI, the functions are named like this:
GetClassicConnection,
GetRunAsConnection,
Set-Subscription $subcriptName
So here are my questions:
Is there are way to get the source code of all the referenced functions within this runbook powershell script? Something like disassembling a .NET dll using disassembler tools.
How to see the source code of an existing module in Automation Account that has its Status as "Available" under Modules section.
azure powershell azure-automation runbook
azure powershell azure-automation runbook
edited Nov 14 '18 at 8:57
CHEEKATLAPRADEEP-MSFT
2,084413
2,084413
asked Nov 12 '18 at 23:58
mv_05
114
114
I can't speak to Azure Automation, but in general terms you can use(Get-Command $commandName).Definition
to get the source code of (body) of a function, and for compiled cmdlets it will display the syntax diagrams (parameters and their types). A locally installed module can be inspected via its installation directory atSplit-Path (Get-Module -ListAvailable $moduleName).Path
– mklement0
Nov 13 '18 at 14:17
add a comment |
I can't speak to Azure Automation, but in general terms you can use(Get-Command $commandName).Definition
to get the source code of (body) of a function, and for compiled cmdlets it will display the syntax diagrams (parameters and their types). A locally installed module can be inspected via its installation directory atSplit-Path (Get-Module -ListAvailable $moduleName).Path
– mklement0
Nov 13 '18 at 14:17
I can't speak to Azure Automation, but in general terms you can use
(Get-Command $commandName).Definition
to get the source code of (body) of a function, and for compiled cmdlets it will display the syntax diagrams (parameters and their types). A locally installed module can be inspected via its installation directory at Split-Path (Get-Module -ListAvailable $moduleName).Path
– mklement0
Nov 13 '18 at 14:17
I can't speak to Azure Automation, but in general terms you can use
(Get-Command $commandName).Definition
to get the source code of (body) of a function, and for compiled cmdlets it will display the syntax diagrams (parameters and their types). A locally installed module can be inspected via its installation directory at Split-Path (Get-Module -ListAvailable $moduleName).Path
– mklement0
Nov 13 '18 at 14:17
add a comment |
1 Answer
1
active
oldest
votes
I have not had teh reason, yet, to use Azure Runbooks, however, PowerShellCore is already open source and can be viewed on GitHub.
That being said, you can get source code from local cmdlets for example this way...
Param
(
[string]$CmdletName = (Get-Command -CommandType Cmdlet |
Out-GridView -Passthru)
)
# Get the DLL is it is a compiled cmdlet
'Getting DLL if the entered cmdlet name is a compiled cmdlet'
(Get-Command $CmdletName).DLL
'Getting cmdlet details / source code'
$metadata = New-Object system.management.automation.commandmetadata (Get-Command $CmdletName)
[System.management.automation.proxycommand]::Create($MetaData)
Note: Even with the above I've had issues with some cmdlets erroring out.
You can get source code from local functions for example this way...
Param
(
[string]$FunctionName = (Get-Command -CommandType Function |
Out-GridView -Passthru)
)
(Get-Command -Name $FunctionName).ScriptBlock
For dll, one could use the same approach for looking at any other .Net dlls, would be the same tools, ILSpy or dotNetPeek and the like
[System.management.automation.proxycommand]::Create()
doesn't retrieve source code, it creates the skeleton for a proxy function based on the input command's metadata.
– mklement0
Nov 13 '18 at 3:35
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271838%2fget-source-code-for-referenced-functions-in-azure-runbook%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I have not had teh reason, yet, to use Azure Runbooks, however, PowerShellCore is already open source and can be viewed on GitHub.
That being said, you can get source code from local cmdlets for example this way...
Param
(
[string]$CmdletName = (Get-Command -CommandType Cmdlet |
Out-GridView -Passthru)
)
# Get the DLL is it is a compiled cmdlet
'Getting DLL if the entered cmdlet name is a compiled cmdlet'
(Get-Command $CmdletName).DLL
'Getting cmdlet details / source code'
$metadata = New-Object system.management.automation.commandmetadata (Get-Command $CmdletName)
[System.management.automation.proxycommand]::Create($MetaData)
Note: Even with the above I've had issues with some cmdlets erroring out.
You can get source code from local functions for example this way...
Param
(
[string]$FunctionName = (Get-Command -CommandType Function |
Out-GridView -Passthru)
)
(Get-Command -Name $FunctionName).ScriptBlock
For dll, one could use the same approach for looking at any other .Net dlls, would be the same tools, ILSpy or dotNetPeek and the like
[System.management.automation.proxycommand]::Create()
doesn't retrieve source code, it creates the skeleton for a proxy function based on the input command's metadata.
– mklement0
Nov 13 '18 at 3:35
add a comment |
I have not had teh reason, yet, to use Azure Runbooks, however, PowerShellCore is already open source and can be viewed on GitHub.
That being said, you can get source code from local cmdlets for example this way...
Param
(
[string]$CmdletName = (Get-Command -CommandType Cmdlet |
Out-GridView -Passthru)
)
# Get the DLL is it is a compiled cmdlet
'Getting DLL if the entered cmdlet name is a compiled cmdlet'
(Get-Command $CmdletName).DLL
'Getting cmdlet details / source code'
$metadata = New-Object system.management.automation.commandmetadata (Get-Command $CmdletName)
[System.management.automation.proxycommand]::Create($MetaData)
Note: Even with the above I've had issues with some cmdlets erroring out.
You can get source code from local functions for example this way...
Param
(
[string]$FunctionName = (Get-Command -CommandType Function |
Out-GridView -Passthru)
)
(Get-Command -Name $FunctionName).ScriptBlock
For dll, one could use the same approach for looking at any other .Net dlls, would be the same tools, ILSpy or dotNetPeek and the like
[System.management.automation.proxycommand]::Create()
doesn't retrieve source code, it creates the skeleton for a proxy function based on the input command's metadata.
– mklement0
Nov 13 '18 at 3:35
add a comment |
I have not had teh reason, yet, to use Azure Runbooks, however, PowerShellCore is already open source and can be viewed on GitHub.
That being said, you can get source code from local cmdlets for example this way...
Param
(
[string]$CmdletName = (Get-Command -CommandType Cmdlet |
Out-GridView -Passthru)
)
# Get the DLL is it is a compiled cmdlet
'Getting DLL if the entered cmdlet name is a compiled cmdlet'
(Get-Command $CmdletName).DLL
'Getting cmdlet details / source code'
$metadata = New-Object system.management.automation.commandmetadata (Get-Command $CmdletName)
[System.management.automation.proxycommand]::Create($MetaData)
Note: Even with the above I've had issues with some cmdlets erroring out.
You can get source code from local functions for example this way...
Param
(
[string]$FunctionName = (Get-Command -CommandType Function |
Out-GridView -Passthru)
)
(Get-Command -Name $FunctionName).ScriptBlock
For dll, one could use the same approach for looking at any other .Net dlls, would be the same tools, ILSpy or dotNetPeek and the like
I have not had teh reason, yet, to use Azure Runbooks, however, PowerShellCore is already open source and can be viewed on GitHub.
That being said, you can get source code from local cmdlets for example this way...
Param
(
[string]$CmdletName = (Get-Command -CommandType Cmdlet |
Out-GridView -Passthru)
)
# Get the DLL is it is a compiled cmdlet
'Getting DLL if the entered cmdlet name is a compiled cmdlet'
(Get-Command $CmdletName).DLL
'Getting cmdlet details / source code'
$metadata = New-Object system.management.automation.commandmetadata (Get-Command $CmdletName)
[System.management.automation.proxycommand]::Create($MetaData)
Note: Even with the above I've had issues with some cmdlets erroring out.
You can get source code from local functions for example this way...
Param
(
[string]$FunctionName = (Get-Command -CommandType Function |
Out-GridView -Passthru)
)
(Get-Command -Name $FunctionName).ScriptBlock
For dll, one could use the same approach for looking at any other .Net dlls, would be the same tools, ILSpy or dotNetPeek and the like
answered Nov 13 '18 at 1:35
postanote
3,1331410
3,1331410
[System.management.automation.proxycommand]::Create()
doesn't retrieve source code, it creates the skeleton for a proxy function based on the input command's metadata.
– mklement0
Nov 13 '18 at 3:35
add a comment |
[System.management.automation.proxycommand]::Create()
doesn't retrieve source code, it creates the skeleton for a proxy function based on the input command's metadata.
– mklement0
Nov 13 '18 at 3:35
[System.management.automation.proxycommand]::Create()
doesn't retrieve source code, it creates the skeleton for a proxy function based on the input command's metadata.– mklement0
Nov 13 '18 at 3:35
[System.management.automation.proxycommand]::Create()
doesn't retrieve source code, it creates the skeleton for a proxy function based on the input command's metadata.– mklement0
Nov 13 '18 at 3:35
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271838%2fget-source-code-for-referenced-functions-in-azure-runbook%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I can't speak to Azure Automation, but in general terms you can use
(Get-Command $commandName).Definition
to get the source code of (body) of a function, and for compiled cmdlets it will display the syntax diagrams (parameters and their types). A locally installed module can be inspected via its installation directory atSplit-Path (Get-Module -ListAvailable $moduleName).Path
– mklement0
Nov 13 '18 at 14:17