PowerShell Script中的Function执行顺序

简介:

PowerShell是典型的批处理语言,即按照顺序一行一行的执行,不进行预编译;看下面的例子:

(1)将HW这个函数块放在前面,执行脚本顺利通过

image

(2)将将HW这个函数块放在前面,执行脚本不通过,提示没有发现这个HW函数;


image

 

编写powershell脚本不能用像其他编译语言的思维,不然调试都找不着问题出在哪儿?!




本文转自 bannerpei 51CTO博客,原文链接:http://blog.51cto.com/281816327/1545897,如需转载请自行联系原作者

相关文章
|
5月前
|
数据安全/隐私保护
【Azure Function App】PowerShell Function 执行 Get-AzAccessToken 的返回值类型问题:System.String 与 System.Security.SecureString
将PowerShell Function部署到Azure Function App后,Get-AzAccessToken返回值类型在不同环境中有差异。正常为SecureString类型,但部分情况下为System.String类型,导致后续处理出错。解决方法是在profile.ps1中设置环境变量$env:AZUREPS_OUTPUT_PLAINTEXT_AZACCESSTOKEN=false,以禁用明文输出。
171 1
|
9月前
【Function App】在PowerShell Function中指定特殊的Microsoft.Graph.Users版本
在Azure Function App中运行PowerShell Function时,通过Requirements.psd1文件管理模块版本。若需将“Microsoft.Graph.Users”从最新版2.26.0改回2.23.0以避免冲突,可通过以下步骤解决:1) 在requirements.psd1中明确指定版本为2.23.0 2) 在profile.ps1中添加`Import-Module Microsoft.Graph.Users -RequiredVersion 2.23.0`语句。此方法确保加载特定版本模块
179 19
【Azure 应用服务】Azure Powershell Function 出错 The term 'Connect-AzAccount' is not recognized
【Azure 应用服务】Azure Powershell Function 出错 The term 'Connect-AzAccount' is not recognized
183 0
|
Docker Windows 容器
Containers feature is disabled. Enable it using the PowerShell script (in an administrative PowerShe
Containers feature is disabled. Enable it using the PowerShell script (in an administrative PowerShe
283 0
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.
【Azure Durable Function】PowerShell Activity 函数遇见 Newtonsoft.Json.JsonReaderException: The reader's MaxDepth of 64 has been exceeded.
161 3
|
JSON 数据格式
【Azure 应用服务】Azure Function App 执行PowerShell指令[Get-Azsubscription -TenantId cxt]错误
【Azure 应用服务】Azure Function App 执行PowerShell指令[Get-Azsubscription -TenantId cxt]错误
132 0
【Azure 应用服务】Azure Function App 执行PowerShell指令[Get-Azsubscription -TenantId  cxt]错误
|
Ubuntu Linux 测试技术
【Azure Function App】Python Function调用Powershell脚本在Azure上执行失败的案例
【Azure Function App】Python Function调用Powershell脚本在Azure上执行失败的案例
144 0
【Azure 应用服务】Azure Function 启用 Managed Identity后, Powershell Funciton出现 ERROR: ManagedIdentityCredential authentication failed
【Azure 应用服务】Azure Function 启用 Managed Identity后, Powershell Funciton出现 ERROR: ManagedIdentityCredential authentication failed
278 0
|
Windows
【Azure 应用服务】Azure Function (PowerShell) 执行时报错 "out of memory"
【Azure 应用服务】Azure Function (PowerShell) 执行时报错 "out of memory"
108 0
【Azure 应用服务】Azure Function 中运行Powershell 脚本,定位 -DefaultProfile 引发的错误
【Azure 应用服务】Azure Function 中运行Powershell 脚本,定位 -DefaultProfile 引发的错误
153 0

热门文章

最新文章