Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 导出csv不会提供我期望的数据_Powershell - Fatal编程技术网

Powershell 导出csv不会提供我期望的数据

Powershell 导出csv不会提供我期望的数据,powershell,Powershell,当我在csv中获得的数据下面运行代码时,它没有我期望的服务器名称 相反,这是我在.csv文件中得到的 Length 204 我将替换: "$varservertoreboot is rebooting" | Export-Csv $varoutfile -Append -NoClobber -NoTypeInformation "$(get-date -f yyyy-MM-dd-HH-mm-ss) Today is $vardow, The system $varservertoreboot

当我在csv中获得的数据下面运行代码时,它没有我期望的服务器名称

相反,这是我在.csv文件中得到的

Length 204 我将替换:

"$varservertoreboot is rebooting" | Export-Csv $varoutfile -Append -NoClobber -NoTypeInformation

"$(get-date -f yyyy-MM-dd-HH-mm-ss) Today is $vardow, The system $varservertoreboot is rebooting" | Export-Csv $varoutfile
与:


您可能是指输出文件,而不是导出Csv。在添加原始字符串时,“导出Csv”尝试将对象属性解构到列中。当然,字符串除了长度之外没有其他有意义的属性,所以这就是您得到的。谢谢。我试试看。
"$varservertoreboot is rebooting" | Export-Csv $varoutfile -Append -NoClobber -NoTypeInformation

"$(get-date -f yyyy-MM-dd-HH-mm-ss) Today is $vardow, The system $varservertoreboot is rebooting" | Export-Csv $varoutfile
Add-Content -Value "$varservertoreboot is rebooting" -Path $varoutfile

Add-Content -Value "$(get-date -f yyyy-MM-dd-HH-mm-ss) Today is $vardow, The system $varservertoreboot is rebooting" -Path $varoutfile