我对 Powershell 很陌生。我基本上只是使用我的 C# 逻辑和 .net 经验以及谷歌来创建这个脚本。我不明白为什么我收到错误:
无法处理参数“机器”上的参数转换。无法将值转换为 System.String 类型
function IterateThroughMachineSubkeys{
(
[Parameter()]
[string]$machine,
[Microsoft.Win32.RegistryKey]$subKey
)
foreach($subKeyName in $subKey.GetSubKeyNames())
{
Write-Host -Object ([System.String]::Format("Machine: {0} Module: {1} Version: {2}",
$machine.ToString(), $subKeyName.ToString(),
$subKey.OpenSubKey([string]$subKeyName).GetValue("Version", "Not found", [Microsoft.Win32.RegistryValueOptions]::None)))
}
}
Run Code Online (Sandbox Code Playgroud)
这是我调用函数的地方:
switch -CaseSensitive (ValidateConsoleInput((Read-Host).ToString()))
{
"E"
{
IterateThroughMachineSubkeys($machine.ToString(), $subKey)
}
"C"
{
Write-Host -Object "Enter the module name to be queried in the registry:"
GetSpecificSubkey($machine, $subkey, [string](Read-Host))
}
}
Run Code Online (Sandbox Code Playgroud) 我不知道 MSbuild 脚本,现在没有时间学习它。我需要在成功构建结束时使用一种方法来重命名 dacpac 文件以包含当前正在构建的版本。
示例:(TfsDropLocation)\filename.dapac 到 (TfsDropLocation\filename.1.0.0.0.dacpac)
有没有办法做到这一点?