PowerShell调用RestMethod无法写入输出文件?

PowerShell调用RestMethod无法写入输出文件?,powershell,logging,invoke,Powershell,Logging,Invoke,我已经能够让它工作并输出到屏幕上,但我想把它写入一个文本文件 承蒙: 我正在努力解决的问题是,我可以将以下行写入输出文件,很好: Add-Content $result "Server $tomcatserver" 但是,将整数写入输出文件不起作用: Add-Content $result Memory_Used [string]$memory.total 我应该看到的是: Server : SERVER1 Memory_Used

我已经能够让它工作并输出到屏幕上,但我想把它写入一个文本文件

承蒙:

我正在努力解决的问题是,我可以将以下行写入输出文件,很好:

Add-Content $result "Server $tomcatserver"
但是,将整数写入输出文件不起作用:

Add-Content $result Memory_Used [string]$memory.total
我应该看到的是:

Server                        : SERVER1
Memory_Used                   : 1948254208
Memory_free                   : 820702992
Memory_Max                    : 1948254208
Current_Threads_busy          : 1
Current_Thread_Count          : 27
Max_Threads                   : 150
Request_Max_ProcessingTime_ms : 156454
Request_Count                 : 669515
ProcessingTime_total_s        : 88929596
谢谢

任意使用

Add-Content $result ("Memory_Used: " + $memory.total)

任用

Add-Content $result ("Memory_Used: " + $memory.total)


你的代码有什么问题?提示:您应该使用
$result=Join Path$scriptPath'results.txt'
。它似乎可以很好地写入字符串,但无法将整数写入日志文件,例如:
添加内容$result'Memory\u Used'+$Memory.total
您能在Q中包含文件中的当前输出吗?完成。。谢谢你。我已经澄清了问题和结果。请尝试使用
添加内容$result“Memory\u Used$($Memory.total)”
?您的代码有什么问题?提示:您应该使用
$result=Join Path$scriptPath'results.txt'
。它似乎可以很好地写入字符串,但无法将整数写入日志文件,例如:
添加内容$result'Memory\u Used'+$Memory.total
您能在Q中包含文件中的当前输出吗?完成。。谢谢你。我已经澄清了问题和结果。请尝试使用
添加内容$result“Memory\u Used$($Memory.total)”
Add-Content $result "Memory_Used: $($memory.total)"