【发布时间】:2020-05-25 20:33:39
【问题描述】:
首先对不起我的英语。
我不使用 powershell,但我必须编写一个脚本来生成一些 SSRS 的报告。我需要连接两个变量并将结果转换为大写,下面的代码可以正常工作,但我不知道将结果转换为大写并将其放入其他变量中。非常感谢
$direxcel = "C:\Users\Administrador\Documents\SSRS"
$rdl = "Sin Título"
write-host ${direxcel}\$rdl.xls
【问题讨论】:
-
"${direxcel}\$rdl.xls".ToUpper()- PowerShell 是基于 .NET 构建的,因此您可以访问其类型及其方法,例如System.String.ToUpper。将一个值传递给Get-Member以了解它是什么类型。 -
试试
$filePath = (Join-Path -Path $direxcel -ChildPath ($rdl + '.xls')).ToUpper()。见Join-Path -
由于 powershell 字符串是 .net 对象,
toupper()开关应该可以做到这一点。例如,"Hello World".toupper() -
谢谢,工作正常
标签: powershell string-concatenation